Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Help with xslt

Reply
Thread Tools

Help with xslt

 
 
Mike
Guest
Posts: n/a
 
      11-29-2008
Hello,
I am using Oxygen to help with the learning process. I have the
following xslt and I am trying to understand why I am only getting
one "name" (<?xml version="1.0" encoding="utf-8"?>Belgian Waffles)from
the xml file below.
Thanks

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="/">
<xsl:value-of select="/breakfast_menu/food/name"/>
</xsl:template>
</xsl:stylesheet>

<?xml version="1.0" encoding="utf-8"?>Belgian Waffles

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>two of our famous Belgian Waffles with plenty of real
maple syrup</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>light Belgian waffles covered with strawberries and
whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>light Belgian waffles covered with an assortment of
fresh berries and whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>thick slices made from our homemade sourdough bread</
description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>two eggs, bacon or sausage, toast, and our ever-popular
hash browns</description>
<calories>950</calories>
</food>
</breakfast_menu>
 
Reply With Quote
 
 
 
 
Mukul Gandhi
Guest
Posts: n/a
 
      11-30-2008
On Nov 30, 4:28*am, Mike <ampel...@gmail.com> wrote:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform"
> version="2.0">
> * * <xsl:template match="/">
> * * * * <xsl:value-of select="/breakfast_menu/food/name"/>
> * * </xsl:template>
> </xsl:stylesheet>


xsl:value-of creates a text node. and this is how it works in XSLT 1.0
and 2.0 respectively.

If you run the above code with a XSLT 2.0 processor (like, Saxon),
you'll get *all the names* in the output separated by a space
character.

but if you run the above code with a XSLT 1.0 processor, you'll get
only the 1st element of the nodeset (called sequence in 2.0).


Regards,
Mukul
 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      11-30-2008
On Nov 30, 5:52*am, Mukul Gandhi <mukul_gan...@yahoo.com> wrote:
> On Nov 30, 4:28*am, Mike <ampel...@gmail.com> wrote:
>
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform"
> > version="2.0">
> > * * <xsl:template match="/">
> > * * * * <xsl:value-of select="/breakfast_menu/food/name"/>
> > * * </xsl:template>
> > </xsl:stylesheet>

>
> xsl:value-of creates a text node. and this is how it works in XSLT 1.0
> and 2.0 respectively.
>
> If you run the above code with a XSLT 2.0 processor (like, Saxon),
> you'll get *all the names* in the output separated by a space
> character.
>
> but if you run the above code with a XSLT 1.0 processor, you'll get
> only the 1st element of the nodeset (called sequence in 2.0).
>
> Regards,
> Mukul


Thanks,
Mike
 
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
Including XSLT/XML document within a XSLT document dar_imiro@hotmail.com XML 4 12-13-2005 02:26 AM
Multiple XSLT Transforms using a Controller XSLT sneill@mxlogic.com XML 2 10-19-2005 11:00 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
xslt alone or xslt/java for static site? ted XML 1 01-26-2004 10:41 AM
[XSLT]Passing values from Javascript to a XSLT variable Benjamin Hillsley XML 3 09-25-2003 04:50 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57