|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl:variable
> After when we reach the pb element, I print the
> content of this global variable. I empty the content
> of the variable, and again back to the first step.
You can't do that as XSL variables do not change their values once
bound. I have already posted the solution to the problem that you
originally posed (selecting as far as the first element) but you just
changed the problem to selecting things between multiple pb
elements
In which case you want something like
<div type="chapter">
1<!-- Other tags -->
<pb/>
2<!-- Other tags -->
<pb/>
3<!-- Other tags -->
<pb/>
4<!-- Other tags -->
<pb/>
5
</div>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="div[@type='chapter']">
<xxxx>
<xsl:apply-templates select="node()[not(preceding-sibling::pb)]"/>
</xxxx>
<xsl:for-each select="pb">
<xxxx>
<xsl:variable name="x" select="1+count(preceding-sibling::pb)"/>
<xsl:apply-templates select="following-sibling::node()[count(preceding-sibling::pb)=$x]"/>
</xxxx>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
bash-2.01$ xt div.xml div.xsl
<?xml version="1.0" encoding="utf-8"?>
<xxxx>
1
</xxxx>
<xxxx>
2
</xxxx>
<xxxx>
3
</xxxx>
<xxxx>
4
</xxxx>
<xxxx>
5
</xxxx>
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
|

Cart








