Quote:
Originally Posted by Martin Honnen
First of all, the xsl:key element does not belong into an xsl:template element. Instead it should be a top level element i.e. a child of the xsl:stylesheet element.
As for your key definition <xsl:key name="by-name" match="Request/*" use="SomeTypeB"/>, what is that supposed to achieve? It matches child elements of 'Request' elements and defines the key value with use="SomeTypeB". In your XML sample that you posted earlier the children of the 'Request' element do not have any child named 'SomeTypeB' so that key does not make any sense to me. You would need to have e.g.
Code:
<Request>
<Foo>
<SomeTypeB>whatever</SomeTypeB>
</Foo>
</Request>
for that key to make any sense as then for the 'Foo' child element of the 'Request' element the string value of the 'SomeType' child element would be the key value.
|
I recognize now that it's wrong since especially you mentioened that the generate-id part is central to Meunchin grouping which I never had. I was also confused with the last part of the key statement .. i.e. the SomeTypeB .. in theory what I wanted to do was to create 2 keys for the <request> node:
1) 1 key containing all the SomeTypeB nodes
2) 1 key containing all other nodes in request.
I would then process each key with a for-each statment. I wanted to be able to just create a template to handle all of this. The actual key can be defined at the top I tried that too. But I always felt that my key definition was not correct.
How would I define a key which would create a set of nodes for SomeTypeB and another key (I was thinking a negation of the other key) for all non-SomeTypeB nodes and then process them using-for each statement?
Since the code I inherited calls templates explicitly it does not have any apply-templetes statements which I'm still confused about their order of execution. Calling templates explicitly is easier for me to understand as it's like Java methodology which I'm much more comfortable with.
Again, I appreciate your quick responses and great help. You're helping me to really understand the workings of XSLT
J