[xsl] selecting elements by attributes when working with namespaces

Subject: [xsl] selecting elements by attributes when working with namespaces
From: Joelle Tegwen <tegwe002@xxxxxxx>
Date: Mon, 21 Jul 2008 16:12:31 -0500
I've been working with xsl for a while but I'm very new to namespaces. I'm sure this is rather simple in namespace-land but I can't seem to successfully google an answer for this.

The document I've got is a caption file for a flash movie. (Timed Text (TT) Authoring Format http://www.w3.org/TR/ttaf1-dfxp/)
We're using this to generate a transcript of the movie. (I would have thought someone else would have already done this too but I couldn't find that either.) However, I'd like to make the stylesheet relatively generic so that it can be used for many files.


Breifly, the xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<tt xmlns="http://www.w3.org/2006/04/ttaf1"; xmlns:tts="http://www.w3.org/2006/04/ttaf1#styling"; xml:lang="en">
<head> <!-- omitted for brevity-->
</head>
<body id="thebody" style="defaultCaption">
<div xml:lang="en">
<p begin="0:00:22.10">
<span style="defaultSpeaker">Robert Bruininks</span>
<br/>I founded ICI, primarily out of a belief that the</p>
<p begin="0:00:27.80">University and its people had a great deal to</p>
<p begin="0:00:31.20">offer to the development of services for people</p>
<p begin="0:00:33.80">with disabilities in our society.</p>
<p begin="0:00:36.80">
<span style="defaultSpeaker">Sue Swenson</span>
<br/>The Institute on Community Integration</p>
<p begin="0:00:38.40">has a unique strength in being seen</p>
<p begin="0:00:41.80">as having more understanding of how</p>
<p begin="0:00:45.60">community programs work for folks with</p>
<p begin="0:00:48.10">intellectual disabilities and developmental</p>
<p begin="0:00:50.40">disabilities. It&#39;s not real regimented. It&#39;s not</p>
<p begin="0:00:53.20">like there&#39;s, you know, some guy in charge who tells</p>
<p begin="0:00:56.50">everybody else what to do. There&#39;s, I don&#39;t know,</p>
<p begin="0:00:58.80">a hundred and fifty, couple hundred people, each of</p>
<p begin="0:01:01.10">whom are exploring some of the ideas that they&#39;re</p>
<p begin="0:01:04.00">really interested in.</p>
</div>
</body>
</tt>



I want:
<div class="transcript">
<dl>
<dt>Robert Bruininks</dt>
<dd> I founded ICI, primarily out of a belief that the University and its people had a great deal to offer to the development of services
for people with disabilities in our society.
</dd>
<dt>Sue Swenson</dt>
<dd> The Institute on Community Integration has a unique strength in being seen as having more understanding of how community
programs work for folks with intellectual disabilities and developmental disabilities. It's not real regimented. It's not like
there's, you know, some guy in charge who tells everybody else what to do. There's, I don't know, a hundred and fifty, couple hundred
people, each of whom are exploring some of the ideas that they're really interested in.
</dd>
</dl>
</div>



Which I've gotten.


However. I want to allow for another ttf document to have other kinds of spans and to be able to do something else (pass them on, ignore them, whatever)
So I would like to have a selector on my span template


I currently have this (modified for brevity):
<xsl:template match="tt:span">
<xsl:if test="count(../preceding-sibling::*)>0">
<xsl:text disable-output-escaping="yes">&lt;/dd&gt;</xsl:text>
</xsl:if>
<dt>
<xsl:value-of disable-output-escaping="yes" select="."/>
</dt>
<xsl:text disable-output-escaping="yes">&lt;dd&gt;</xsl:text>
</xsl:template>


I would like to have

<xsl:template match="tt:span[@class='defaultSpeaker']">
<xsl:if test="count(../preceding-sibling::*)>0">
<xsl:text disable-output-escaping="yes">&lt;/dd&gt;</xsl:text>
</xsl:if>
<dt>
<xsl:value-of disable-output-escaping="yes" select="."/>
</dt>
<xsl:text disable-output-escaping="yes">&lt;dd&gt;</xsl:text>
</xsl:template>
<xsl:template match="tt:span">
<!-- do something else -->
</xsl:template>


but when I do that the selector doesn't work. How do I do this very simple filter?

Thanks
Joelle

Current Thread