Re: [xsl] Accessing input document from extension function loop (XSL 1.0)

Subject: Re: [xsl] Accessing input document from extension function loop (XSL 1.0)
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Fri, 15 Feb 2008 13:41:50 +0100
Martin Honnen schrieb:
Michael Ludwig wrote:

From inside the xsl:for-each loop using the content generated by
the extension function, I don't seem to be able to access my original
input document. Am I mistaken here or is this assumption correct?

If it is correct, why is this so?

And is there a remedy?

You could use a global variable <xsl:variable name="main-doc" select="/"/> then you can access that variable as needed.

Thanks, Michael and Martin, your answers explained and solved the problem.

I also found the solution in the archive:

http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/200310/msg00046.html

Michael

PS: The solved example goes:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
 xmlns:php="http://php.net/xsl"; exclude-result-prefixes="php"
 xmlns:str="http://exslt.org/strings"; extension-element-prefixes="str"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="xml" indent="yes"/>

 <xsl:template match="Channels">
  <Urmel>
   <xsl:variable name="my-pointer" select="/Channels/Ch"/>
   <U4>
    <xsl:for-each select="str:split('ard zdf')">
     <T3><xsl:value-of select="$my-pointer[ @ID = current() ]"/></T3>
    </xsl:for-each>
   </U4>
   <!-- <U5>
    <xsl:for-each select="php:function('gen_nodes', 'ard zdf')/*">
     <T3><xsl:value-of select="$my-pointer[ @ID = current() ]"/></T3>
    </xsl:for-each>
   </U5> -->
  </Urmel>
 </xsl:template>

</xsl:stylesheet>

Current Thread