[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Namespace getting carried over to output XML

Subject: Namespace getting carried over to output XML
From: "Prashanth T S" <tsprashanth@xxxxxxxxx>
Date: Tue, 11 Jul 2006 10:53:03 -0400
xmlns output xml
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.

I have given the following line when I start my XSL

<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">


I have a tag in my source xhtml which is like:


<a href="/contents/myfolder/abc.htm">Click here</a>

My xsl is supposed to change <a href> to my custom tag. Basically my
output should be

<abc:link linkend="/contents/myfolder/abc.htm">Click here</abc:link>

The "a" is replaced by "abc:link" and "href" is replaced by "linkend"

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>


Any help would be highly appreciated.


Thanks
Prashanth

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.