How to view pub year based on xml:id through XSLT? -


i using code in xml

reference citation links in xml:

   boulos <link href="#bib-0014"/>    

corresponding reference:

  <bib xml:id="bib-0014"><citation type="journal" xml:id="cit-0014"><author><familyname>boulos</familyname>, <givennames>l</givennames></author>. **<pubyear year="1974">1974a</pubyear>**. <articletitle>r&#x00e9;vision syst&#x00e9;matique du genre <i>sonchus</i> l. s.l. v. sous&#x2010;genre 2. <i>dendrosonchus</i>. &#x2013; bot</articletitle>. <journaltitle>not</journaltitle>. <vol>127</vol>: <pagefirst>7</pagefirst>&#x2013;<pagelast>37</pagelast>.</citation></bib> 

figure citation links in xml:

   fig <link href="#ecog340-fig-0001"/> 

corresponding figure:

      <figure xml:id="ecog340-fig-0001">       <mediaresourcegroup>       <mediaresource alt="image" href="urn:x-wiley:16000587:media:ecog340:ecog340-fig-0001"/>       <mediaresource alt="image" mimetype="image/png" href="image_n/ecog340-fig-0001.png" rendition="weboriginal" />       <mediaresource alt="image" mimetype="image/gif" href="image_t/ecog340-fig-0001-t.gif" rendition="weblores" />       <mediaresource alt="image" mimetype="image/png" href="image_m/ecog340-fig-0001-m.png" rendition="webhires" />       </mediaresourcegroup>       <caption>       <p>........</p>       </caption>       </figure> 

table citation links in xml:

   table <link href="#ecog340-tbl-1"/> 

corresponding table:

    <tabular xml:id="ecog340-tbl-1">     <title type="main">......</title> 

using in xslt:

    <xsl:template match="link">     <a href="{@href}"><xsl:value-of select="@href"/>     <xsl:value-of select="."/>      </a>     </xsl:template> 

in browserview:

boulos #bib-0014

fig #ecog340-fig-0001

table #ecog340-tbl-1

but want should view reference links year

boulos 1974a

with number (based on id - omit zeros)

fig 1

with number (based on id)

table 1

could please?

i'd define key

<xsl:key name="bibbyid" match="bib" use="@xml:id"/> 

then in link template can year with

<xsl:value-of select="key('bibbyid', substring-after(@href, '#'))/citation/pubyear" /> 

extending question tables , figures well, i'd adopt more flexible approach - allow key take in figure , tabular elements bib:

<xsl:key name="xrefbyid" match="bib|tabular|figure" use="@xml:id"/> 

and define templates in special mode handle various cases

<xsl:template match="bib" mode="xref">   <xsl:value-of select="citation/pubyear" /> </xsl:template>  <xsl:template match="*" mode="xref">   <!-- take after second dash in id , treat number -->   <xsl:value-of select="          number(substring-after(substring-after(@xml:id, '-'), '-'))" /> </xsl:template> 

now in link template can use

<xsl:template match="link">   <a href="{@href}">     <xsl:apply-templates select="key('bibbyid', substring-after(@href, '#'))"                          mode="xref" />    </a> </xsl:template> 

and right thing each kind of cross-reference.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -