how to inherit namespace into xinclude included elements

L

Larry

Given the "includer" xml file:

<?xml version="1.0"?>
<test-includer
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:testns="http://www.w3.org/TR/REC-xml-names"
xmlns:xi="http://www.w3.org/2001/XInclude"<xi:include
href="test-included.xml"
parse="xml"
/>
</test-includer>

and the "included" xml file:

<testns:test-element>1</testns:test-element>

and the xsl file:

<?xml version="1.0"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:testns="http://www.w3.org/TR/REC-xml-names"<xsl:eek:utput method="text"/>

<xsl:template match="/">
<xsl:value-of select="testns:test-element"/>
</xsl:template>

how do I avoid the duplication of the testns declaration
in the "includer" xml and the xsl file, and how do I
cause the testns namespace to be inherited by the
included elements (e.g. <testns:test-element> ). IOW,
I want to avoid the error message from xsltproc:

xsltproc --xinclude -o test-includer.html test-includer.xsl
test-includer.xml
test-included.xml:1: namespace error : Namespace prefix testns on
test-element is not defined
<testns:test-element>1</testns:test-element>
^

TIA.
 
R

Richard Tobin

Larry said:
and the "included" xml file:

<testns:test-element>1</testns:test-element>

That won't work. XInclude isn't a text replacement mechanism; it
works on parsed XML documents (infosets). If you want textual
inclusion you could use an external entity:

<?xml version="1.0"?>
<!DOCTYPE test-includer [
<!ENTITY t SYSTEM "test-included.xml">
]>
<test-includer
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:testns="http://www.w3.org/TR/REC-xml-names"
xmlns:xi="http://www.w3.org/2001/XInclude"&t;
</test-includer>

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top