p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

xslt thread: // behavior


Message #1 by "Michiel van Otegem \(lists ONLY\)" <michiel_lists@a...> on Wed, 25 Jul 2001 17:58:14 +0200
yep... I completely forgot about precdence. I was aiming at a simple sample
for a course, and tha didn't work... gave me and excuse to discuss
precedence :)


---
Michiel van Otegem
ASPNL.com    - ASP/ASP.NET/XML Teacher
ASPLists.com - Moderator

http://www.aspnl.com
http://www.aspalliance.com/michiel
off-list email: michiel@a...
---
----- Original Message -----
From: "Kipp Howard" <khoward@c...>
To: "P2P_XSLT" <xslt@p...>
Sent: Wednesday, July 25, 2001 6:45 PM
Subject: [xslt] RE: // behavior


> I'll take a stab at this:
>
> Michiel van Otegem (lists ONLY) [mailto:michiel_lists@a...] wrote:
> > Can somebody please explain why
> > <xsl:value-of select="//dish[6]" /> yields nothing
>
> Select all dish elements that are the 6th child of its parent.  (i.e.,
> nothing)
>
> > <xsl:value-of select="//dish[5]" /> yields "Ribs and Wings"
>
> Select all dish elements that are the 5th child of its parent. (Only one
> dish element meets this criteria; "Ribs and Wings")
>
> > and
> > <xsl:value-of select="//dish[1]" /> yields "Crab Cakes" given
>
> Select all dish elements that are the first child of its parent.  This
> should return a node-set with 3 nodes but since the XPath statement is
used
> within an <xsl:value-of>, only the first node is returned (i.e., "Crab
> Cakes").
>
> > the XML document below?
> > dish[1] seems fine. dish[5] I would expect "Grilled Salmon",
> > and dish[6] I would expect "Seafood Pasta". I've trief with
> > Saxon, xt and MSXSL, so it's not a bug (unless all three are
> > going wrong :) ).
>
> I believe that you can use the following to get what you expected (note
the
> parenthesis):
>
> <xsl:value-of select="(//dish)[6]" />
> <xsl:value-of select="(//dish)[5]" />
> <xsl:value-of select="(//dish)[1]" />
>
> > <?xml version="1.0" encoding="UTF-8"?>
> > <menu>
> >   <appetizers title="Work up an Appetite">
> >     <dish id="1" price="8.95">Crab Cakes</dish>
> >     <dish id="2" price="9.95">Jumbo Prawns</dish>
> >     <dish id="3" price="10.95">Smoked Salmon and Avocado
> > Quesadilla</dish>
> >     <dish id="4" price="6.95">Ceasar Salad</dish>
> >   </appetizers>
> >   <entrees title="Chow Time!">
> >     <dish id="5" price="19.95">Grilled Salmon</dish>
> >     <dish id="6" price="17.95">Seafood Pasta</dish>
> >     <dish id="7" price="16.95">Linguini al Pesto</dish>
> >     <dish id="8" price="18.95">Rack of Lamb</dish>
> >     <dish id="9" price="16.95">Ribs and Wings</dish>
> >   </entrees>
> >   <desserts title="To Top It Off">
> >     <dish id="10" price="6.95">Dame Blanche</dish>
> >     <dish id="11" price="5.95">Chocolat Mousse</dish>
> >     <dish id="12" price="6.95">Banana Split</dish>
> >   </desserts>
> > </menu>
>
>
> --
> Kipp E. Howard - Sr. Software Engineer @ CourtLink


  Return to Index