xsl-list
[Top] [All Lists]

Re: [xsl] processing source XML while inside variable processing - XSLT 1.0

2006-05-10 04:16:30
At 2006-05-10 11:01 +0200, news(_at_)swisslab(_dot_)de wrote:
I've a variable which I process inside a template. While processig this
variable I want to get data from the source XML document, applying
templates.

<xsl:for-each select="$theVariable">
 <!-- some code here -->
  <xsl:apply-template select="aNodeInsideTheSourceDocument" />

 <!-- some more code here -->
</xsl:for-each>

The problem is, that while processing the variable "theVariable" with
"xsl:for-each", the "apply-templates" command searches for
"aNodeInsideTheSourceDocument" inside "theVariable" but not as required
inside the source XML document.

Correct, because you changed your context with the <xsl:for-each>

Is there any way to process the source document whily processing a variable
with XSLT 1.0?

Yes, by putting it into another variable:

<xsl:variable name="sNode" select="aNodeInsideTheSourceDocument"/>

<xsl:for-each select="$theVariable">
 <!-- some code here -->
  <xsl:apply-template select="$sNode" />

 <!-- some more code here -->
</xsl:for-each>

I hope this helps.

. . . . . . . . Ken

--
Registration open for XSLT/XSL-FO training: Wash.,DC 2006-06-12/16
Also for XSLT/XSL-FO training:    Minneapolis, MN 2006-07-31/08-04
Also for XML/XSLT/XSL-FO training:Birmingham,England 2006-05-22/25
Also for XSLT/XSL-FO training:    Copenhagen,Denmark 2006-05-08/11
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [xsl] processing source XML while inside variable processing - XSLT 1.0, G. Ken Holman <=