You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Philipp Strazny <ph...@thegeogroup.com> on 2004/04/01 00:35:30 UTC

using param in match expression

Since I'm new to XSLT, I hesitate to submit this as a bug:

I'm trying to supply a location path dynamically to a stylesheet, to 
process only a fragment of the source xml. I pull the path in as a 
parameter, and I can successfully reference this parameter in the select 
of an apply-templates construct:

...
<xsl:param name="startpath" select="/" />   #defined as a global
...
   <xsl:template match="/">
     ...
         <xsl:apply-templates select="$startpath" />
     ...
   </xsl:template>

However, if I try to go straight to the fragment, as in
...
    <xsl:template match="$startpath">...
...
I get the following error:

XPathParserException: A node test was expected
pattern = '$startpath' Remaining tokens:  ('$' 'startpath')

If I understand this correctly, I can reference variables/parameters in 
select contexts, but not in match contexts? It took me forever to figure 
this out, since the XSLT specification doesn't seem to say that 
variables can only be referenced in certain places. Can anyone tell me 
whether this is a bug of Xalan-C or a feature of XSLT?

Best,
Philipp


-- 
Philipp Strazny            Tel.: (608) 230-1000
Localization Specialist    Fax:  (608) 230-1010
The Geo Group              philipp@thegeogroup.com
www.thegeogroup.com



Re: using param in match expression

Posted by da...@us.ibm.com.



Hi Phillip,

General XSLT questions are best posted on the Mulberry Technologies XSL
list, where there are numerous parties that can answer such questions.  You
might also try Dave Pawson's XSL FAQ:

   http://www.dpawson.co.uk/xsl/xslfaq.html

If you look at the grammar for a match pattern, you will see that variables
are not allowed:

   http://www.w3.org/TR/xslt#NT-Pattern

Dave



|---------+--------------------------->
|         |           Philipp Strazny |
|         |           <philipp@thegeog|
|         |           roup.com>       |
|         |                           |
|         |           03/31/2004 02:35|
|         |           PM              |
|         |           Please respond  |
|         |           to xalan-c-users|
|---------+--------------------------->
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                                                  |
  |        To:      xalan-c-users@xml.apache.org                                                                                                     |
  |        cc:      (bcc: David N Bertoni/Cambridge/IBM)                                                                                             |
  |        Subject: using param in match expression                                                                                                  |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|



Since I'm new to XSLT, I hesitate to submit this as a bug:

I'm trying to supply a location path dynamically to a stylesheet, to
process only a fragment of the source xml. I pull the path in as a
parameter, and I can successfully reference this parameter in the select
of an apply-templates construct:

...
<xsl:param name="startpath" select="/" />   #defined as a global
...
   <xsl:template match="/">
     ...
         <xsl:apply-templates select="$startpath" />
     ...
   </xsl:template>

However, if I try to go straight to the fragment, as in
...
    <xsl:template match="$startpath">...
...
I get the following error:

XPathParserException: A node test was expected
pattern = '$startpath' Remaining tokens:  ('$' 'startpath')

If I understand this correctly, I can reference variables/parameters in
select contexts, but not in match contexts? It took me forever to figure
this out, since the XSLT specification doesn't seem to say that
variables can only be referenced in certain places. Can anyone tell me
whether this is a bug of Xalan-C or a feature of XSLT?

Best,
Philipp


--
Philipp Strazny            Tel.: (608) 230-1000
Localization Specialist    Fax:  (608) 230-1010
The Geo Group              philipp@thegeogroup.com
www.thegeogroup.com