XML & XSLT namespaces

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Colin Fox

    #1

    XML & XSLT namespaces

    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="ht tp://cfconsulting.ca/xmlform/1.0">
    <title>Page Title</title>
    <navtree>&navtr ee;</navtree>
    <body>
    <sect>
    <title>Form Test</title>
    <p>Form follows this:</p>
    <xform:form>
    <xform:textwidg et name='test_text ' value='a test value'/>
    <xform:buttonwi dget name='test_but' value='Submit'/>
    </xform:form>
    </sect>
    </body>
    </page>
    -----------------
    xform.xsl:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <xsl:styleshe et version="1.0"
    xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
    xmlns:xform="ht tp://cfconsulting.ca/xform/1.0">

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

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

    <xsl:template match="xform:bu ttonwidget">
    <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
  • Martin Honnen

    #2
    Re: XML &amp; XSLT namespaces



    Colin Fox wrote:

    [color=blue]
    > 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="ht tp://cfconsulting.ca/xmlform/1.0">[/color]
    ^^^^^^^
    [color=blue]
    > xform.xsl:
    > <?xml version="1.0" encoding="iso-8859-1"?>
    > <xsl:styleshe et version="1.0"
    > xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
    > xmlns:xform="ht tp://cfconsulting.ca/xform/1.0">[/color]
    ^^^^^^
    so the namespace here is different.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    • Colin Fox

      #3
      Re: XML &amp; XSLT namespaces

      On Sun, 11 Jan 2004 12:18:13 +0100, Martin Honnen wrote:
      [color=blue][color=green]
      >> xform.xsl:
      >> <?xml version="1.0" encoding="iso-8859-1"?>
      >> <xsl:styleshe et version="1.0"
      >> xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
      >> xmlns:xform="ht tp://cfconsulting.ca/xform/1.0">[/color]
      > ^^^^^^
      > so the namespace here is different.[/color]

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

      cf

      Comment

      Working...