[xsl] how to keep context when copying

Subject: [xsl] how to keep context when copying
From: Andy Chambers <achambers.home@xxxxxxxxxxxxxx>
Date: Tue, 18 Aug 2009 14:52:03 +0100
Hey All,

Is there a way of keeping the context information when you copy a
node?  Here's my use-case....

I have a document that has "refs" and "defs" and I'd like to write a
function that returns a "def"
node when you pass it a "ref".

I've got this working fine using keys to lookup the defs.  The
fdx:GetDef function basically boils
down to the following template (XSLT 2)....(it's actually a little
more complicated because depending
on the type of the "ref", it has to go lookup a different key)

<xsl:function name="fdx:GetDef">
  <xsl:param name="ref"/>
  <xsl:copy-of select="key('keyItems', $ref/@OID)"/>
</xsl:function>

My problem is that the nodes returned by this function lack ancestor
info that would be useful
in downstream processing of the node.  Is there a way that I can
rewrite the function to return
a node that allows me to get at the node's ancestors for example.

Cheers,
Andy

Current Thread