Well, with jelly, you can easily modify a stream of SAX events.

But you can definitely parse a document, store it in a variable, modify it (accessing it using XPath for example) then re-output it...

Down here is such a snippet, it parses a bunch of files together and re-outputs it in one file...

Do note that if you're using DTDs or Schemas, the default values specified there will come in...

Also, do not that jelly has a strong tendency to ignore all whitespace by default (the trim attribute just about everywhere) which may or may not be wished...

Paul

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly
        xmlns:j         ="jelly:core"
        xmlns:log       ="jelly:log"
        xmlns:x         ="jelly:xml"
        xmlns:ant       ="jelly:ant"
        xmlns:util="jelly:util"
        xmlns:b="jelly:beanshell"
        >
        
        <log:info>Constructing File scanner.</log:info>
  <ant:fileScanner var="blopFiles">
    <ant:fileset dir="." includes="blop/**/dependency.xml"/>
         </ant:fileScanner>

         <log:info>File scanner constructed.</log:info>
        <!--                 - amalgamate all files within one object -->
        <x:parse var="all_files">
                <my:allFiles xmlns:my="myNamespace">
                        <j:forEach var="file" items="${blopFiles.iterator()}">
                                <j:set var="url" value="${file.toURL()}"/>
                                <log:info>Going around ${url}</log:info>
                                <my:file
                                                href="${url.toExternalForm()}">
                                        <j:include uri="${url.toExternalForm()}"/>
                                </my:file>
                        </j:forEach>
                        </my:allFiles>
                </x:parse>


<!-- do something on there like something using
x:forEach which goes around XPath elements -->

<j:file name="someFile.xml" outputMode="HTML" ><!-- prettyPrint="yes" -->
<x:copyOf select="$all_files"/>
</j:file>


</j:jelly>


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to