473,378 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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="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
Jul 20 '05 #1
2 2007


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/

Jul 20 '05 #2
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
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Greg Wogan-Browne | last post by:
Hi all, I am having some trouble figuring out what is going on here - is this a bug, or correct behaviour? Basically, when I create an XML document with a namespace using xml.dom.minidom.parse()...
4
by: cyclops | last post by:
I'm trying to do XML + XSLT -> Another XML. The source XML contains multiple namespaces and XSLT will handle all possible tags under each name space. ----source---- <document xmlns="..."...
12
by: Sammy | last post by:
Hi, my mind is going crazy. I have tried everything I can think of to no avail. I have tried Disable Output Escaping. I tried to think of a way of enclosing the attribute data in a CDATA...
1
by: Wil | last post by:
I'm very new to developing in .NET and even newer to XML. The past few days have been pretty frustrating for me because I'm trying to perform a transform on data in a dataset and it's not working....
19
by: David Thielen | last post by:
Hi; If there are no namespaces this works fine for me. But if the xml has namespaces, then I get either no node back or an exception. Here is the sample xml: <root xmlns="http://www.test.org"...
4
by: David S. Alexander | last post by:
How can I do simple subtraction in an XSLT. I want to read a few attribute values from an XML document, calculate their difference, and transform that value to an attribute in the XML output...
1
by: Rajesh | last post by:
I am trying to pass the namespace, which is in my Original Message, to a Java method for further processing. In the original message the xmlns:xenc namespace is present. I make a call to Java...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.