Nesting of xsl:key() within xsl:key() & combining results of xsl:key()

569 views Asked by At

I have 2 unrelated questions. I need to do a grouping of data using XSLT. I need this to function like how a nested IF within an IF would function. After which, I need to group the data so that I can split it into multiple files according to the Group condition.

Using XSLT Version 1.0 :

Q1) How do you nest a key() within another key() (i.e. Use the result nodes returned from the first key() as current node-list to search for 2nd key() condition to group my data)?

Q2) Can I combine the results of 2 key() functions? Say, I want to execute code for all nodes with Key values of "A" and "B".

Does anyone know how to solve Q1 and Q2?

Appreciate your help very much! I hope the questions are clear enough. Let me know if you need examples of input and output.

Regards, Melita.

1

There are 1 answers

0
Jonathan B On

On Q2, did you mean "values of 'A' OR 'B'"? The key for an element has only one value.

<xsl:for-each select="key('myKey', 'A') | key('myKey', 'B')">
  ...
</xsl:for-each>