The CMC folks wanted to refer, from within a paragraph of prose, to one of the examples in the chapter. Turns out, though, if you just do the reasonable, expected thing (put an @xml:id on the <egXML>, and then refer to it with a <ptr>), the output looks awful. (Because the text of the pointer is created by concatenating all the text nodes in the target.) That is a Stylesheets problem (for which there is not yet an issue). BUT it begs the question “how do we normally do this?”.
The answer is, we don’t have a normal way to do this. As far as I can tell (using the XSLT below):
We use <ref> to point to <anchor> (makes sense, would be hard to generate link text from an empty element) — Note that this happens 5 times, and it is always the same anchor.
We use both <ptr> and <ref> to point to <figure> (The former 4 times; the latter twice, both the same figure.)
We use <ptr> to point to <table>.
below
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tei="http://www.tei-c.org/ns/1.0"
version="3.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:text>
 </xsl:text>
<xsl:apply-templates select="//tei:*/@target[starts-with( normalize-space(.), '#')]"/>
</xsl:template>
<xsl:template match="@target">
<xsl:variable name="whatIamTargetOf" select="local-name(..)" as="xs:string"/>
<xsl:variable name="whereIpoint" select="substring( normalize-space( .), 2 )" as="xs:string"/>
<xsl:variable name="whatIpointAt" select="local-name( id( $whereIpoint ) )" as="xs:string"/>
<xsl:variable name="whichOccurence" as="xs:string">
<xsl:number select=".." level="single" ordinal="yes"/>
</xsl:variable>
<xsl:if test="not( $whatIpointAt = ('div', 'specGrp', 'bibl', 'biblStruct') )">
<xsl:sequence select=" $whatIamTargetOf
||'/@target='
||$whereIpoint
||' points to a '
||local-name( id( $whereIpoint ) )
||'; it is in section '
||(ancestor-or-self::*[@xml:id|@ident][1]/@xml:id|ancestor-or-self::*[@xml:id|@ident][1]/@ident)[1]
||' and is the '
||$whichOccurence
||' such.
'
"/>
<!-- Note-to-self: That run-on XPath for the section selects an
@xml:id preferentially over an @ident. That is not really
what we want; we want whichever is closer. Not worth the
effort at the moment, especially since it turns out there
is only 1 that does not have in @xml:id. -->
</xsl:if>
</xsl:template>
</xsl:stylesheet>
The CMC folks wanted to refer, from within a paragraph of prose, to one of the examples in the chapter. Turns out, though, if you just do the reasonable, expected thing (put an
@xml:id
on the<egXML>
, and then refer to it with a<ptr>
), the output looks awful. (Because the text of the pointer is created by concatenating all the text nodes in the target.) That is a Stylesheets problem (for which there is not yet an issue). BUT it begs the question “how do we normally do this?”.The answer is, we don’t have a normal way to do this. As far as I can tell (using the XSLT below):
<ref>
to point to<anchor>
(makes sense, would be hard to generate link text from an empty element) — Note that this happens 5 times, and it is always the same anchor.<ptr>
and<ref>
to point to<figure>
(The former 4 times; the latter twice, both the same figure.)<ptr>
to point to<table>
.below