how to inherit namespace into xinclude included elements

Discussion in 'XML' started by Larry, Sep 17, 2005.

  1. Larry

    Larry Guest

    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.
     
    Larry, Sep 17, 2005
    #1
    1. Advertising

  2. In article <>,
    Larry <> 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
     
    Richard Tobin, Sep 20, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ed Dennison
    Replies:
    0
    Views:
    467
    Ed Dennison
    Sep 12, 2003
  2. Erdem Guven

    XInclude

    Erdem Guven, Aug 12, 2004, in forum: XML
    Replies:
    1
    Views:
    616
    Matthias Jung
    Aug 12, 2004
  3. SL
    Replies:
    0
    Views:
    537
  4. Jason Heyes
    Replies:
    1
    Views:
    456
    Woebegone
    Nov 19, 2004
  5. chuck
    Replies:
    6
    Views:
    981
    chuck
    Nov 25, 2011
Loading...

Share This Page