[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Answers to review questions in "Beginning XSLT": C

Subject: RE: Answers to review questions in "Beginning XSLT": Chapter 5
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Wed, 12 Mar 2003 11:53:09 -0600
xslt compare get difference
Jeni Tennison wrote:

> Sent: Wednesday, March 12, 2003 7:09 AM
> 
> > For now I'm omitting the questions themselves, since I don't yet
> > have explicit permission to copy them. (Jeni, would that be OK?)
> 
> Yes, I'm sure that would be fine. It would also mean that people who
> don't have the book are able to understand what you're answering.

Thanks.  That will be helpful!

> > 1. No nodes match the select pattern, so no templates get applied,
> >    so there is no output for that apply-templates.
> 
> That's correct, though it would be more accurate to say that "no nodes
> get selected by the select expression". Remember that the select
> attribute (on <xsl:apply-templates>, and elsewhere) is for *selecting*
> things with an *expression* and the match attribute (on <xsl:template>
> and elsewhere) is for *matching* things with a *pattern*.

Thanks.  I have to admit the difference between the two is less than
crystal-clear in my mind.  Kay p. 430 and 433 are helpful.

> The wrapping <xsl:if> is actually superfluous. @flag = 'favorite' and
> @flag = 'interesting' obviously cannot be true if there is not flag
> attribute, but it is also the case that @flag != 'favorite' cannot be
> true if there is no flag attribute.

Oh yeah.  :-)  Haven't gotten used to that mental shift yet... that we
are actually making a query on a nodeset, rather than comparing a value
to a value.

> Perhaps you included the <xsl:if>
> so that all the instructions are ignored if the flag attribute doesn't
> exist.

Well, that was part of it too (efficiency in the case of no flag
attribute).

> > 10. ...

> You've answered a lot of this yourself in your follow-up mail. I don't
> think that there's a right answer to this question: it's more a prompt
> to get you to explore the properties of NaN, number(), boolean(),
> string() and comparison operators.

It worked!

> Personally, I usually use:
> 
>   string(number()) != 'NaN'
> 
> because it makes it clear what I'm actually testing:

Good point.

Thanks for the pointers!  This has been helpful.

Lars


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.