Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
77 views
in Technique[技术] by (71.8m points)

XML-TEI How to call two attributes

I'm working with poetry and I want to give to every verse an own ID that mixes the number of the poem and the number of the verse.

Header:

  <?xml version="1.0" encoding ="UTF-8" standalone ="no" ?>
    <TEI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <teiHeader>
        <fileDesc>
          <titleStmt>
            <title n="013">13</title>

Verses:

<lg>
    <l n="01"></l>
</lg>

I want to create an xml:id attribute for <l> like p013-v01 (poem 13, from n@title; verse 1 from n@l). Is there any way to do it automatically for every single line?

The purpose of this is to compare versions and editions of the same poem. I was told to do this, but to be honest I'm not sure of the utility of this xml:id attribute. I hope you can help me. Thanks!

question from:https://stackoverflow.com/questions/65846638/xml-tei-how-to-call-two-attributes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
    <xsl:template match="l">
       <xsl:variable name="id-num" select="concat('p', ancestor::TEI/descendant::title/@n, '-v', ./@n)"/>
       <l id="{$id-num}">
          <xsl:attribute name="n"><xsl:value-of select="@n"/></xsl:attribute>
          <xsl:apply-templates/>
       </l>
    </xsl:template>

The id-value is the result of a concatenation of literal text strings and two attribute values.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...