It's not a secret anymore!
The moose likes XML and Related Technologies and the fly likes xsl:apply-templates problem 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 "xsl:apply-templates problem" Watch "xsl:apply-templates problem" New topic

xsl:apply-templates problem

Bipul Kumar Singh

Joined: Jul 08, 2004
Posts: 6

I have a xslt
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
<xsl utput omit-xml-declaration="yes" method="xml" indent="yes" encoding="iso8859-1"/>
<xsl:key name="speaker" match="SPEECH" use="SPEAKER"/>
<xsl:template match="/">
<!-- Do this to suppress the display of all the text in the document-->
<xsl:apply-templates select="SCENE/SPEECH[count(. | key('speaker', SPEAKER)[1]) = 1]/SPEAKER"/>
<!--<xsl:apply-templates select="//SPEAKER"/>-->
<xsl:template match="SPEAKER">
<xsl:variable name="temp" select="."/>
<!-- Collect all of the lines spoken by the current speaker -->
<xsl:value-of select="$temp"/>
<xsl:for-each select="//SPEECH[SPEAKER=$temp]/LINE">
<xsl:value-of select="."/>

which i want to apply to this xml
<?xml version="1.0" encoding="UTF-8"?>
<LINE>Who's there?</LINE>
<LINE>Nay, answer me: stand, and unfold yourself.</LINE>
<LINE>Long live the king!</LINE>

Can anyone pl. tell me how is this XSLT working? I mean how the xsl:apply-templates is working here in conjunction with key() and count() !!!

I'm stumped and not able to figure it out

Thanks in advance

I agree. Here's the link:
subject: xsl:apply-templates problem
It's not a secret anymore!