• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

xsl:apply-templates problem

Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a xslt
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<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

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!