Thank you very much, this worked for me.

Dale

Robert Houben wrote:
Hi Dale,

You need to specify the namespace explicitly in your stylesheet.  Try this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:x="http://foo"; >

<xsl:template match="x:b">
   <d>
   </d>
</xsl:template>

<xsl:template match="@* | node()">
 <xsl:copy>
   <xsl:apply-templates select="@*"/>
   <xsl:apply-templates/>
 </xsl:copy>
</xsl:template>

</xsl:stylesheet>

-----Original Message-----
From: Dale Beermann [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 18, 2007 7:16 AM
To: xalan-j-users@xml.apache.org
Subject: Issue resolving templates when namespace is applied.

I apologize if this is received twice.

I'm having a problem getting my templates to apply when my root node has
a namespace.  If my XML file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<a xmlns="http://foo";>
 <b>
   <c />
 </b>
</a>

and my XSL file looks like this:

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

<xsl:template match="b">
   <d>
   </d>
</xsl:template>

<xsl:template match="@* | node()">
 <xsl:copy>
   <xsl:apply-templates select="@*"/>
   <xsl:apply-templates/>
 </xsl:copy>
</xsl:template>

</xsl:stylesheet>

I am getting the same result as the original file (there is no <d> node
written to the result).  I'm running Xalan on the command line, using:

java -classpath "xml-apis.jar;xercesImpl.jar;xalan.jar;serializer.jar"
org.apache.xalan.xslt.Process -in input.xml -xsl transformation.xsl -out
result.xml

If I remove the xmlns attribute from my input file, things work fine and
I end up with the expected result.  I don't know if this is a problem
with how I'm specifying something, a problem with Xalan, or maybe even a
problem with the underlying Xerces library.  I know that we disable
namespace processing using Xerces for a few other things, but I don't
know if it's possible to do that with Xalan.  Any help would be greatly
appreciated.

Thanks,

Dale Beermann



--
Dale Beermann
Software Architect, Founder
Sharendipity
[EMAIL PROTECTED]
608-332-7221

Reply via email to