Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XML Attribute and XSL

Reply
Thread Tools

XML Attribute and XSL

 
 
giandrea
Guest
Posts: n/a
 
      11-24-2008
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
 
Reply With Quote
 
 
 
 
giandrea
Guest
Posts: n/a
 
      11-24-2008
On 24 Nov, 22:10, giandrea <(E-Mail Removed)> 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>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I use a variable or parameter in an <xsl:if> expression to compare it with the value of an xml attribute? mark4asp XML 2 12-04-2007 07:58 AM
XSL: putting a XSL value inside an html attribute? Kourosh XML 6 05-17-2006 09:13 PM
Use of XSL:variable in XML-Attribute schaf XML 3 09-16-2005 08:22 AM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
XML/XSL newb q: can I ever select or refer to xml attribute values? 5tein XML 1 04-30-2004 12:42 AM



Advertisments