469,625 Members | 1,722 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

how to inherit namespace into xinclude included elements

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:output 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.

Sep 17 '05 #1
1 1356
In article <11**********************@g43g2000cwa.googlegroups .com>,
Larry <cp********@cox-internet.com> wrote:
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
Sep 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by John L. Clark | last post: by
3 posts views Thread by rene | last post: by
9 posts views Thread by Tjerk Wolterink | last post: by
4 posts views Thread by FabrizioSW | last post: by
11 posts views Thread by john fra | last post: by
4 posts views Thread by Tim Arnold | last post: by
1 post views Thread by marfi95 | last post: by
2 posts views Thread by McSwell | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.