xml - TEI xsl:template to show tag <g> relative charName -


inside tei header of tei file have declared chars: `

<chardecl>    <char xml:id="char1">      <charname>vnc.</charname>      <desc>tractus longus</desc>     </char>      <char xml:id="char2">      <charname>drag.</charname>      <desc>interclusio uncinata</desc>     </char> ... </chardecl> 

`

inside body text of tei have tag : lorem ipsum <g ref="#char2"/> dolor sit ii. cotylus habet <g ref="#char1">—</g> want display this: lorem ipsum [drag.] dolor sit ii. cotylus habet —[vnc.]

how xsl stylesheet xsl:template? tried doesn't work:

 <xsl:key name="char" match="tei:teiheader/encodingdesc/chardecl/char" use="@xml:id"/>  <xsl:template match="tei:g[@ref]">      <xsl:apply-templates />     <span title="<xsl:value-of select="key('char',substring-after(@ref,'#'))/desc"/>">[<xsl:value-of select="key('char',substring-after(@ref,'#'))/charname"/>]</span> </xsl:template> 

inside head of file tei link stylesheet:

<?xml version="1.0" encoding="utf-8"?> <?oxygen rngschema="file:teilite.rnc" type="compact"?> <?xml-stylesheet type="text/xsl" href="../mainstyle.xsl"?> <tei xmlns="http://www.tei-c.org/ns/1.0"> 

inside main style have:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0"   xmlns:xsl="http://www.w3.org/1999/xsl/transform"    xmlns:eg="http://www.tei-c.org/ns/examples"   xmlns:tei="http://www.tei-c.org/ns/1.0"    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"   xmlns:exsl="http://exslt.org/common"   xmlns:msxsl="urn:schemas-microsoft-com:xslt"   xmlns:fn="http://www.w3.org/2005/xpath-functions"   extension-element-prefixes="exsl msxsl"   xmlns="http://www.w3.org/1999/xhtml"    xmlns:html="http://www.w3.org/1999/xhtml"    exclude-result-prefixes="xsl tei xd eg fn #default"> ... <xsl:include href="rendchars.xsl"/> 

inside rendchars.xsl starts:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"     xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"     xmlns:fo="http://www.w3.org/1999/xsl/format" xmlns:html="http://www.w3.org/1999/xhtml"     xmlns:rng="http://relaxng.org/ns/structure/1.0" xmlns:tei="http://www.tei-c.org/ns/1.0"     xmlns:teix="http://www.tei-c.org/ns/examples" xmlns:xsl="http://www.w3.org/1999/xsl/transform"     xmlns:teidocx="http://www.tei-c.org/ns/teidocx/1.0"     exclude-result-prefixes="a fo html rng tei teix teidocx" version="2.0"> 

i tryed these codes didn't work me:

<xsl:key name="chname" match="tei:teiheader/encodingdesc/chardecl/char" use="@xml:id"/> <xsl:template match="g[@ref]">     <span title="{key('chname',substring-after(@ref,'#'))/tei:desc}">[<xsl:value-of select="key('chname',substring-after(@ref,'#'))/tei:charname"/>]</span><xsl:text></xsl:text>  </xsl:template> 

and

<xsl:template match="@*|node()">         <xsl:copy>             <xsl:apply-templates select="@*|node()"/>         </xsl:copy>     </xsl:template>     <xsl:template match="chardecl"/>     <xsl:template match="g[@ref]">       <xsl:value-of select="id(substring-after(@ref,'#'))/charname"/>     </xsl:template> 

and

<xsl:key name="chname" match="tei:teiheader/tei:encodingdesc/tei:chardecl/tei:char" use="@xml:id"/>      <xsl:template match="g[@ref]">         <xsl:apply-templates/>         <span title="{key('chname',substring-after(@ref,'#'))/tei:desc}">[<xsl:value-of select="key('chname',substring-after(@ref,'#'))/tei:charname"/>]</span><xsl:text></xsl:text>      </xsl:template> 

assuming xslt 2.0 should suffice use id function:

<xsl:template match="g[@ref]">   <xsl:value-of select="id(substring(@ref, 2))/charname"/> </xsl:template> 

complete example: http://xsltransform.net/a9gix6.

as attempt, if elements in same namespace think want <span title="{key('char',substring-after(@ref,'#'))/tei:desc}">[<xsl:value-of select="key('char',substring-after(@ref,'#'))/tei:charname"/>]</span>, is, need make sure use prefix tei elements in paths. , key need changed <xsl:key name="char" match="tei:teiheader/tei:encodingdesc/tei:chardecl/tei:char" use="@xml:id"/>


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -