A
Andy Chambers
Hi,
I've stumbled across a problem for which I can't find a nice solution
(although it has cleared up a misunderstanding I had about keys).
I've setup keys to access ItemDefs in my document like so...
<xsl:key name="keyItems"
match="odm:ItemDef"
use="concat(ancestor:
dm:Study/@OID,
ancestor:
dm:MetaDataVersion/@OID, @OID)"/>
Subsequently, I need to build a nodelist of strings with which I can
use to access nodes from this key
<xsl:variable name="xrtFormItems">
<xsl:for-each select="$xnlItemGroups">
<xsl:variable name="xndItemGroupDef"
select="key('keyItemGroups',
concat(ancestor:
dm:Study/@OID,
ancestor:
dm:MetaDataVersion/
@OID,
@ItemGroupOID))"/>
<xsl:for-each select="$xndItemGroupDef/odm:ItemRef">
<key>
<xsl:value-of select="concat(ancestor:
dm:Study/
@OID,
ancestor:
dm:MetaDataVersion/@OID,
@ItemOID)"/>
</key>
</xsl:for-each>
</xsl:for-each>
</xsl:variable>
However, if I try to use the values stored in this variable to access
ItemDefs from my key....
<xsl:for-each select="ex:node-set($xrtFormItems)/*">
<xsl:apply-templates select="key('keyItems', .)"/>
</xsl:for-each>
....the key doesn't work. I thought that keys were basically a
hashtable that stored the specified nodes with the use attribute
representing the key. The point being that they were created at the
start and didn't change throughout the process. It seems that doing a
for-each on a node-set returned by some extension function can indeed
change the contents of your keys. Has anyone else bumped into this?
Is it a FAQ? What's the workaround?
I've stumbled across a problem for which I can't find a nice solution
(although it has cleared up a misunderstanding I had about keys).
I've setup keys to access ItemDefs in my document like so...
<xsl:key name="keyItems"
match="odm:ItemDef"
use="concat(ancestor:
ancestor:
Subsequently, I need to build a nodelist of strings with which I can
use to access nodes from this key
<xsl:variable name="xrtFormItems">
<xsl:for-each select="$xnlItemGroups">
<xsl:variable name="xndItemGroupDef"
select="key('keyItemGroups',
concat(ancestor:
ancestor:
@OID,
@ItemGroupOID))"/>
<xsl:for-each select="$xndItemGroupDef/odm:ItemRef">
<key>
<xsl:value-of select="concat(ancestor:
@OID,
ancestor:
@ItemOID)"/>
</key>
</xsl:for-each>
</xsl:for-each>
</xsl:variable>
However, if I try to use the values stored in this variable to access
ItemDefs from my key....
<xsl:for-each select="ex:node-set($xrtFormItems)/*">
<xsl:apply-templates select="key('keyItems', .)"/>
</xsl:for-each>
....the key doesn't work. I thought that keys were basically a
hashtable that stored the specified nodes with the use attribute
representing the key. The point being that they were created at the
start and didn't change throughout the process. It seems that doing a
for-each on a node-set returned by some extension function can indeed
change the contents of your keys. Has anyone else bumped into this?
Is it a FAQ? What's the workaround?