Search code examples
xlstei

Excluding a node in <xsl:apply-templates select= />


I am working with this TEI XML document:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://epidoc.stoa.org/schema/latest/tei-epidoc.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://epidoc.stoa.org/schema/latest/tei-epidoc.rng" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" xml:space="preserve" xml:lang="en">
    <teiHeader>
        <fileDesc>
            <titleStmt>
                <title>Vat. Pal. gr. 44</title>
            </titleStmt>
            <publicationStmt>
                <authority></authority>
                <idno type="filename">colophon.010</idno>
                <idno type="Σημειώματα"><ref target="http://simeiomata-kodikon.arch.uoa.gr/index.php/simeioma/10">10</ref></idno>
                <idno type="nr">10</idno>
            </publicationStmt>
            <sourceDesc>
                <msDesc>
                    <msIdentifier>
                        <settlement ref="#vatican">Città del Vaticano</settlement> 
                        <repository ref="#BAV">Biblioteca Apostolica Vaticana</repository> 
                        <collection>Pal. gr.</collection>
                        <idno>44</idno>
                        <altIdentifier type="Pinakes">
                            <idno><ref target="https://pinakes.irht.cnrs.fr/notices/cote/id/65777">65777</ref></idno>
                        </altIdentifier>
                    </msIdentifier>
                    <physDesc>
                        <objectDesc>
                            <supportDesc>
                                <support xml:lang="it">Manoscritto <material>pergamenaceo</material>.</support>
                            </supportDesc>
                            <layoutDesc>
                                <layout xml:lang="it">I due testi occupano quasi interamente il f. 245v. Essi sono separati dal testo principale
                                e tra di loro da semplici linee ornate. Una fascia a motivi fitomorfi chiude il secondo testo.</layout>
                            </layoutDesc>
                        </objectDesc>
                        <handDesc>
                            <handNote xml:lang="it">Maiuscola ogivale diritta</handNote>
                        </handDesc>
                    </physDesc>
                    <history>
                        <origin>
                            <origPlace>Place of origin</origPlace>
                            <origDate when="0056" precision="high" evidence="internal-date" datingMethod="#julian"/>
                                <p xml:lang="it"></p>
                                <p xml:lang="en"></p>
                        </origin>
                        <provenance type="found"> Findspot and circumstances/context
                        </provenance>
                        <provenance type="observed">Modern location(s) (if different from repository, above)
                        </provenance>
                    </history>
                </msDesc>
            </sourceDesc>
        </fileDesc>
    </teiHeader>
    <facsimile>         
        <graphic url="colophon.010.jpg"><desc>Vat. Pal. gr. 44, f. 245v</desc></graphic> 
    </facsimile>
    <text>
        <body>
            <div type="edition" xml:lang="grc" xml:space="preserve">
            <div type="textpart" n="A" xml:id="A"> 
                <ab> 
                    <lb n="1"/><g type="cross">+</g> ὡς <choice><reg>ἡδὺ</reg><orig>ϊδὺ</orig></choice> τοῖς πλέουσιν εὔδιος λιμὴν 
                    <lb n="2"/>οὕτως καὶ τοις γραφουσιν ὁ <choice><orig>ΰστατος</orig><reg>ὔστατος</reg></choice> στίχος. 
                </ab>
            </div>

            <div type="textpart" n="B"> <!--agguyngere a lexicon.xml γράφω δέλτος ἑρμηνευτής ψαλτήρ ταβουλάριος 
                                            aggiungere a persons.xml λεων.ταβουλαριος-->
                <ab>  
                    <lb n="1"/><unclear><g type="cross">+</g></unclear> <rs type="lex" ref="#γράφω"><w lemma="γράφω">ἐγράφη</w></rs> οὖν 
                      ἡ <rs type="lex" ref="#παρών"><w lemma="παρών">παροῦσα</w></rs> 
                      <rs type="lex" ref="#δέλτος"><w lemma="δέλτος">δέλτος</w></rs> τοῦ 
                   <lb n="2"/><rs type="lex" ref="#ἑρμηνευτής"><w lemma="ἑρμηνευτής">ἐρμηνευτοῦ</w></rs> 
                      <rs type="lex" ref="ψαλτήρ"><w lemma="ψαλτήρ">ψαλτήρος</w></rs> δια 
                      <rs type="lex" ref="#χείρ"><w lemma="χείρ">χειρὸς</w></rs> 
                    <lb n="3"/><persName type="copist" ref="#λεων.ταβουλαριος">Λέωντος</persName> 
                      <rs type="app" ref="#ταβουλάριος"><w lemma="ταβουλάριος">ταβουλαρίου</w></rs> Μονοβα
                    <lb n="4" break="no"/>σίας <expan><abbr>μη</abbr><ex>νι</ex></expan> αὐγούστῳ 
                      <num value="28"><hi rend="supraline">κη</hi></num> 
                      <expan><abbr>ἡμέ</abbr><ex>ρᾳ</ex></expan> <num value="2"><hi rend="supraline">β</hi></num> 
                      <expan><abbr>ἰνδ</abbr><ex>ικτιῶνος</ex></expan> <supplied reason="lost"><num value="1">α</num></supplied>
                    <lb n="5"/> ἔτους <num value="6405"><hi rend="supraline"><unclear>ϛ</unclear>υε</hi></num> -· 
                    <lb n="6"/>ὁ ἀναγινώσκων εὔχου μοι <choice><orig>δια</orig><reg>διὰ</reg></choice> τὸν <expan><abbr><hi rend="supraline">κ</hi></abbr><ex>υρίο</ex><abbr><hi rend="supraline">ν</hi></abbr></expan> 
                    <lb n="7"/>ὅπως <choice><orig>λυτρωθω</orig><reg>λυτρωθῶ</reg></choice> <choice><orig>του</orig><reg>τοῦ</reg></choice> 
                      <choice><orig>πυρος</orig><reg>πυρὸς</reg></choice> τῆς Γεαίννης.
                </ab>
            </div>
            </div>
            <div type="apparatus">
            </div>
            <div type="translation" xml:lang="it" resp="Luca De Curtis">
                <p corresp="A"> Come è cosa dolce per coloro che navigano il porto tranquillo, così per coloro che scrivono è l'ultima riga.
                </p>

                <p corresp="B">
                </p>
            </div>
            <div type="commentary">
                <p>
                    <seg xml:lang="it">Il colofone vero e proprio è costituito dal testo B.</seg>
                </p>
            </div>
            <div type="bibliography">
                <p></p>
            </div>
        </body>
    </text>
</TEI>

Now, I want to customize the xls stylesheet to display all the child of <msIdentifier> with the exclusion of <altIdentifier>. Here the template I am working with:

<xsl:template name="greco-body-structure">
    <xsl:call-template name="greco-navigation"/>
    <div id="greco-inscription-body" class="greco">
      <div id="title" class="greco">
        <h1><xsl:if test="//t:idno[@type='projectNo']/text()"><xsl:value-of select="number(//t:idno[@type='projectNo'])"/>. </xsl:if><xsl:apply-templates select="//t:titleStmt/t:title"/></h1>
      </div>
      
      
      <div id="descriptive_lemma" class="greco">
        <p><b>Segnatura: </b> <!--Vedere come selezionare ms identifier senza altidentifier-->
          <xsl:choose>
            <xsl:when test="//t:msDesc/t:msIdentifier">
              <xsl:apply-templates select="//t:msDesc/t:msIdentifier">
            </xsl:when>
            <xsl:otherwise>?</xsl:otherwise>
          </xsl:choose>
        </p>
</div>
</div>
</xsl:template>

I tried something like <xsl:apply-templates select="//t:msDesc/t:msIdentifier[not(/altIdentifier)]"> but it does not work, and it still displays Città del Vaticano Biblioteca Apostolica Vaticana Pal. gr. 44 65777 instead of Città del Vaticano Biblioteca Apostolica Vaticana Pal. gr. 44 (without the last id number). Can anyone help?


Solution

  • If you apply templates to some subtree and want some element or other node to not be processed/copied, make sure you add an empty template e.g. <xsl:template match="t:msIdentifier/t:altIdentifier"/> so that the node doesn't produce any output.

    At the level of the select attribute of xsl:apply-templates you can use except to use e.g. * except foo to apply templates to all child elements except the foo child element but I don't think that will help if you apply templates to a certain msIdentifier but want to exclude some descendants of it from producing output; for that, as said above, add an empty template.