Subject: [xsl] Namespace getting carried over to output XML From: "Prashanth T S" <tsprashanth@xxxxxxxxx> Date: Tue, 11 Jul 2006 10:53:03 -0400 |
Hi, I tried to apply a xsl on a xhtml document and once it passes through the xsl, I am getting the namespace carried over to my output xhtml document in places unnecessary. Below is an example.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform " xmlns:xhtml="http://www.w3.org/1999/xhtml " xmlns=" http://www.w3.org/1999/xhtml" xmlns:abc="abctest" exclude-result-prefixes="abc">
My xsl is supposed to change <a href> to my custom tag. Basically my output should be
The problem is my output is coming this way <abc:link xmlns:xhtml=" http://www.w3.org/1999/xhtml " xmlns:abc="abctest" linkend="/contents/myfolder/abc.htm">Click here</abc:link>
The namespace is getting carried over to the output in the place where I am replacing the text. For reference, below is my full XSL
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform" xmlns:xhtml=" http://www.w3.org/1999/xhtml" xmlns=" http://www.w3.org/1999/xhtml" xmlns:abc="abctest" exclude-result-prefixes="abc"> <!--Copying through all the contents of the <html> and <head> tags--> <xsl:output method="xml" version="1.0" indent="yes" doctype-system=" http://www.w3.org/TR/xhtml1/DTD/xhtml1-translational.dtd" doctype-public="-//W3C/DTD XHTML 1.0 Transitional//EN"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template>
<!-- Normally, the transformed XML elements will match this template, which just copies them into the output stream--> <!-- THE REPLACEMENT PORTION--> <xsl:template name="anchor"> <xsl:choose> <xsl:when test="@href"> <xsl:choose> <xsl:when test="contains(@href,':') "> <xsl:element name="pwc:ulink"> <xsl:attribute name="url"> <xsl:value-of select="@href"/> </xsl:attribute> <xsl:value-of select="."/> </xsl:element> </xsl:when> <xsl:otherwise> <xsl:element name="link"> <xsl:attribute name="linkend"> <xsl:value-of select="@href"/> </xsl:attribute> <xsl:value-of select="."/> </xsl:element> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </xsl:template>
<!--SEARCH FOR LINK AND REPLACE WITH ABC:LINK --> <xsl:template match="@* | node() | processing-instruction()"> <xsl:choose> <xsl:when test="name()='a'"> <xsl:call-template name="anchor"/> </xsl:when> <xsl:otherwise> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
Thanks Prashanth
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
AW: [xsl] Basic Question about Addi, Huditsch, Roman \(LN | Thread | Re: [xsl] Namespace getting carried, J.Pietschmann |
Re: [xsl] values in sequence after , andrew welch | Date | Re: [xsl] values in sequence after , Florent Georges |
Month |