With XmlSlurper it is possible to supply your own XMLReader or
SAXParser. I am not sure how XmlSlurper initialises the underlying
SAXParser, but the following might get you going
def spf = javax.xml.parsers.SAXParserFactory.newInstance()
spf.namespaceAware = true
spf.setXIncludeAware ( true ) // for some reason spf.xIncludeAware
= true does not compile
def parser = new XmlSlurper(spf.newSAXParser())
I hope that helps.
Now slightly digressing ...
Looking at the above has made me think that it would actually be good if
an extra contructor can be added to XmlSlurper being
XmlSlurper( Map saxOptions = [:] )
That can lead to something more expressive than the cirrent way of
constructing options on XmlSlurper. It would also be more flexible
should SAXParserFactory obtain additional setters in future releases of
the JDK. As an example.
new XmlSlurper( namespaceAware : true, xIncludeAware : true )
On 13/10/2015 17:44, Balachandran Sivakumar wrote:
Hi,
Can someone please help me using XmlSlurper with an xml
document that uses xml includes ? I have an xml that is something
like this
<root namespaces.....>
<xi:include href="another.xml" parse="xml" xpointer="xpointer(//path)"/>
<somenode../>
<somenode2../>
</root>
And, another.xml has
<path>
<subpath attr="value"/>
</path>
With XmlSlurper, I am able to access root.somenode.whatever. But I
don't know how to access the included xml's nodes and attributes. Can
someone please help me with this ? Thanks
--
Thank you
Balachandran Sivakumar
--
Schalk W. Cronjé
Twitter / Ello / Toeter : @ysb33r