Re: [xsl] selecting elements by attributes when working with namespaces

Subject: Re: [xsl] selecting elements by attributes when working with namespaces
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 22 Jul 2008 18:33:13 +0200
Joelle Tegwen wrote:
Ahh, sorry, I should have said that I'm using v 1.0. I can't use the for-each-group.

Here is an XSLT 1.0 stylesheet that should create the dl/dt/dd structure you are looking for:


<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  version="1.0"
  xmlns:ttaf="http://www.w3.org/2006/04/ttaf1";
  exclude-result-prefixes="ttaf">

<xsl:output method="html" indent="yes"/>

<xsl:key name="start-p"
match="ttaf:p[not(ttaf:span[@style = 'defaultSpeaker'])]"
use="generate-id(preceding-sibling::ttaf:p[ttaf:span[@style = 'defaultSpeaker']][1])"/>


<xsl:template match="ttaf:body/ttaf:div">
<div>
<dl>
<xsl:apply-templates select="ttaf:p[ttaf:span[@style = 'defaultSpeaker']]"/>
</dl>
</div>
</xsl:template>


  <xsl:template match="ttaf:p">
    <dt>
      <xsl:value-of select="ttaf:span[@style = 'defaultSpeaker']"/>
    </dt>
    <dd>
      <xsl:for-each select=". | key('start-p', generate-id(.))">
        <xsl:value-of select="text()[last()]"/>
        <xsl:if test="position() != last()">
          <xsl:text> </xsl:text>
        </xsl:if>
      </xsl:for-each>
    </dd>
  </xsl:template>

</xsl:stylesheet>

--

	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread