Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in XSL apply-templates Tag ??

 
Rahul Si
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic