Subject: Re: Side-effects, state, internal references From: Norman Walsh <ndw@xxxxxxxxxx> Date: Thu, 16 Apr 1998 16:25:44 -0400 |
/ Jonathan Marsh <jmarsh@xxxxxxxxxxxxx> was heard to say: | > -----Original Message----- | > From: Norman Walsh [mailto:ndw@xxxxxxxxxx] | > Sent: Thursday, April 16, 1998 11:47 AM | > | One solution might be to build counting behavior directly into the flow | > | objects, such as the HTML <OL> provides. A more general solution would | be | > | for XSL to provide counting functions relative to the output tree, e.g. | > | flowObjectChildNumber(). | > | > Those are both possibilities, but it's also possible to simply | > calculate the number correctly from the source grove. After | > all, if your stylesheet is doing the reordering, it knows what | > reordering it's doing, right? ;-) | I challenge you (in the friendliest way possible :-)) to solve the problem | originally solved in this thread using source-level numbering mechanisms. I | feel confident that while it is possible, it will be pretty involved, | probably requiring a lot of tree walking from script. It's difficult to solve complex problems with XSL right now because most of the powerful features aren't fully specified (buitin functions, node list manipulation, etc.). | Or alternatively how would you do this correctly? Given | <A> | <B level="1">first level 1 B</B> | <B level="2">first level 2 B</B> | <B level="1">second level 1 B</B> | <B level="1">third level 1 B</B> | <B level="2">second level 2 B</B> | </A> | | I would like this output (the numbers are generated): | 1) first level 1 B | 2) second level 1 B | 3) third level 1 B | | In other words, I am filtering out level="2". This is intended to be a | simple example that shows the general problem of combining numbering with | filtering, reordering or sorting, all of which I expect to be common (nearly | ubiquitous) operations on XML data, and have useful application to XML | documents as well. It would be very hard to do that with XSL as it is defined in the submission. In DSSSL, I'd build a node-list of B elements and filter out all the ones that weren't at level 1. In XSL terms: <select-elements from="chilren"> <target-element type="B"> <attribute name="level" value="1"/> </target-element> </select-elements> Then I'd process each child of the list, counting as I went. That's the part I can't yet do in XSL. The problem with select-elements is that in DSSSL terms it is really (process-node-list (select-elements ...)) You can't actually grab the node-list it returns and do something with it. | Have you come across this situation in your stylesheets? I.e. combining | numbering with filtering, reordering or sorting? Yes, but the problem is that I've always solved it by building a node-list containing the reordered, filered elements that I want to print and then counting them as I output them. (Which is not the same as counting them _after_ they've been output ;-). --norm XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Side-effects, state, internal r, Jonathan Marsh | Thread | Attributes of the flow object eleme, Andrew n marshall |
RE: Side-effects, state, internal r, Jonathan Marsh | Date | Re: Side-effects, state, internal r, Paul Prescod |
Month |