0

I have an xml-file, similar to this excerpt:

    <?xml version="1.0" encoding="UTF-8"?><TEI xmlns="http://www.tei-c.org/ns/1.0">
       <teiHeader>
          <fileDesc>
             <titleStmt><title type="main">Augsburger Interim 1548 (lat)</title></titleStmt><publicationStmt><publisher ref="http://d-nb.info/gnd/10073682-8"><orgName>Universitäts- und Landesbibliothek Darmstadt</orgName></publisher><pubPlace>Darmstadt</pubPlace></publicationStmt>
             <seriesStmt><title level="s">Europäische Religionsfrieden digital</title></seriesStmt>
             <sourceDesc>
                <bibl>
                   <title type="main">Augsburger Interim 1548 (lat)</title><idno type="Transkribus">565093</idno><idno type="external">NA</idno>
                </bibl>
             </sourceDesc>
          </fileDesc>
       </teiHeader>
       <facsimile>
         <surface ulx="0" uly="0" lrx="7920" lry="11579" xml:id="facs_4"><grapic url="https://api.digitale-sammlungen.de/iiif/image/v2/bsb10940504_00003/full/full/0/default.jpg" width="7920px" height="11579px"/><zone points="1282,1062 6319,1062 6319,3828 1282,3828" rendition="TextRegion" xml:id="facs_4_TextRegion_1628082563377_103">
            <zone points="1232,1039 6366,1039 6366,1706 1232,1706" rendition="Line" xml:id="facs_4_r1l3"/>
            <zone points="1278,1662 6279,1662 6279,2046 1278,2046" rendition="Line" xml:id="facs_4_r1l9"/>
            <zone points="1514,1960 6020,1960 6020,2294 1514,2294" rendition="Line" xml:id="facs_4_r1l10"/>
            <zone points="1681,2271 5947,2271 5947,2611 1681,2611" rendition="Line" xml:id="facs_4_r1l11"/>
            <zone points="1871,2495 5717,2495 5717,2798 1871,2798" rendition="Line" xml:id="facs_4_r1l12"/>
            <zone points="2141,2739 5511,2739 5511,3114 2141,3114" rendition="Line" xml:id="facs_4_r1l13"/>
            <zone points="2398,2992 5223,2992 5223,3338 2398,3338" rendition="Line" xml:id="facs_4_r1l14"/>
            <zone points="2644,3267 5030,3267 5030,3627 2644,3627" rendition="Line" xml:id="facs_4_r1l16"/>
            <zone points="3046,3707 4543,3707 4543,3776 3046,3776" rendition="Line" xml:id="facs_4_line_1631027974815_752"/>
          </zone><zone points="3599,3844 3952,3844 3952,4389 3599,4389" rendition="TextRegion" xml:id="facs_4_TextRegion_1628082626805_110" subtype="other">
            <zone points="3611,4271 3939,4271 3939,4335 3611,4335" rendition="Line" xml:id="facs_4_line_1628082749326_143"/>
          </zone><zone points="1300,4349 6328,4349 6328,5235 1300,5235" rendition="TextRegion" xml:id="facs_4_TextRegion_1628082626805_109">
            <zone points="2904,4326 4744,4326 4744,4626 2904,4626" rendition="Line" xml:id="facs_4_line_1628082626879_112"/>
            <zone points="3052,4547 4599,4547 4599,4899 3052,4899" rendition="Line" xml:id="facs_4_r1l20"/>
            <zone points="2520,4779 5045,4779 5045,5203 2520,5203" rendition="Line" xml:id="facs_4_r1l21"/>
          </zone><zone points="1876,5194 5648,5194 5648,8578 1876,8578" rendition="TextRegion" xml:id="facs_4_TextRegion_1628082255490_39" subtype="other">
            <zone points="1945,8394 5632,8394 5632,8450 1945,8450" rendition="Line" xml:id="facs_4_line_1628082795209_149"/>
          </zone><zone points="2149,8539 5409,8539 5409,9816 2149,9816" rendition="TextRegion" xml:id="facs_4_TextRegion_1628082255490_38">
            <zone points="2229,8531 5364,8531 5364,8950 2229,8950" rendition="Line" xml:id="facs_4_line_1628082255556_41"/>
            <zone points="2653,8983 4872,8983 4872,9404 2653,9404" rendition="Line" xml:id="facs_4_r1l23"/>
            <zone points="2191,9292 5288,9292 5288,9702 2191,9702" rendition="Line" xml:id="facs_4_r1l24"/>
            <zone points="2880,9558 4686,9558 4686,9963 2880,9963" rendition="Line" xml:id="facs_4_r1l25"/>
          </zone></surface> <surface ulx="0" uly="0" lrx="7920" lry="11412" xml:id="facs_5"><graphic url="https://api.digitale-sammlungen.de/iiif/image/v2/bsb10940504_00004/full/full/0/default.jpg" width="7920px" height="11412px"/></surface><surface ulx="0" uly="0" lrx="7920" lry="11625" xml:id="facs_6"><graphic url="https://api.digitale-sammlungen.de/iiif/image/v2/bsb10940504_00005/full/full/0/default.jpg" width="7920px" height="11625px"/><zone points="6168,883 6426,883 6426,1141 6168,1141" rendition="TextRegion" xml:id="facs_6_region_1625231307705_59" subtype="page-number">
    <zone points="6248,937 6391,937 6391,1090 6248,1090" rendition="Line" xml:id="facs_6_line_1625231327025_63"/>
  </zone><zone points="1294,1254 6360,1254 6360,6101 1294,6101" rendition="TextRegion" xml:id="facs_6_TextRegion_1625231542879_93">
    <zone points="2718,1057 6294,1057 6294,1475 2718,1475" rendition="Line" xml:id="facs_6_r1l1"/>
    <zone points="2630,1384 6326,1384 6326,1742 2630,1742" rendition="Line" xml:id="facs_6_r1l2"/>
    <zone points="2668,1641 6342,1641 6342,1920 2668,1920" rendition="Line" xml:id="facs_6_r1l3"/>
    <zone points="2609,1862 6354,1862 6354,2171 2609,2171" rendition="Line" xml:id="facs_6_r1l4"/>
    <zone points="2661,2139 6324,2139 6324,2417 2661,2417" rendition="Line" xml:id="facs_6_r1l5"/>
    <zone points="2619,2323 6352,2323 6352,2646 2619,2646" rendition="Line" xml:id="facs_6_r1l6"/>
    <zone points="1260,2569 6412,2569 6412,2834 1260,2834" rendition="Line" xml:id="facs_6_r1l7"/>
    <zone points="1287,2818 6395,2818 6395,3082 1287,3082" rendition="Line" xml:id="facs_6_r1l8"/>
    <zone points="1267,3033 6376,3033 6376,3342 1267,3342" rendition="Line" xml:id="facs_6_r1l9"/>
    <zone points="1304,3275 6355,3275 6355,3560 1304,3560" rendition="Line" xml:id="facs_6_r1l10"/>
    <zone points="1268,3505 6364,3505 6364,3763 1268,3763" rendition="Line" xml:id="facs_6_r1l11"/>
    <zone points="1278,3752 6354,3752 6354,4037 1278,4037" rendition="Line" xml:id="facs_6_r1l12"/>
    <zone points="1339,3985 6366,3985 6366,4276 1339,4276" rendition="Line" xml:id="facs_6_r1l13"/>
    <zone points="1267,4239 6381,4239 6381,4505 1267,4505" rendition="Line" xml:id="facs_6_r1l14"/>
    <zone points="1271,4389 6361,4389 6361,4733 1271,4733" rendition="Line" xml:id="facs_6_r1l15"/>
    <zone points="1307,4671 6377,4671 6377,4986 1307,4986" rendition="Line" xml:id="facs_6_r1l16"/>
    <zone points="1310,4921 6386,4921 6386,5202 1310,5202" rendition="Line" xml:id="facs_6_r1l17"/>
    <zone points="1286,5172 6362,5172 6362,5444 1286,5444" rendition="Line" xml:id="facs_6_r1l18"/>
    <zone points="1277,5365 6366,5365 6366,5706 1277,5706" rendition="Line" xml:id="facs_6_r1l19"/>
    <zone points="1262,5621 6364,5621 6364,5986 1262,5986" rendition="Line" xml:id="facs_6_r1l20"/>
    <zone points="1284,5865 3753,5865 3753,6101 1284,6101" rendition="Line" xml:id="facs_6_line_1625231542991_96"/>
  </zone><zone points="1294,6101 6360,6101 6360,9574 1294,9574" rendition="TextRegion" xml:id="facs_6_TextRegion_1625231735196_169">
    <zone points="1770,6101 6335,6101 6335,6345 1770,6345" rendition="Line" xml:id="facs_6_line_1625231542993_97"/>
    <zone points="1270,6282 6347,6282 6347,6622 1270,6622" rendition="Line" xml:id="facs_6_r1l23"/>
    <zone points="1280,6513 6326,6513 6326,6783 1280,6783" rendition="Line" xml:id="facs_6_r1l24"/>
    <zone points="1278,6737 6348,6737 6348,7079 1278,7079" rendition="Line" xml:id="facs_6_r1l25"/>
    <zone points="1302,6976 6297,6976 6297,7318 1302,7318" rendition="Line" xml:id="facs_6_r1l26"/>
    <zone points="1282,7233 6345,7233 6345,7502 1282,7502" rendition="Line" xml:id="facs_6_r1l27"/>
    <zone points="1276,7455 6371,7455 6371,7767 1276,7767" rendition="Line" xml:id="facs_6_r1l28"/>
    <zone points="1268,7670 6332,7670 6332,7975 1268,7975" rendition="Line" xml:id="facs_6_r1l29"/>
    <zone points="1300,7906 6358,7906 6358,8239 1300,8239" rendition="Line" xml:id="facs_6_r1l30"/>
    <zone points="1287,8154 6339,8154 6339,8443 1287,8443" rendition="Line" xml:id="facs_6_r1l31"/>
    <zone points="1305,8382 6357,8382 6357,8677 1305,8677" rendition="Line" xml:id="facs_6_r1l32"/>
    <zone points="1265,8624 6323,8624 6323,8878 1265,8878" rendition="Line" xml:id="facs_6_r1l33"/>
    <zone points="1298,8879 6375,8879 6375,9176 1298,9176" rendition="Line" xml:id="facs_6_r1l34"/>
    <zone points="1349,9136 6343,9136 6343,9388 1349,9388" rendition="Line" xml:id="facs_6_r1l35"/>
    <zone points="1270,9312 6314,9312 6314,9574 1270,9574" rendition="Line" xml:id="facs_6_line_1625231735305_172"/>
  </zone><zone points="4250,9584 4945,9584 4945,9840 4250,9840" rendition="TextRegion" xml:id="facs_6_TextRegion_1625231768454_186" subtype="signature-mark">
    <zone points="4293,9563 4844,9563 4844,9872 4293,9872" rendition="Line" xml:id="facs_6_r1l38"/>
  </zone><zone points="5249,9574 6360,9574 6360,9822 5249,9822" rendition="TextRegion" xml:id="facs_6_TextRegion_1625231768454_185" subtype="catch-word">
    <zone points="5529,9588 6351,9588 6351,9857 5529,9857" rendition="Line" xml:id="facs_6_r1l37"/>
  </zone></surface> </facsimile>
   <text>
      <body>
         <div><pb facs="#facs_4" xml:id="img_0004" n="Titelblatt r"/>
            <p facs="#facs_4_TextRegion_1628082563377_103">
               <lb facs="#facs_4_r1l3" n="N001"/>SACRÆ 
               <w>CÆSA<pc>=</pc><lb facs="#facs_4_r1l9" n="N002"/>REAE</w>
                MAIESTATIS 
               <w>DECLA<pc>-</pc><lb facs="#facs_4_r1l10" n="N003"/>RATIO,</w>
                QVOMODO IN 
               <w>NE<pc>-</pc><lb facs="#facs_4_r1l11" n="N004"/>gocio</w>
                Religionis per Imperium uſqꝫ ad definitionem
               <lb facs="#facs_4_r1l12" n="N005"/>Concilj generalis uiuendum ſit, in Comitijs 
               <w>Au<pc>-</pc><lb facs="#facs_4_r1l13" n="N006"/>gustanis</w>
                XV. Maij, Anno M. D.
               <lb facs="#facs_4_r1l14" n="N007"/>XLV III. propoſita, &amp; 
               <w>publi<pc>-</pc><lb facs="#facs_4_r1l16" n="N008"/>cata,</w>
                 &amp; ab omnibus Imperij
               <lb facs="#facs_4_line_1631027974815_752" n="N009"/>ordinibus recepta.
            </p>
         </div>
      </body>
   </text>
</TEI>

Sorry, this example is rather excessive due to the lines, but I am afraid of taking them out ...

I want to grab the <graphic url="..."> and put it into an <a href="..."> rather similar tothis expression:

<xsl:value-of select="/tei:TEI/tei:facsimile/tei:facsimile/tei:graphic/@url"/> 

However, If I use the above section of code, I only get the following output:

<span class="pb"> [<a href="https://api.digitale-sammlungen.de/iiif/image/v2/bsb10940504_00004/full/full/0/default.jpg" target="display2">Blatt: Titelblatt r</a>] </span>

--> always the same image ... This part should obviously change, and the images are all there bsb10940504_00004. I am aware, that I am not using the @facs attribute from the surface, but how would I go about it?

Some edits:

it's XSL 1.0 so far.

Problem with this script is, that I am not the creator but rather a maintainer, so at times I struggle with realising what parts are actually necessary.

   <!-- pysical pages     -->
    <xsl:template match="tei:pb">
        <xsl:variable name="url">
            <!-- convert identifier z.B. drucke_qun-59-9-1_00006 -->
            <xsl:value-of select="$server"/>
            <!-- select type of resource, e.g. mss or drucke -->
            <xsl:value-of select="substring-before(substring(@facs,2),'_')"/>
            <xsl:text>/</xsl:text>
            <!-- select normalised shelfmark -->
            <xsl:value-of select="translate(substring-before(substring-after(substring(@facs,2),'_'),'_'), '_', '/')"/>
            <!-- select Image-No , e.g. 00006  -->
            <xsl:text>/start.htm?distype=imgs&amp;image=</xsl:text>
            <xsl:value-of select="substring-after(substring-after(substring(@facs,2),'_'),'_')"/>
        </xsl:variable>
        <!--    <div class="pagebreak"> -->

        <xsl:if test="@ed">
            <xsl:value-of select="substring(@ed,4)"/>
            <xsl:text>: </xsl:text>
        </xsl:if>
        <span class="pb">
        <xsl:text> [</xsl:text> 
        <xsl:choose>
            <xsl:when test="@facs">
        
                <a>
                    <xsl:attribute name="href">
                        <xsl:choose>
                            <xsl:when test="@facs">

                                <xsl:choose>
                                    <xsl:when test="starts-with(@facs, '#varia')">
                                        <xsl:text>http://diglib.hab.de/</xsl:text>
                                        <xsl:value-of select="substring-before(substring(@facs,2),'_')"/>
                                        <xsl:text>/</xsl:text>
                                        <xsl:value-of select="substring-before(substring-after(substring(@facs,2),'_'),'_')"/>
                                        <xsl:text>/start.htm?distype=imgs&amp;image=</xsl:text>
                                        <xsl:value-of select="substring-after(substring-after(substring(@facs,2),'_'),'_')"/>
                                    </xsl:when>
                                    <xsl:when test="starts-with(@facs, 'http://nbn-resolving.de')">
                                        <xsl:value-of select="@facs"/>
                                    </xsl:when>
                                    <!--<xsl:when test="starts-with(@facs, '#mss')">
                                        <xsl:text>http://diglib.hab.de/</xsl:text>
                                        <xsl:value-of select="substring-before(substring(@facs,2),'_')"/>
                                        <xsl:text>/start.htm?distype=imgs&amp;image=</xsl:text>
                                        <xsl:value-of select="substring-after(substring-after(substring(@facs,2),'_'),'_')"/>
                                    </xsl:when>-->
<!--                                    <xsl:when test="starts-with(@facs, '#drucke')"> -->
                                            <!-- Im Moment in der declaratio Ferdinandea mit voller URL angegeben -->
<!--                                    </xsl:when> -->
                                    <xsl:otherwise>
                                        <xsl:variable name="refs"><xsl:value-of select="substring-after(@facs, '#')" /></xsl:variable>
                                        <xsl:value-of select="/tei:TEI/tei:facsimile/tei:surface/tei:graphic/@url" />
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:when>
                            <xsl:when test="document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href">
                                <xsl:value-of select="document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href"/>
                                <xsl:text>&amp;image=</xsl:text>
                                <xsl:value-of select="substring-after(substring-after(substring(@facs,2),'_'),'_')"/>
                            </xsl:when>
                            <xsl:when test="starts-with(document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href,'http:')">
                                <xsl:value-of select="document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href"/>
                                <xsl:text>&amp;image=</xsl:text>
                                <xsl:value-of select="substring-after(substring-after(substring(@facs,2),'_'),'_')"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$content"/>
                                <xsl:text>?dir=</xsl:text>
                                <xsl:value-of select="$dir"/>
                                <xsl:text>&amp;xml=</xsl:text>
                                <xsl:value-of
                                    select="document($metsfile)//mets:file[@ID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@FILEID]/mets:FLocat/@xlink:href"/>
                                <xsl:text>&amp;xsl=</xsl:text>
                                <xsl:value-of
                                    select="document($metsfile)//mets:behavior[@STRUCTID=document($metsfile)//mets:div[@ID=$pvID]/mets:fptr/mets:par/mets:area[2]/@ID]/mets:mechanism/@xlink:href"/>
                                <xsl:text>#</xsl:text>
                                <xsl:value-of select="substring(@facs,2)"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:attribute>
                    <xsl:attribute name="target">
                        <xsl:text>display2</xsl:text>
                    </xsl:attribute> 

I have added the second surface-element in above code. I am at the moment a little overwhelmedby this

All the best, K

KWunsch
  • 77
  • 1
  • 8
  • Does your XML have more than one `graphic` element? If so, post an example that has at least two. Also post a minimal, but complete (executable) XSLT stylesheet, so that we can see the context from which you call the instruction. -- Hint: your current instruction selects ALL `graphic` elements in the input XML that have the specified path and (in XSLT 1.0) returns the value of the FIRST one of these. You probably want to use a *relative* path from your current context node, instead of the *absolute* path you have now - but we don't know what your context node is. – michael.hor257k Nov 18 '21 at 11:30
  • P.S. In all your questions regarding XSLT, please state which version of XSLT your processor supports. – michael.hor257k Nov 18 '21 at 11:32
  • Added the second -element. added some more XSLT ... I am recreating a minimal example as we speak, might take a while, though. It's way too long for a single script ... – KWunsch Nov 18 '21 at 12:11
  • unfortunately I didn't understand your hint ... :-D really sorry -.- – KWunsch Nov 18 '21 at 12:18
  • These edits are not helpful. What is needed is a [mcve] - similar to what I posted. – michael.hor257k Nov 18 '21 at 12:27
  • I'm really trying ... I edited a second graphic element (didn't dare to remove the Zones) and thus IMHO the xml is "minimal" The XSL, damn, the part that I posted (okay, with a xsl-header) gives me a result that I had before. – KWunsch Nov 18 '21 at 12:38

1 Answers1

0

See if this simplifed example can get you on the right track:

XML

<TEI xmlns="http://www.tei-c.org/ns/1.0">
  <facsimile>
    <surface xml:id="facs_1">
      <graphic url="https://images.com/image1.jpg" />
    </surface>
    <surface xml:id="facs_2">
      <graphic url="https://images.com/image2.jpg" />
    </surface>
    <surface xml:id="facs_3">
      <graphic url="https://images.com/image3.jpg" />
    </surface>
  </facsimile>
</TEI>

XSLT 1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="tei">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/tei:TEI">
    <root>
        <xsl:for-each select="tei:facsimile/tei:surface">
            <surface id="{@xml:id}">
                <a href="{tei:graphic/@url}"/>
            </surface>      
        </xsl:for-each>
    </root>
</xsl:template>

</xsl:stylesheet>

Result

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <surface id="facs_1">
    <a href="https://images.com/image1.jpg"/>
  </surface>
  <surface id="facs_2">
    <a href="https://images.com/image2.jpg"/>
  </surface>
  <surface id="facs_3">
    <a href="https://images.com/image3.jpg"/>
  </surface>
</root>

Explanation

The instruction:

<xsl:for-each select="tei:facsimile/tei:surface">

puts you in the context of surface. From this context, the relative path:

tei:graphic/@url

leads to the url attribute of the graphic element that is the child of the current surface.

michael.hor257k
  • 113,275
  • 6
  • 33
  • 51
  • nope it doesnt' get me on track ... Sorry for being useless right now, I kinda really feel overwhelmed by this ... – KWunsch Nov 18 '21 at 12:39