Subject: RE: [xsl] Answers to review questions in "Beginning XSLT": Chapter 5 From: "Lars Huttar" <lars_huttar@xxxxxxx> Date: Wed, 12 Mar 2003 11:53:09 -0600 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Answers to review questio, Jeni Tennison | Thread | RE: [xsl] Answers to review questio, Lars Huttar |
RE: [xsl] dynamic XPath?, Passin, Tom | Date | RE: [xsl] XSL and javascript, Mac Martine |
Month |