[tei-council] Conference call Nov. 29

Sebastian Rahtz sebastian.rahtz at computing-services.oxford.ac.uk
Sun Nov 28 08:10:29 EST 2004


Syd Bauman wrote:

>
>Sorry, my XSLT just isn't that good. Some things I don't understand. 
>
>   <xsl:when test="starts-with(@target,'#')">
>
>The test here checks that the first character of the value
>of the target= attribute is "#". Is that sufficient? We haven't
>agreed on the details yet, but the suggestion was that target= be
>declared as either
>   xsd:anyURI			# for P4 IDREF
>or
>   list { xsd:anyURI+ }		# for P4 IDREFS
>Will a conforming processor have already handled whitespace issues?
>
>  
>
oh, sorry, I didn't realize you meant you needed a solution to handle
multiple targets.  handling space-separated targets would need a call to 
(extension function)
exslt:tokenize, or wait for XSLT2

but thats the same as it is now, isn't it? if XSLT has some special
code for handling IDREFS, I at least have never used it. Though
I suspect my stylesheets have never had to handle IDREFS anyway.

>I realize I didn't ask for sample code to handle the new version of
>IDREFS, but I am a bit concerned about leading & trailing whitespace
>for a RelaxNG list.
>  
>
a quick "normalize-space()" around the @target should clear that up

>   select="key('IDS',substring-after(@target,'#'))"
>   mode="xref"
>
>Here I'm a bit lost. The first line selects all nodes for which the
>IDS key matches the value of target= after the "#". 
>
yup.

>So supposedly
>somewhere there's some code to set the key for each element to its
>xml:id= value, right? 
>
<xsl:key name="IDS" match="*" use="@xml:id"/>

>I'm guessing the mode=xref business tells XSLT
>which of several possible modes to use when processing the templates
>that are selected -- I'm guessing that if no 'xref' mode is defined
>for a template that is selected, nothing happens.
>  
>
no; if no mode is defined, it uses default rules (which isn't what you 
want).
so you have a fallback
  <xsl:template match="*" mode="xref">
which returns a way of getting to any particular element
(it may return an error code, of course).

><castList>
>   <!-- ... -->
>   <castItem><role xml:id="r.jp">Colonel Juan Peron</role></castItem>
>   <!-- ... -->
></castList>
><!-- ... -->
><sp who="#r.jp">
>   <speaker>Col. P.</speaker>
>   <p> ... </p>
></sp>
>
>
>In both cases we want to ignore <speaker> elements and precede each
><sp> element with
>   <span class="speaker">[content of correct <role> here]:</span>
>
>  
>

(untested)

<xsl:template match="speaker"/>

<xsl:template match="sp">
 <span class="speaker">
  <xsl:for-each select="key('IDS',substring-after(@who,'#'))">
    <xsl:apply-templates/>
  </xsl:for-each>
 </span>
 <xsl:apply-templates/>
</xsl:template>


apart from the substring-after thing, this is
exactly what I'd have done for P4 too.

but wasn't this all discussed in SO? when you agreed on the syntax,  you
must have had some ideas of the algorithms for processing it?

-- 
Sebastian Rahtz      
Information Manager, Oxford University Computing Services
13 Banbury Road, Oxford OX2 6NN. Phone +44 1865 283431

OSS Watch: JISC Open Source Advisory Service
http://www.oss-watch.ac.uk




More information about the tei-council mailing list