Awkward XPath reference
Posted: Mon Oct 01, 2018 7:53 pm
We have started marking precision on some XML date elements. An invented maximal example is as follows:
<date when="1815-01-06" notBefore="1814-10" notAfter="1815">6 January c1815
<precision match="@when" precision="medium"/>
<precision match="@notBefore" precision="high"/>
<precision match="@notAfter" precision="medium"/>
</date>
My XSLT 1.0 script (XML to HTML) displays the content of the date element, here "6 January c1815". I added a small template to be called after the date display and having no effect unless there are one or more <precision> children:
<xsl:template name="datePrecision">
<xsl:for-each select="TEI/teiHeader/profileDesc/correspDesc/correspAction[@type='sent']/date/precision">
<br/><xsl:value-of select="substring-after(./@match,'@')" /><xsl:text> </xsl:text><xsl:value-of select="???" /> <xsl:text> (precision: </xsl:text><xsl:value-of select="./@precision" />)
</xsl:for-each>
</xsl:template>
The problem is the emboldened, red element, which is meant to be the value of the attribute in <date> whose name (plus @ sign) is given in @match in the relevant <precision> child. What is the XPath formula which will identify this value?
Thanks for any help [or suggestions for a simpler way of achieving the same end].
<date when="1815-01-06" notBefore="1814-10" notAfter="1815">6 January c1815
<precision match="@when" precision="medium"/>
<precision match="@notBefore" precision="high"/>
<precision match="@notAfter" precision="medium"/>
</date>
My XSLT 1.0 script (XML to HTML) displays the content of the date element, here "6 January c1815". I added a small template to be called after the date display and having no effect unless there are one or more <precision> children:
<xsl:template name="datePrecision">
<xsl:for-each select="TEI/teiHeader/profileDesc/correspDesc/correspAction[@type='sent']/date/precision">
<br/><xsl:value-of select="substring-after(./@match,'@')" /><xsl:text> </xsl:text><xsl:value-of select="???" /> <xsl:text> (precision: </xsl:text><xsl:value-of select="./@precision" />)
</xsl:for-each>
</xsl:template>
The problem is the emboldened, red element, which is meant to be the value of the attribute in <date> whose name (plus @ sign) is given in @match in the relevant <precision> child. What is the XPath formula which will identify this value?
Thanks for any help [or suggestions for a simpler way of achieving the same end].