XSLT to replace XInclude elements
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 2
- Joined: Wed Jan 13, 2010 5:12 pm
XSLT to replace XInclude elements
I’m using oXygen 11.1 (build 2010010613). I have an XSLT that I’m using to transform an XML document. One of the changes I need to make is to replace <xi:include> tags with another element as required by downstream process. I have turned off XInclude processing under “XML | XML Parser” and under XSLT for XSLTProc and MSXML.NET. However, the <xsl:template> that I’ve added doesn’t seem to be executed and the result file still contains the <xi:include> tags. What do I need to do to have my template “match” the <xi:include> tags?
The template I have is:
<xsl:template match=”xi:include”>
…
</xsl:template>
An example file would be:
<?xml version=”1.0” encoding=”UTF-8”?>
<!DOCTYPE book PUBLIC… …>
<book dtd-version=”2” xml:lang=”EN”
xmlns:xlink=”http://www.w3.org/1999/xlink”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>
<book-meta>...</book-meta>
<body>
<xi:include href=”file.xml”
xmlns:xi=”http://www.w3.org/2001/XInclude”>
<xi:fallback><!--Fallback for “file.xml"-->
</xi:fallback>
</xi:include>
…
…
</body>
</book>
Thanks.
DJ
The template I have is:
<xsl:template match=”xi:include”>
…
</xsl:template>
An example file would be:
<?xml version=”1.0” encoding=”UTF-8”?>
<!DOCTYPE book PUBLIC… …>
<book dtd-version=”2” xml:lang=”EN”
xmlns:xlink=”http://www.w3.org/1999/xlink”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>
<book-meta>...</book-meta>
<body>
<xi:include href=”file.xml”
xmlns:xi=”http://www.w3.org/2001/XInclude”>
<xi:fallback><!--Fallback for “file.xml"-->
</xi:fallback>
</xi:include>
…
…
</body>
</book>
Thanks.
DJ
-
- Posts: 2883
- Joined: Tue May 17, 2005 4:01 pm
Re: XSLT to replace XInclude elements
Hello,
First you should have the namespace declaration for XInclude, so the template should look like this:
And then, assuming you have a template that matches the root(/) or the parent element of the xi:include, make sure you call xsl:apply-templates, something like this:
Regards,
Adrian
First you should have the namespace declaration for XInclude, so the template should look like this:
Code: Select all
<xsl:template match="xi:include" xmlns:xi="http://www.w3.org/2001/XInclude">
...
</xsl:template>
Code: Select all
<xsl:template match="/">
...
<xsl:apply-templates/>
...
</xsl:template>
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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