|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: sliding window of depth 2
I do not provide a solution, but let me attract your attention to the
following point:
With following input: <doc><node id="1"><book id="2"/><book id="3"/></node><node id="4"><book id="5"/></node></doc> And provided that start=3 and qty=2, what would you expect your output to be? From your description, you expect to apply-templates to the nodes with id 3 and 4. I believe you do not really want that, do you? I imagine that you want that with start=2 and qty=2 you get two tables with one row each. That is, you are not counting elements at two levels, but only at one level, which happens to be the second. Apart from that, you need grouping. into tables, and that is another matter. So the nodes you are selecting on are: node/book[position() >= $start and position() < ($qty + $start)] I would group using the first ones on the group: node/book[position() >= $start and position() < ($qty + $start)][not(preceding-sibling::book)] And then, process all the groups in two phases, all but the last, and the last. The last is different because not all following siblings of the first book element are to be in the output. So we will need to somehow calculate how many of them to output. I would bet for something like: <xsl:apply-templates select="node/book[position() >= $start and position() < ($qty + $start)][not(preceding-sibling::book)][position() < last()]" mode="group" /> <xsl:apply-templates select="node/book[position() >= $start and position() < ($qty + $start)][not(preceding-sibling::book)][last()]" mode="lastgroup"> <xsl:with-param name="remain" select="$qty - count(node/book[position() >= $start and position() < ($qty + $start)][not(preceding-sibling::book)][position() < last()]) - count(node/book[position() >= $start and position() < ($qty + $start)][not(preceding-sibling::book)][position() < last()]/following-sibling::book)" /> </xsl:apply-templates>
<xsl:template match="book" mode="lastgroup"> <xsl:param name="remain" select="1" /> <table> <xsl:apply-templates select="." /> <xsl:apply-templates select="following-sibling::book[position() < $remain" /> </table> </xsl:template> None of these lines of code are tested. I hope you get the idea, and especially that the idea is good, which I am not sure at all... Antonio Fiol Américo Albuquerque wrote: Hi! 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








