Subject: Re: [xsl] XSL questions From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 1 Jun 2006 17:02:29 +0100 |
> 1) how to embed html tags in a XML which will be processed by XSL? XSLT deals with elements (a parsed node tree) rather than tags, but you just generate those nodes by putting the tags as literal result elements in your stylesheet, they have to be well formed xml though, so <br>/> not <br> <xsl:template match="title"> <h1>....</h1> ... will make an h1 element. > 2) Counter inside of xsl:for-each > > With the xsl:choose tag inside of xsl:for-each tag, I need to count the number of nodes met the condition. How to set up the counter? > The number of nodes in the node set that xsl:for-each is iterating over is available as the function last(). > 3) Flag inside of xsl:for-each > > With the xsl:if tag inside of xsl:for-each tag, I need to know whether > a node met the condition by the end of the loop. How to set up the > flag variable? You don't need a variable just select the nodes that meet the condition select="...[condition]" if there are no nodes that meet the condition then the node set will be empty and so test as false. You seem to be thinking procedurally an thinking that the for-each will be executed in a certain order, that isn't the case the code is executed for each item selected but may be in any order, or in particular in parallel. The results of each iteration are merged in a specified order but that does not imply an execution order, so you can't make the processing of one item in the sequence depend on the result of processing a different one. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSL questions, Wei Wei | Thread | RE: [xsl] XSL questions, Rick Roen |
[xsl] Re: xsl-list Digest 1 Jun 200, Chad Chelius | Date | Re: [xsl] Re: xsl-list Digest 1 Jun, David Carlisle |
Month |