XML & XSLT namespaces

C

Colin Fox

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
 
M

Martin Honnen

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.
 

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,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top