xsl-list
[Top] [All Lists]

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

2008-07-22 09:33:46
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[(_at_)style = 'defaultSpeaker'])]"
use="generate-id(preceding-sibling::ttaf:p[ttaf:span[(_at_)style = 'defaultSpeaker']][1])"/>

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

  <xsl:template match="ttaf:p">
    <dt>
      <xsl:value-of select="ttaf:span[(_at_)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/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--