Quantcast

groovy.xml.MarkupBuilder

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

groovy.xml.MarkupBuilder

Russel Winder
I have almost certainly just missed something obvious but is there any
easy idiomatic way of getting <?xml...?> and <!DOCTYPE...> tags out of
the groovy.xml.MarkupBuilder?  JDOM and dom4j make this quite easy.

--
Russel.
====================================================
Dr Russel Winder                +44 20 7585 2200
41 Buckmaster Road              +44 7770 465 077
London SW11 1EN, UK             [hidden email]

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

tugwilson

On 20 Mar 2006, at 21:03, Russel Winder wrote:

> I have almost certainly just missed something obvious but is there any
> easy idiomatic way of getting <?xml...?> and <!DOCTYPE...> tags out of
> the groovy.xml.MarkupBuilder?  JDOM and dom4j make this quite easy.

No but you can do it with StreamingMarkupBuilder.

ther's a command called mkp.yieldUnescaped which lets you drop  
arbitrary CDATA into XML documents so you can use that for the XML  
declaration and the internal DTD subset.

It lets lets you insert PIs and comments

mkp.comment "this is a comment"

mkp.pi("myTarget", "myInstruction")

mkp.pi("myTarget", [name1: "value1", name2: "value2"])


John Wilson
The Wilson Partnership
http://www.wilson.co.uk


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

Russel Winder
On Mon, 2006-03-20 at 21:27 +0000, John Wilson wrote:

> > I have almost certainly just missed something obvious but is there any
> > easy idiomatic way of getting <?xml...?> and <!DOCTYPE...> tags out of
> > the groovy.xml.MarkupBuilder?  JDOM and dom4j make this quite easy.
>
> No but you can do it with StreamingMarkupBuilder.

That seems a shame.  I tried replacing MarkupBuilder with Streaming
MarkupBuilder in a script that worked but now it produces:

Caught: groovy.lang.MissingMethodException: No signature of method
groovy.xml.StreamingMarkupBuilder.contacts() is applicable for argument
types: (writeContacts_better$_run_closure1) values:
{writeContacts_better$_run_closure1@c931fc}
        at
groovy.xml.streamingmarkupsupport.AbstractStreamingBuilder.invokeMethod(AbstractStreamingBuilder.groovy)
        at writeContacts_better.run(writeContacts_better.groovy:6)
        at writeContacts_better.main(writeContacts_better.groovy)

Which means that StreamingMarkupBuilder must be used very differently to
MarkupBuilder.  Google doesn't have any  StreamingMarkupBuilder examples
indexed from what I can see quickly.

> ther's a command called mkp.yieldUnescaped which lets you drop  
> arbitrary CDATA into XML documents so you can use that for the XML  
> declaration and the internal DTD subset.
>
> It lets lets you insert PIs and comments
>
> mkp.comment "this is a comment"
>
> mkp.pi("myTarget", "myInstruction")
>
> mkp.pi("myTarget", [name1: "value1", name2: "value2"])
This sort of code doesn't work for me :-(

As a side question:  I assume there is a parameter you can give in the
constructor to the MarkupBuilder to redirect output from standard output
to a file.  I.e. instead of:

        def xml = new groovy.xml.MarkupBuilder ( )

sending output to a file is achieved by...

Thanks.

--
Russel.
====================================================
Dr Russel Winder                +44 20 7585 2200
41 Buckmaster Road              +44 7770 465 077
London SW11 1EN, UK             [hidden email]

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

tugwilson

On 21 Mar 2006, at 08:01, Russel Winder wrote:

> On Mon, 2006-03-20 at 21:27 +0000, John Wilson wrote:
>
>>> I have almost certainly just missed something obvious but is  
>>> there any
>>> easy idiomatic way of getting <?xml...?> and <!DOCTYPE...> tags  
>>> out of
>>> the groovy.xml.MarkupBuilder?  JDOM and dom4j make this quite easy.
>>
>> No but you can do it with StreamingMarkupBuilder.
>
> That seems a shame.  I tried replacing MarkupBuilder with Streaming
> MarkupBuilder in a script that worked but now it produces:
>
> Caught: groovy.lang.MissingMethodException: No signature of method
> groovy.xml.StreamingMarkupBuilder.contacts() is applicable for  
> argument
> types: (writeContacts_better$_run_closure1) values:
> {writeContacts_better$_run_closure1@c931fc}
>         at
> groovy.xml.streamingmarkupsupport.AbstractStreamingBuilder.invokeMetho
> d(AbstractStreamingBuilder.groovy)
>         at writeContacts_better.run(writeContacts_better.groovy:6)
>         at writeContacts_better.main(writeContacts_better.groovy)
>
> Which means that StreamingMarkupBuilder must be used very  
> differently to
> MarkupBuilder.  Google doesn't have any  StreamingMarkupBuilder  
> examples
> indexed from what I can see quickly.

Well there are example of the use in the unit tests and Google comes  
up with a reasonable number of examples.

My presentation to XML2004 linked here: http://groovy.codehaus.org/ 
Articles gives an extended example.

>
>> ther's a command called mkp.yieldUnescaped which lets you drop
>> arbitrary CDATA into XML documents so you can use that for the XML
>> declaration and the internal DTD subset.
>>
>> It lets lets you insert PIs and comments
>>
>> mkp.comment "this is a comment"
>>
>> mkp.pi("myTarget", "myInstruction")
>>
>> mkp.pi("myTarget", [name1: "value1", name2: "value2"])
>
> This sort of code doesn't work for me :-(

Details?

>
> As a side question:  I assume there is a parameter you can give in the
> constructor to the MarkupBuilder to redirect output from standard  
> output
> to a file.  I.e. instead of:
>
> def xml = new groovy.xml.MarkupBuilder ( )
>
> sending output to a file is achieved by...
>

I'm not sure i really don't use MarkupBuilder

with StreamingMarkupBuilder the process of binding the closure to the  
builder produces a Writable object so you can write it wherever you  
like.



John Wilson
The Wilson Partnership
http://www.wilson.co.uk


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

Russel Winder
On Tue, 2006-03-21 at 08:15 +0000, John Wilson wrote:

> > MarkupBuilder.  Google doesn't have any  StreamingMarkupBuilder  
> > examples
> > indexed from what I can see quickly.
>
> Well there are example of the use in the unit tests and Google comes  
> up with a reasonable number of examples.

I am being stupid, I should have looked in the unit tests.

You must be better at using Google than me as I found lots of references
to Fisheye but no useful things ;-)

> My presentation to XML2004 linked here: http://groovy.codehaus.org/ 
> Articles gives an extended example.

Excellent, thanks.

I now have a StreamingMarkupBuilder example working and with the use of
<<, all the C++ addicts in the audience of the talk will become very
happy :-)

> >> mkp.pi("myTarget", "myInstruction")
> >>
> >> mkp.pi("myTarget", [name1: "value1", name2: "value2"])
> >
> > This sort of code doesn't work for me :-(
>
> Details?

If I put lines like that in the closure being used in the builder.bind
call then I get no output.  I guess I am being slow this morning.

> I'm not sure i really don't use MarkupBuilder

Does anyone use MarkupBuilder or is StreamingMarkupBuilder now Groovy
standard?

> with StreamingMarkupBuilder the process of binding the closure to the  
> builder produces a Writable object so you can write it wherever you  
> like.

This makes sense to me and the examples will sit well with the C++
mindset.

Is XmlSlurper the Groovy standard reader or is there the same sort of
dichotomy we have with MarkupBuilder and StreamingMarkupBuilder ?

Thanks.

--
Russel.
====================================================
Dr Russel Winder                +44 20 7585 2200
41 Buckmaster Road              +44 7770 465 077
London SW11 1EN, UK             [hidden email]

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

Russel Winder
In reply to this post by tugwilson
On Mon, 2006-03-20 at 21:27 +0000, John Wilson wrote:
> On 20 Mar 2006, at 21:03, Russel Winder wrote:
>
> > I have almost certainly just missed something obvious but is there any
> > easy idiomatic way of getting <?xml...?> and <!DOCTYPE...> tags out of
> > the groovy.xml.MarkupBuilder?  JDOM and dom4j make this quite easy.
>
> No but you can do it with StreamingMarkupBuilder.

Not totally true it seems.  MarkupBuilder can take a Writer as a
constructor parameter and then it writes to that stream.

writer = new BufferedWriter ( new FileWriter ( 'contacts.xml' ) )
def xml = new groovy.xml.MarkupBuilder ( writer )
def eol = System.properties.'line.separator'
writer << '<?xml version="1.0" encoding="UTF-8"?>' << eol
xml.contacts {
    contact {

etc.

Trivial but...

MarkupBuilder inserts appropriate indentation before each element and
appends an EOL after each element whereas StreamingMarkupBuilder does
not.  Irrelevant for general processing but not for creating human
readable files.  Is there a formatting option (a la dom4j etc.) that
creates human readable output with StreamingMarkupBuilder?

--
Russel.
====================================================
Dr Russel Winder                +44 20 7585 2200
41 Buckmaster Road              +44 7770 465 077
London SW11 1EN, UK             [hidden email]

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

tugwilson

On 21 Mar 2006, at 09:24, Russel Winder wrote:

> Trivial but...
>
> MarkupBuilder inserts appropriate indentation before each element and
> appends an EOL after each element whereas StreamingMarkupBuilder does
> not.  Irrelevant for general processing but not for creating human
> readable files.  Is there a formatting option (a la dom4j etc.) that
> creates human readable output with StreamingMarkupBuilder?


MarkupBuilder cannot emit mixed content. I think that this is a  
pretty major deficiency. However as it can't ever produce mixed  
content then it can "pretty print" the output without screwing the  
document up.

StreamingMarkupBuilder can produce mixed content so it does not  
attempt to pretty print the output because doing so could break a  
document. I don't intend to add pretty printing as an option. I just  
load the output into an XMl editor (I use Oxygen) and use the  
formatting feature there if I want to see the structure.


John Wilson
The Wilson Partnership
http://www.wilson.co.uk


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

tugwilson
In reply to this post by Russel Winder

On 21 Mar 2006, at 09:07, Russel Winder wrote:

>
> If I put lines like that in the closure being used in the builder.bind
> call then I get no output.  I guess I am being slow this morning.
>


No I got the example wrong!

Here's a full scale example of the use

import groovy.xml.StreamingMarkupBuilder

class C {
static atomPerson = {name, url = null, email = null ->
   mkp.declareNamespace(atom: "http://purl.org/atom/ns#")

   atom.name name
   if (url != null) atom.url url
   if (email != null) atom.email email
}

static doc = new StreamingMarkupBuilder().bind {
   mkp.declareNamespace(atom: "http://purl.org/atom/ns#")

   atom.feed(version: ".3") {
     mkp.pi(target: "body")
     mkp.pi(target:  [name1: "value1", name2: "value2"])
     atom.title "Test Jobs"
     atom.link(href: "http://www.example.org", rel: "alternate",  
type: "text/html")
     atom.modified " 2005-10-11T18:30:02Z"
     atom.author {
       def person = atomPerson.clone()
       person.delegate = delegate
       person "John Wilson"
     }
     atom.id "tag:example.org"
     atom.entry {
       atom.title "Test Job - don't apply "
       atom.link(href: "http://www.example.org")
       atom.summary "This is a test please don't apply for this job"
       atom.id "tag:example.org"
       atom.issued "2005-10-13T18:30:02Z"
       atom.modified "2005-10-13T18:30:02Z"
     }
   }
}

static main(args) {
     System.out << doc
}
}


Produces this output (after pretty printing)

<atom:feed version=".3" xmlns:atom="http://purl.org/atom/ns#">
     <?target body?>
     <?target name1="value1" name2="value2"?>
     <atom:title>Test Jobs</atom:title>
     <atom:link href="http://www.example.org" type="text/html"  
rel="alternate"/>
     <atom:modified> 2005-10-11T18:30:02Z</atom:modified>
     <atom:author>
         <atom:name>John Wilson</atom:name>
     </atom:author>
     <atom:id>tag:example.org</atom:id>
     <atom:entry>
         <atom:title>Test Job - don't apply </atom:title>
         <atom:link href="http://www.example.org"/>
         <atom:summary>This is a test please don't apply for this  
job</atom:summary>
         <atom:id>tag:example.org</atom:id>
         <atom:issued>2005-10-13T18:30:02Z</atom:issued>
         <atom:modified>2005-10-13T18:30:02Z</atom:modified>
     </atom:entry>
</atom:feed>



John Wilson
The Wilson Partnership
http://www.wilson.co.uk


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

Russel Winder
In reply to this post by tugwilson
On Tue, 2006-03-21 at 09:34 +0000, John Wilson wrote:

> MarkupBuilder cannot emit mixed content. I think that this is a  
> pretty major deficiency. However as it can't ever produce mixed  
> content then it can "pretty print" the output without screwing the  
> document up.

This is certainly a problem for tasks like creating websites but not
really a problem for data transfer.

> StreamingMarkupBuilder can produce mixed content so it does not  
> attempt to pretty print the output because doing so could break a  
> document. I don't intend to add pretty printing as an option. I just  
> load the output into an XMl editor (I use Oxygen) and use the  
> formatting feature there if I want to see the structure.

I think that is a very sensible position and no problem.

Does XmlSlurper do validating parsing?  If it does, does it validate
against DTDs, XML Schemas, RelaxNG Schemas?

--
Russel.
====================================================
Dr Russel Winder                +44 20 7585 2200
41 Buckmaster Road              +44 7770 465 077
London SW11 1EN, UK             [hidden email]

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

tugwilson

On 21 Mar 2006, at 10:43, Russel Winder wrote:

> Does XmlSlurper do validating parsing?  If it does, does it validate
> against DTDs, XML Schemas, RelaxNG Schemas?


The default is that it uses a non validating, namespace aware parser.  
There are constructor options which allow you to switch validation on  
and switch namespace awareness off. You can also supply an XMLReader  
or a SAXParser.

So if you have a parser which validates against W3C or RNG schemas  
then you can do validation with XMLSlurper.


John Wilson
The Wilson Partnership
http://www.wilson.co.uk


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

Russel Winder
In reply to this post by tugwilson
On Tue, 2006-03-21 at 09:50 +0000, John Wilson wrote:

> Here's a full scale example of the use

Thanks for that, I now have the <?xml line going out.

mkp.pi produces <? tags, is there an equivalent for SGML tags, i.e.
<!...> as needed for DOCTYPE tags?

PS.  I think I prefer the outputting model in StreamingMarkupBuilder to
that of MarkupBuilder but then I have only been doing XML in Groovy for
1 hour :-)

--
Russel.
====================================================
Dr Russel Winder                +44 20 7585 2200
41 Buckmaster Road              +44 7770 465 077
London SW11 1EN, UK             [hidden email]

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

tugwilson

On 21 Mar 2006, at 11:08, Russel Winder wrote:

> On Tue, 2006-03-21 at 09:50 +0000, John Wilson wrote:
>
>> Here's a full scale example of the use
>
> Thanks for that, I now have the <?xml line going out.
>
> mkp.pi produces <? tags, is there an equivalent for SGML tags, i.e.
> <!...> as needed for DOCTYPE tags?

mkp.yieldUnesacaped "<!DOCTYPE.............>" should do it.

John Wilson
The Wilson Partnership
http://www.wilson.co.uk


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

Russel Winder
On Tue, 2006-03-21 at 11:15 +0000, John Wilson wrote:

> mkp.yieldUnesacaped "<!DOCTYPE.............>" should do it.

Ah, OK.  I think I am getting there with this.  mkp is treated as
special by the builder being a set of real methods not turned into
nodes.  In any event I have my sample XML file writers working just as
the Java dom4j code does and Groovy wins just so easily :-)

I see that XmlParser and XmlSlurper are in groovy.util rather than being
in groovy.xml at first sight strange but I guess there is a reason.

I can see that it makes sense to have DOMBuilder,
StreamingMarkupBuilder, etc. since it makes creating trees of nodes so
much easier than even the JDOM and dom4j methods.  It also makes sense
that XmlSlurper creates things ready for GPath processing.  But
XmlParser seems to create a document tree that is not W3C DOM nor JDOM
nor dom4j, it is yet another tree structure.

Is this a fair generalization?

--
Russel.
====================================================
Dr Russel Winder                +44 20 7585 2200
41 Buckmaster Road              +44 7770 465 077
London SW11 1EN, UK             [hidden email]

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

Russel Winder
In reply to this post by tugwilson
On Tue, 2006-03-21 at 10:52 +0000, John Wilson wrote:

> The default is that it uses a non validating, namespace aware parser.  
> There are constructor options which allow you to switch validation on  
> and switch namespace awareness off. You can also supply an XMLReader  
> or a SAXParser.
>
> So if you have a parser which validates against W3C or RNG schemas  
> then you can do validation with XMLSlurper.

I tried the script:

        import groovy.util.XmlSlurper
       
        def document = ( new XmlSlurper ( true , false ) ).parse ( new
        FileReader ( 'contacts.xml' ) )

with the file contacts.xml containing the output from my
StreamingMarkupBuilder and there seems to be a problem.

      mkp.pi ( xml : [ version : '1.0' , encoding : "UTF-8" ] )

generates the line:

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

which causes the validator picked up on my system to have problems:

Caught: org.xml.sax.SAXParseException: The version is required in the
XML declaration.
        at readContacts.run(readContacts.groovy:5)
        at readContacts.main(readContacts.groovy)

If I reorder the statement to:

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

then everything is fine.  I am not sure if this is an error in the
validator (seems likely) or elsewhere.
--
Russel.
====================================================
Dr Russel Winder                +44 20 7585 2200
41 Buckmaster Road              +44 7770 465 077
London SW11 1EN, UK             [hidden email]

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

tugwilson
In reply to this post by Russel Winder

On 21 Mar 2006, at 11:35, Russel Winder wrote:

> On Tue, 2006-03-21 at 11:15 +0000, John Wilson wrote:
>
>> mkp.yieldUnesacaped "<!DOCTYPE.............>" should do it.
>
> Ah, OK.  I think I am getting there with this.  mkp is treated as
> special by the builder being a set of real methods not turned into
> nodes.  In any event I have my sample XML file writers working just as
> the Java dom4j code does and Groovy wins just so easily :-)

StreamingMarkupBuilder supports namespaces (see my example a few  
emails ago which produced an Atom document).

So myTag.myElement emits a tag in the namespace denoted by myTag.  
There are two build in namsepaces:

xml which represents  http://www.w3.org/XML/1998/namespace
mkp which represents http://www.codehaus.org/Groovy/markup/keywords

The xml namespace is part of the XML standard.
The mkp namespace is used to denote tags which are understood by the  
Builder and they are not emitted.

So you can write

mkp.declareNamespace(xyz: "http://www.codehaus.org/Groovy/markup/ 
keywords")
xyz.pi(target: "Body")

(so if you don't like mkp as a prefix you can change it).


> I see that XmlParser and XmlSlurper are in groovy.util rather than  
> being
> in groovy.xml at first sight strange but I guess there is a reason.
>
> I can see that it makes sense to have DOMBuilder,
> StreamingMarkupBuilder, etc. since it makes creating trees of nodes so
> much easier than even the JDOM and dom4j methods.  It also makes sense
> that XmlSlurper creates things ready for GPath processing.  But
> XmlParser seems to create a document tree that is not W3C DOM nor JDOM
> nor dom4j, it is yet another tree structure.

XMLParser generates a custom DOM (as does XMLSlurper but it's a  
different structure).
These Doms are intended to to be small footprint and high  
performance. They are very similar to Python's ElementTree.
One major difference between XMLParser and XMLSlurper is what they  
produce as the result of a GPath expression.
XMLParser returns a DOM tree which is constructed from the original  
tree.
XMLSlurper returns a complex iterator which works over the original  
DOM tree.

XMLSlurper GPath expressions do fancy things if they are used in  
StreamingXXXBuilder closures:

mkp.yield mySlurperResult.root.elem.elem1

will drop the result of the GPath expression into the document being  
generated. It works intelligently  so if you are using  
StreamingSAXBuilder you will get the right SAX events. It also does  
resonably clever things if the GPath expression results in an XML  
fragment which uses namespaces which have already been declared in  
the enclosing document.

John Wilson
The Wilson Partnership
http://www.wilson.co.uk


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

tugwilson
In reply to this post by Russel Winder

On 21 Mar 2006, at 11:48, Russel Winder wrote:

> I tried the script:
>
>         import groovy.util.XmlSlurper
>
>         def document = ( new XmlSlurper ( true , false ) ).parse ( new
>         FileReader ( 'contacts.xml' ) )
>
> with the file contacts.xml containing the output from my
> StreamingMarkupBuilder and there seems to be a problem.
>
>       mkp.pi ( xml : [ version : '1.0' , encoding : "UTF-8" ] )
>
> generates the line:
>
>         <?xml encoding="UTF-8" version="1.0"?>
>
> which causes the validator picked up on my system to have problems:
>
> Caught: org.xml.sax.SAXParseException: The version is required in the
> XML declaration.
>         at readContacts.run(readContacts.groovy:5)
>         at readContacts.main(readContacts.groovy)
>
> If I reorder the statement to:
>
>         <?xml version="1.0" encoding="UTF-8"?>
>
> then everything is fine.  I am not sure if this is an error in the
> validator (seems likely) or elsewhere.

The parser is perfectly correct.

The XML declaration needs the version to preceded the encoding  
declaration.

The XML declaration is not, strictly an PI which is why my original  
advice was to use mkp.yieldUnescaped.

If you want yo use mkp.pi then use the mkp.pi(xml: "version='1.0'  
encoding='UTF-8'") version.

I intend at some tom to add mkp.dcl which will generate a proper  
declaration. This issue is the encoding. You don't really want to put  
the encoding in the Builder closure as the result of the same builder  
closure could be rendered in many different encodings. So really the  
XML declaration needs to be dynamically generated at the point when  
the document is being rendered.


A point on encoding. At the moment StreamingMarkupBuilder attempts to  
detect the encoding used by the Writer it is writing itself to. If it  
can find this out it ensures that it uses the correct numeric  
character entities for Unicode characters which cannot be represented  
in the encoding. You can force a particular encoding be setting the  
"encoding" property of the
StreamingMarkupBuilder before binding the closure to it.


John Wilson
The Wilson Partnership
http://www.wilson.co.uk


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: groovy.xml.MarkupBuilder

Russel Winder
On Tue, 2006-03-21 at 12:17 +0000, John Wilson wrote:

> The parser is perfectly correct.
>
> The XML declaration needs the version to preceded the encoding  
> declaration.

I did wonder.  I guess this is the one place where attribute order is
important.

> If you want yo use mkp.pi then use the mkp.pi(xml: "version='1.0'  
> encoding='UTF-8'") version.

Hummm... once seen, perfectly obvious :-)

John, Thanks for all your replies over the last couple of hours, they
have been immensely useful.  I can now talk about XML processing in
Groovy  with at least some knowledge and not just total bullshit!

I think my trivial examples of writing and reading XML show Groovy
definitely beats Java with Dom4j.  I may have a go doing things in C++
just to show how cool Groovy really is.

Of course I should do something on GPath...

--
Russel.
====================================================
Dr Russel Winder                +44 20 7585 2200
41 Buckmaster Road              +44 7770 465 077
London SW11 1EN, UK             [hidden email]

signature.asc (196 bytes) Download Attachment
Loading...