XML Attribute and XSL

Discussion in 'XML' started by giandrea, Nov 24, 2008.

  1. giandrea

    giandrea Guest

    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
    giandrea, Nov 24, 2008
    #1
    1. Advertising

  2. giandrea

    giandrea Guest

    On 24 Nov, 22:10, giandrea <> wrote:
    > 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>
    giandrea, Nov 24, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. 5tein
    Replies:
    1
    Views:
    468
    Patrick TJ McPhee
    Apr 30, 2004
  2. Replies:
    1
    Views:
    3,595
    A. Bolmarcich
    May 27, 2005
  3. schaf
    Replies:
    3
    Views:
    1,305
    schaf
    Sep 16, 2005
  4. Kourosh
    Replies:
    6
    Views:
    848
    Peter Flynn
    May 17, 2006
  5. Pradeep

    XML, XSL, CSS attribute issue

    Pradeep, Jan 16, 2008, in forum: HTML
    Replies:
    2
    Views:
    443
    Harlan Messinger
    Jan 16, 2008
Loading...

Share This Page