Subject: [xsl] Selecting nested unique values, Muench approach not a good fit? From: chrislott@xxxxxxxxxxx Date: Wed, 20 Nov 2002 22:30:23 -0500 |
Dear XSL experts, I hope you can please find a minute to look at my question. I think it may be a grouping question, but the Muench-style solutions I found so far have not done the trick (or I misunderstood how to apply them). I would like to select a unique set of node values, basically a list of names, from a hierarchical structure in which the names might be duplicated. Example XML is at the end. To explain, a chunk has a collection of fields. Every field has values. A value may be decorated with one or more names called "seeds". The seeds are just simple strings. I would like to select the unique set of seed names from a chunk. What seems to be complicating this situation is the fact that I may have many <chunk>s in my XML file, and each chunk may re-use the same seed names again. For example, chunk 1 may have fields "one" and "two", with seeds "0" and "1" attached to values in fields one and two. Then chunk 2 might well have seed "0" attached to some values in chunk 2's seeds. I hope I'm making sense; the example below will probably help. I read about and tried the Muench approach using xsl:key, the key function, and generate-id to select the first node that matches a particular key value so as to avoid visiting duplicates. In my case, an input file may have many "seed" nodes, all with the same value. Because they appear in different chunks, I don't think there is any ambiguity -- seed "0" in one chunk seems quite different from seed "0" in another chunk -- but the Muench approach seems to want them to be globally unique (correct me where I'm wrong). In the example below, I'd like to select the distinct seed values for the chunk named 'j'. I.e., I want to write a select statement that yields "0" and "1". A node-set is fine, a list of string would also be fine (but maybe that's my procedural programming background showing through). Once I have that list, I can wallk the fields, picking out values that have the appropriate "seed" decorations without repeats. It seems that if the seed names could be made unique across chunks, the Muench approach might work. I.e., if the first chunk has seed names "chunk1-0", "chunk1-1", etc. and the next chunk has seed names "chunk2-0", "chunk2-1", etc. If this is the only way to solve the problem, I may be forced to go after it that way. Any and all hints will be greatly appreciated. Thanks in advance! chris... p.s. can you blame me for wanting a Perl hash right about now? -- <chunks> <chunk> <name>j</name> <usefields> <field> <name>field3</name> <valids> <validvalue> <value>three</value> <seeds> <seed>0</seed> </seeds> </validvalue> <validvalue> <value>three</value> <seeds> <seed>0</seed> </seeds> </validvalue> <validvalue> <value>drei</value> <seeds> <seed>1</seed> </seeds> </validvalue> </valids> </field> <field> <name>field4</name> <valids> <validvalue> <value>four</value> </validvalue> <validvalue> <value>vier</value> <seeds> <seed>0</seed> <seed>1</seed> </seeds> </validvalue> <validvalue> <value>quatro</value> </validvalue> </valids> </field> </usefields> </chunk> ( followed by another <chunk> with its own fields and seed names, and so on. ) </chunks> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XML translation problem u, Michael Kay | Thread | RE: [xsl] Selecting nested unique v, Conal Tuohy |
[xsl] XML translation problem using, Dineen, Geoffrey | Date | Re: [xsl] XML translation problem u, Bix |
Month |