XML Attribute and XSL

G

giandrea

Hi to all

I've this XML file:

<output>
<page1>
<field id="nome">
<value>Andrea</value>
</field>
<field id="citta">
<value>
Milano
</value>
</field>
</output>


I've to create a PDF wih XSL:FO and I use this metod to extract XML
Data

<xsl:template match="output/page1">
<xsl:variable name="id_" select="@id"/>
<xsl:variable name="field" select="output/page1/field[@id=$id_]" />
<fo:block font-size="10pt" color="black">
<xsl:value-of select="$id_"/>: <xsl:value-of select="."/>
</fo:block>
</xsl:template>

I can't see the FIELD attribut ID. How can I show it?

thanks a lot!

Andrea
 
G

giandrea

Hi to all

I've this XML file:

<output>
  <page1>
    <field id="nome">
      <value>Andrea</value>
    </field>
    <field id="citta">
      <value>
        Milano
      </value>
    </field>
</output>

I've to create a PDF wih XSL:FO and I use this metod to extract XML
Data

<xsl:template match="output/page1">
        <xsl:variable name="id_" select="@id"/>
        <xsl:variable name="field" select="output/page1/field[@id=$id_]" />
        <fo:block font-size="10pt" color="black">
                <xsl:value-of select="$id_"/>: <xsl:value-of select="."/>
        </fo:block>
</xsl:template>

I can't see the FIELD attribut ID. How can I show it?

thanks a lot!

Andrea

Solved

<xsl:template match="output/page1">
<xsl:apply-templates select="field"/>
</xsl:template>


<xsl:template match="field">
<fo:block font-size="10pt" color="black" font-weight="bold" text-
align="left">
<xsl:if test="@id ='data'">Data:</xsl:if>
<xsl:if test="@id ='nome'">Nome:</xsl:if>
<xsl:if test="@id ='cognome'">Cognome:</xsl:if>
<xsl:if test="@id ='luogonascita'">Luogo di Nascita:</xsl:if>
<xsl:if test="@id ='datanascita'">Data di Nascita:</xsl:if>
<xsl:if test="@id ='indirizzo'">Indirizzo:</xsl:if>
<xsl:if test="@id ='citta'">Città:</xsl:if>
<xsl:if test="@id ='quesito'">Quesito:</xsl:if>
<xsl:if test="@id ='areaanatomica'">Area anatomica:</xsl:if>
<xsl:if test="@id ='quesito'">Quesito:</xsl:if>
<xsl:if test="@id ='referto'">Referto:</xsl:if>
<xsl:if test="@id ='note'">Note:</xsl:if>
<xsl:value-of select="value" />
</fo:block>
</xsl:template>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top