dimanche 13 décembre 2015

XSL -if combination with attribute

Hi everybody i have a litle problem with xsl. I have a basic document like this:

<head>
<persName type="creator" xml:id="ID.14">
            <forename>Theodor</forename>
            <surname>Billroth</surname>
          </persName>
          <persName type="addressee" xml:id="ID.15">
            <forename>Alexander</forename>
            <surname>Rollett</surname>
</persName>
<persName type="creator" xml:id="ID.14">
            <forename>Christian</forename>
            <surname>Billroth</surname>
          </persName>
          <persName type="addressee" xml:id="ID.15">
            <forename>Phil</forename>
            <surname>Rollett</surname>
</persName>
</head>

I have written a short XSL statement like that. And i am tryiing to learn this language so please give me some advices.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:template match="/">
  <html>
  <body>
        <br/>
        <xsl:text> From </xsl:text>
        <xsl:if test="//persName[@type='creator']">
            <xsl:value-of select="//forename"/>
            <xsl:text> to </xsl:text>
        </xsl:if>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

At the moment the Output is looking like this:

From to 

I expect or better i want to generate an output which hits the creator attribute and if it hits it should add the forename. then jump down , add to select the forenema from the addresssee. and the output should look like this

From Theodor To Alexander 
and
From Christian to Phil

ok the and is an option. I hope you have a solution for that. Cheers

Aucun commentaire:

Enregistrer un commentaire