[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Stange behavior with parameters, can somebody expl

Subject: Re: Stange behavior with parameters, can somebody explain?
From: Gunther Schadow <gunther@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 17 Jan 2002 13:37:52 -0500
7960 iso 8859 1
Oops, first the message was rejected and now it went through
twice. Sorry for that.

Thanks so much for the hint. Heck, I was fiddling with the
default rule for 'node()' but forgot about the root node.
This turns out to be a mistake similarly easy to make and
obscure to discover as the famous if(a = 0) fallacy in C.

Last night I rewrote all my parameter passing to use a
synthesized node structure only to loose sleep over it
and now turn it all back. Ah well. But I'm happy it was
my mistake.

Still, XSLT is great, I love it more each day.


Gunther Schadow wrote:

Help! I'm ripping my heair out on this one. Please explain
why the effect of with-param in apply-templates select='expr'
depends on whether expr is an xpath selector on the current
document or a synthesized node-set.

This is my XML file:


And this is the common part of an XSLT:

<!-- For MSXSL use this instead

<xsl:output method='xml' encoding="iso-8859-1" indent='yes'/>

<xsl:template match="ROOT">
    <xsl:apply-templates select='child::node()[1]'/>

<xsl:template match="BAR">
  <xsl:param name='P'/>
  <BAR P='{$P}'/>

<!-- variant here -->


Now I show you two variants of templates to deal with the FOO element. The first one uses the xpath selector:

<xsl:template match="FOO">
  <xsl:apply-templates select='following-sibling::node()[1]'>
    <xsl:with-param name='P' select="'V'"/>

when I run the transform, the result is:

<?xml version="1.0" encoding="iso-8859-1"?>
   <BAR P="V"/>

as it should be. However, when I use this variant:

<xsl:template match="FOO">
  <xsl:variable name='SYNTH'>
  <xsl:apply-templates select='exsl:node-set($SYNTH)'>
    <xsl:with-param name='P' select="'V'"/>

the result is

<?xml version="1.0" encoding="iso-8859-1"?>
   <BAR P=""/>

as you see, here the parameter P <= V was not carried into the
applied templates. Why is that?

I tried with both saxon and msxml and they both do the same

Whatever it is, it is very obscure and makes my life very

Of course you don't see the use case from this dummed down
example. My use case is string parsing for 'up-translation'
where I match a head of a string then clip off the head
and apply the templates on the rest of the text node. I
cannot pass any parameters through this kind of process,


PS: workaround seems to be to wrap the rest of the text node in an element with parameters as attributes or something. Argh!

Gunther Schadow, M.D., Ph.D.                    gschadow@xxxxxxxxxxxxxxx
Medical Information Scientist      Regenstrief Institute for Health Care
Adjunct Assistant Professor        Indiana University School of Medicine
tel:1(317)630-7960                         http://aurora.regenstrief.org

XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.