problem..

Here should go questions about transforming XML with XSLT and FOP.
heldopslippers
Posts: 10
Joined: Thu Dec 07, 2006 12:08 pm

problem..

Post by heldopslippers »

I hava this XML file

<a name="1">
<b name="2">
</b>
</a>

I would like to get the name from b
I thought this but doesn't work:

<xsl:value-of select="/b/@NAME"/>

I hope someone can help me out
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Post by Radu »

Hi,

You have two mistakes in the select.
First of all, everything in XSL (and XML in general) is case sensitive so the attribute name must be written "name" and not "NAME".
Then, if you begin an XPath with a "/" it means it's absolute which in your case is not true.
So the select XPath value should read:

Code: Select all


 <xsl:value-of select="/a/b/@name"/> 
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
heldopslippers
Posts: 10
Joined: Thu Dec 07, 2006 12:08 pm

Post by heldopslippers »

:P THANXS !!!
heldopslippers
Posts: 10
Joined: Thu Dec 07, 2006 12:08 pm

Post by heldopslippers »

:oops: I am sorry...but welll I think my example wasn't good enough ....

this is my new example:

Code: Select all


<FMPXMLRESULT xmlns="http://www.filenaker.com/fmpxmlresult">
<DATABASE NAME="filemaker" />
</FMPXMLRESULT>
well ehm my exmaple wasn't good enough I think so sorry... I tryed this:

Code: Select all


<xsl:value-of select="/FMPXMLRESULT/DATABASE/@NAME" />
I hope somebody can hellp me
(and for radu it works on my first example but not this one)

gr "heldopslippers" :wink: [/code]
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Post by Radu »

Hi,

The difference is that all the elements in your second XML fragment are in the "http://www.filenaker.com/fmpxmlresult" namespace so one way to access the attribute value is to bind the namespace to a prefix and use the prefix in the XPath like:

Code: Select all

 <xsl:value-of select="/FS:FMPXMLRESULT/FS:DATABASE/@NAME" xmlns:FS="http://www.filenaker.com/fmpxmlresult"/>    
I recommend reading this tutorial http://www.zvon.org/xxl/XSLTutorial/Output/index.html about stylesheets.

We also have more tutorial links here:
http://www.oxygenxml.com/tutorials.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
heldopslippers
Posts: 10
Joined: Thu Dec 07, 2006 12:08 pm

Post by heldopslippers »

:lol: I works !! thank you..... and I wil read the tutorials


gr "heldopslippers"
Post Reply