Help with xslt

Discussion in 'XML' started by Mike, Nov 29, 2008.

  1. Mike

    Mike Guest

    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 xmlns:xsl="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>
    Mike, Nov 29, 2008
    #1
    1. Advertising

  2. Mike

    Mukul Gandhi Guest

    On Nov 30, 4:28 am, Mike <> wrote:
    > <?xml version="1.0" encoding="UTF-8"?>
    > <xsl:stylesheet xmlns:xsl="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
    Mukul Gandhi, Nov 30, 2008
    #2
    1. Advertising

  3. Mike

    Mike Guest

    On Nov 30, 5:52 am, Mukul Gandhi <> wrote:
    > On Nov 30, 4:28 am, Mike <> wrote:
    >
    > > <?xml version="1.0" encoding="UTF-8"?>
    > > <xsl:stylesheet xmlns:xsl="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
    Mike, Nov 30, 2008
    #3
    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. Stylus Studio
    Replies:
    0
    Views:
    637
    Stylus Studio
    Aug 3, 2004
  2. Benjamin Hillsley
    Replies:
    3
    Views:
    1,659
    Dimitre Novatchev
    Sep 25, 2003
  3. ted
    Replies:
    1
    Views:
    611
    Laurens
    Jan 26, 2004
  4. Replies:
    2
    Views:
    708
    Henry S. Thompson
    Oct 19, 2005
  5. Replies:
    4
    Views:
    654
Loading...

Share This Page