Subject: [xsl] Namespaces and template matching From: "David P. Nesbitt" <dnesbitt@xxxxxxxxxxxxx> Date: Thu, 7 Nov 2002 20:42:36 -0800 |
Good People, I am struggling with doing a template match when namespaces are involved. I have the following stylesheet which renames any 'x' element to 'y': <?xml version='1.0' encoding='UTF-8'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="x"> <xsl:element name="y"> <xsl:apply-templates select="@*"/> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> </xsl:stylesheet> A document without namespaces translates as expected: <?xml version="1.0" encoding="UTF-8"?> <a> <x a="1" b="2" c="3" d="4" /> </a> becomes: <?xml version="1.0" encoding="UTF-8"?> <a> <y a="1" b="2" c="3" d="4"/> </a> But when a namespace is placed on the root node, it ceases to work: <?xml version="1.0" encoding="UTF-8"?> <a xmlns="b"> <x a="1" b="2" c="3" d="4" /> </a> becomes: <?xml version="1.0" encoding="UTF-8"?> <a xmlns="b"> <x a="1" b="2" c="3" d="4"/> </a> Why doesn't the second document translate properly? What can I do to make it happen? Thanks in advance for your assistance. Best Regards, Dave P.S. I am using Xalan if that makes any difference. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] node-set = node-set invol, David N Bertoni/Camb | Thread | Re: [xsl] Namespaces and template m, David N Bertoni/Camb |
Re: [xsl] MSXML / NBSP problem and , Mike Brown | Date | Re: [xsl] Namespaces and template m, David N Bertoni/Camb |
Month |