XML & XSLT namespaces

Discussion in 'XML' started by Colin Fox, Jan 11, 2004.

  1. Colin Fox

    Colin Fox Guest

    I've got a bit of a problem, and I'm stumped.

    I'm working on a system to create web pages based on XML files. I'd like
    to be able to use a variety of techniques to make the coding faster & more
    maintainable.

    To that end, I have some XML and XSLT files that I use as 'subroutines' to
    build the pages faster. All pretty standard stuff.

    My problem is this: I have two xml/xslt file pairs that I'm using, and
    they both use their own namespace. One works, and one doesn't and I can't
    tell why the one doesn't work.
    -----------------------
    index.xml:
    <?xml version="1.0"?>
    <!DOCTYPE page[
    <!ENTITY navtree SYSTEM "nav.xml">
    ]>
    <page xmlns:xform="http://cfconsulting.ca/xmlform/1.0">
    <title>Page Title</title>
    <navtree>&navtree;</navtree>
    <body>
    <sect>
    <title>Form Test</title>
    <p>Form follows this:</p>
    <xform:form>
    <xform:textwidget name='test_text' value='a test value'/>
    <xform:buttonwidget name='test_but' value='Submit'/>
    </xform:form>
    </sect>
    </body>
    </page>
    -----------------
    xform.xsl:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xform="http://cfconsulting.ca/xform/1.0">

    <xsl:template match="xform:form">
    <form>
    <xsl:apply-templates />
    </form>
    </xsl:template>

    <xsl:template match="xform:textwidget">
    <input type="text" name="{@name}" value="{@value}" />
    </xsl:template>

    <xsl:template match="xform:buttonwidget">
    <input type="button" name="{@name}" value="{@value}" />
    </xsl:template>

    </xsl:stylesheet>

    The nav.xml file defines & uses a namespace (nav:), which is referenced in
    the nav.xsl file. That works fine. I get my navigation tree.

    The xform (yes, I know about XFORMS, this is just a convenient name for
    now) namespace, however, is for some reason ignored. When I use xsltproc
    with -v, I can see it parse the xform namespace, but when it gets to
    parsing this file, it says that there is no handler for 'textwidget' and
    'buttonwidget'.

    If I take the xform namespace right out, of both the index.xml and the
    xform.xsl file, the form works. If the namespace is in use, the form isn't
    there.

    I'm sure I'm doing something stupid in regards to using or defining the
    xform namespace, but I can't figure out what it is, and the xsltproc
    debugging dump isn't any help (at least in this case).

    Suggestions?

    cf
    Colin Fox, Jan 11, 2004
    #1
    1. Advertising

  2. Colin Fox wrote:


    > I'm working on a system to create web pages based on XML files. I'd like
    > to be able to use a variety of techniques to make the coding faster & more
    > maintainable.
    >
    > To that end, I have some XML and XSLT files that I use as 'subroutines' to
    > build the pages faster. All pretty standard stuff.
    >
    > My problem is this: I have two xml/xslt file pairs that I'm using, and
    > they both use their own namespace. One works, and one doesn't and I can't
    > tell why the one doesn't work.
    > -----------------------
    > index.xml:
    > <?xml version="1.0"?>
    > <!DOCTYPE page[
    > <!ENTITY navtree SYSTEM "nav.xml">
    > ]>
    > <page xmlns:xform="http://cfconsulting.ca/xmlform/1.0">

    ^^^^^^^

    > xform.xsl:
    > <?xml version="1.0" encoding="iso-8859-1"?>
    > <xsl:stylesheet version="1.0"
    > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    > xmlns:xform="http://cfconsulting.ca/xform/1.0">

    ^^^^^^
    so the namespace here is different.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jan 11, 2004
    #2
    1. Advertising

  3. Colin Fox

    Colin Fox Guest

    On Sun, 11 Jan 2004 12:18:13 +0100, Martin Honnen wrote:

    >> xform.xsl:
    >> <?xml version="1.0" encoding="iso-8859-1"?>
    >> <xsl:stylesheet version="1.0"
    >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    >> xmlns:xform="http://cfconsulting.ca/xform/1.0">

    > ^^^^^^
    > so the namespace here is different.


    Sigh. I knew it would be something stupid. It's so easy to overlook the
    obvious. Thanks!

    cf
    Colin Fox, Jan 11, 2004
    #3
    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. Stylus Studio
    Replies:
    0
    Views:
    662
    Stylus Studio
    Aug 3, 2004
  2. Replies:
    4
    Views:
    675
  3. daz_oldham
    Replies:
    2
    Views:
    631
    daz_oldham
    May 23, 2006
  4. Thomas Wittek

    XSLT: Normalizing namespaces

    Thomas Wittek, Aug 30, 2007, in forum: XML
    Replies:
    5
    Views:
    1,174
    Martin Honnen
    Aug 31, 2007
  5. Andy Fish

    namespaces in XSLT

    Andy Fish, Feb 29, 2008, in forum: XML
    Replies:
    3
    Views:
    522
    Joseph Kesselman
    Feb 29, 2008
Loading...

Share This Page