GeeCON Prague 2014*
The moose likes XML and Related Technologies and the fly likes Problem in XSL apply-templates Tag ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problem in XSL apply-templates Tag ??" Watch "Problem in XSL apply-templates Tag ??" New topic
Author

Problem in XSL apply-templates Tag ??

Rahul Si
Greenhorn

Joined: Mar 19, 2005
Posts: 1
Hi friends,

I am facing problem while I am trying to apply HELLO.XSL to HELLO.XML. It is giving the following unwanted results as shown below.

In short <xsl:apply-templates select="xs:custom" mode="TTE"/> tag is not referring to <xsl:template match="xs:custom" mode="TTE"> tag.

I guess there is some fundamental problem. If anyone can help me then it wud be great.

Regards,
Rahul

HELLO.XML:

<xs:ql xmlns:xs="http://www.hello.com/XMLSchema" xmlns:bim="http://www.hello.com/XMLSchema/BIM" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xs:custom>
<xs:LRU>Amit</xs:LRU>
<xs:LRU>Sumit</xs:LRU>
</xs:custom>
</xs:ql>


HELLO.XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.hello.com/XMLSchema" xmlns:bim="http://www.hello.com/XMLSchema/BIM" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xslutput method="xml" indent="yes" omit-xml-declaration="yes" />

<xsl:template match="/" >
<xsl:apply-templates select="xs:ql" mode="TTE"/>
</xsl:template>

<xsl:template match="xs:ql" mode="TTE">
<xs:ql>
<xsl:for-each select="child::*">
<xsl:choose>
<xsl:when test="name(.)='xs:custom'">
<xsl:apply-templates select="xs:custom" mode="TTE"/>
</xsl:when>
<xsltherwise>
<xsl:copy-of select="." />
</xsltherwise>
</xsl:choose>
</xsl:for-each>
</xs:ql>
</xsl:template>

<xsl:template match="xs:custom" mode="TTE">
<xs:custom>hello</xs:custom>
</xsl:template>

</xsl:stylesheet>



OUTPUT COMING:

<xs:ql xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bim="http://www.hello.com/XMLSchema/BIM" xmlns:xs="http://www.hello.com/XMLSchema"/>



DESIRED OUTPUT:

<xs:ql xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bim="http://www.hello.com/XMLSchema/BIM" xmlns:xs="http://www.hello.com/XMLSchema">
<xs:custom>hello</xs:custom>
</ql>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem in XSL apply-templates Tag ??