Obviously xslt only knows the local tree at the current recursion level.
Is there a way to access the root node of the whole outer tree?
XSLT has full access to teh entire tree (trees in fact) at all times.
<xsl:template match="//myelem[(_at_)name = 'peter']">
you don't want the // there it isn't doing anything useful the
stylesheet would work the same way with
<xsl:template match="myelem[(_at_)name = 'peter']">
<!-- now I want to jump to the node <myelem name="karl"> with the subnode
'tony'
but this doesn't work because this node is outside the context/scope
-->
<xsl:with-param name="nametofind" select="//myelem[(_at_)name =
$nametofind]" />
//myelem will search the whole document for an element of that name, so
unless you have multiple documents (from document() or xx:node-set()
functions) this wil find the element.
If you do have multiple documeents and want to get back to your original
one, put
<xsl:variable name="originaldoc" select="/"/>
at teh top level of your stylesheet (outside any template)
then you can go
<xsl:with-param name="nametofind" select="$originaldoc//myelem[(_at_)name
= $nametofind]" />
Note that // can be very expensive/slow and you probably would get great
efficiency gains by using keys. (butget it working before getting it
optimised)
How do I access from a given subtree the outer whole tree resp. other
nodes?
if it really is a subtree then just using / will work, if it's a
different tree, use a variable holding the original root node, as
above.
David
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--