Recursive XInclusion with XPointer fragment selection
Questions about XML that are not covered by the other forums should go here.
Recursive XInclusion with XPointer fragment selection
Hello!
I have three XML files: "a.xml", "b.xml" and "c.xml". Full XML files are at the end of this message.
1) "c.xml" is simple XML file.
2) "b.xml" does simple XInclusion of "c.xml" as '<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="c.xml" parse="xml" />'.
3) "a.xml" does XInclusion of "b.xml" using XPointer as '<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="b.xml" xpointer="element(/1/1)" parse="xml" />'.
I want to have "a.xml", which contains part of "b.xml" and whole "c.xml". I am not able to do this. I receive "a.xml" containing part of "b.xml" with just reference to "c.xml" (there is not done XInclusion of "c.xml") – unparsed "b.xml". I can receive "a.xml" with (whole) "b.xml" and "c.xml", but only if I do not use XPointer. What am I doing wrong? I am using JAXP in Java 1.5.0_xx. Can You help me?
Also I did not find how to see result of XInclusion (of e.g. above "a.xml") in oXygen 7.0. Some kind of "Preview". Has oXygen such feature?
Thank You for answers. Stepan
"c.xml":
<?xml version="1.0" encoding="UTF-8"?>
<c xmlns:xi="http://www.w3.org/2001/XInclude">
<element>
<text>ccc</text>
</element>
</c>
"b.xml":
<?xml version="1.0" encoding="UTF-8"?>
<b xmlns:xi="http://www.w3.org/2001/XInclude">
<element>
<text>bbb</text>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="c.xml" parse="xml"/>
</element>
</b>
"a.xml":
<?xml version="1.0" encoding="UTF-8"?>
<a xmlns:xi="http://www.w3.org/2001/XInclude">
<element>
<text>aaa</text>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="b.xml" xpointer="element(/1/1)" parse="xml" />
</element>
</a>
part of my simple Java 1.5.0_xx code:
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
documentBuilderFactory.setXIncludeAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(new File("a.xml"));
I have three XML files: "a.xml", "b.xml" and "c.xml". Full XML files are at the end of this message.
1) "c.xml" is simple XML file.
2) "b.xml" does simple XInclusion of "c.xml" as '<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="c.xml" parse="xml" />'.
3) "a.xml" does XInclusion of "b.xml" using XPointer as '<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="b.xml" xpointer="element(/1/1)" parse="xml" />'.
I want to have "a.xml", which contains part of "b.xml" and whole "c.xml". I am not able to do this. I receive "a.xml" containing part of "b.xml" with just reference to "c.xml" (there is not done XInclusion of "c.xml") – unparsed "b.xml". I can receive "a.xml" with (whole) "b.xml" and "c.xml", but only if I do not use XPointer. What am I doing wrong? I am using JAXP in Java 1.5.0_xx. Can You help me?
Also I did not find how to see result of XInclusion (of e.g. above "a.xml") in oXygen 7.0. Some kind of "Preview". Has oXygen such feature?
Thank You for answers. Stepan
"c.xml":
<?xml version="1.0" encoding="UTF-8"?>
<c xmlns:xi="http://www.w3.org/2001/XInclude">
<element>
<text>ccc</text>
</element>
</c>
"b.xml":
<?xml version="1.0" encoding="UTF-8"?>
<b xmlns:xi="http://www.w3.org/2001/XInclude">
<element>
<text>bbb</text>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="c.xml" parse="xml"/>
</element>
</b>
"a.xml":
<?xml version="1.0" encoding="UTF-8"?>
<a xmlns:xi="http://www.w3.org/2001/XInclude">
<element>
<text>aaa</text>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="b.xml" xpointer="element(/1/1)" parse="xml" />
</element>
</a>
part of my simple Java 1.5.0_xx code:
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
documentBuilderFactory.setXIncludeAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(new File("a.xml"));
Well, I can partially answer my previous questions ;-)
How to preview final XML file after XInclusion? I wrote simple XSLT, which copy all elements and attributes from source to output. Hmm, but maybe it can be done by easier way.
Recursive XInclusion using XPointer is OK in oXygen using Xalan or Saxon8B. So it looks like I have some kind of error in my Java code, but I do not know where, because it is too simple to have any error there :-( I am going to install JAXP plugin to oXygen to test JAXP XInclusion within oXygen.
Stepan
How to preview final XML file after XInclusion? I wrote simple XSLT, which copy all elements and attributes from source to output. Hmm, but maybe it can be done by easier way.
Recursive XInclusion using XPointer is OK in oXygen using Xalan or Saxon8B. So it looks like I have some kind of error in my Java code, but I do not know where, because it is too simple to have any error there :-( I am going to install JAXP plugin to oXygen to test JAXP XInclusion within oXygen.
Stepan
Hi Stepan,
Yes, in order to see the document with the XInclude resolved you can pass it through a simple stylesheet like:
The XInclude does not invlolve the XSLT processor, the XInclude is resolved at XML parser level, in oXygen that is Xerces. If you create the parser through JAXP in Java 1.5 then you probably get a modified Xerces version bundled with Java as com.sun.org.apache.xerces... etc. and I do not know what XInclude support that offers. The JAXP option in oXygen is under XSLT options and refers to configuring oXygen to work with a Java XSLT processor that is not already integrated in oXygen by specifying the factory class for that processor so that will not help you with XInclude testing. Maybe you should better configure JAXP to create a Xerces parser instead of the default parser, that should give you something similar with what oXygen does.
Best Regards,
George
Yes, in order to see the document with the XInclude resolved you can pass it through a simple stylesheet like:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/*">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Best Regards,
George
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service