Altova Mailing List Archives
>xsl-list Archive Home
>Recent entries
>Thread Prev -
>Thread Next - Re: [xsl] selecting elements by attributes when working with namespaces
[xsl] selecting elements by attributes when working with namespaces
To:
Date: 7/21/2008 9:13:00 PM
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's not real
regimented. It's not</p>
<p begin="0:00:53.20">like there's, you know, some guy
in charge who tells</p>
<p begin="0:00:56.50">everybody else what to do.
There's, I don'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'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"></dd></xsl:text>
</xsl:if>
<dt>
<xsl:value-of disable-output-escaping="yes" select="."/>
</dt>
<xsl:text disable-output-escaping="yes"><dd></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"></dd></xsl:text>
</xsl:if>
<dt>
<xsl:value-of disable-output-escaping="yes" select="."/>
</dt>
<xsl:text disable-output-escaping="yes"><dd></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
JoelleDisclaimer
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

