[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: for-each question
Subject: Re: for-each question
From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Tue, 13 Aug 2002 17:38:26 +0000
|
Mike,
The for each is not for-each as in Xsl:for-each.What i meant by the pseudo
code is ..
"The books are: " will be printed as many times as the processor encounters
a book element.
I was emphasising the "effect".Sorry for the word "equivalent" there..
and Sorry for any confusions..
and yes i am with you in saying "xsl:apply-templates
causes nodes to be selected and processed."
Regds
Vasu
From: Mike Brown <mike@xxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: for-each question
Date: Tue, 13 Aug 2002 11:04:06 -0600 (MDT)
Vasu Chakkera wrote:
> The problem is your template matches each book element.
> this is equivalent to a pseudo code
> for each book {
> The books are:
> Book-Name
> }
No it is not. "for each" is an instruction, an operation.
A template is a declaration, a definition.
A lot of XSLT newbies tend to be under the mistaken impression that
xsl:template causes something to happen. Your pseudocode reinforces this
confusion. They need to be told that it is actually the xsl:apply-templates
that causes nodes to be selected and processed.
I would tell him that his template was equivalent to defining
the following functions (Python style):
def handleAnyNode(node,result): # xsl:template
if node.type == ELEMENT and node.name == 'book': # match="book"
handleBookNode(node,result)
def handleBookNode(node,result):
frag = ResultTreeFragment()
frag.append(TextNode('The Books Are:')) # The Books Are:
frag.child[0].append(Element('I')) # <I>...</I>
frag.child[1].append(TextNode(currentNodeName())) # xsl:value-of
result.append(frag)
And that it was his <xsl:apply-templates select="book"> that was equivalent
to
calling
for node in getAllNodesMatchingXpathExpression('child::book'):
handleAnyNode(node,mainOutput)
- Mike
____________________________________________________________________________
mike j. brown | xml/xslt: http://skew.org/xml/
denver/boulder, colorado, usa | resume: http://skew.org/~mike/resume/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|