ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
Re: [xsl] Error xsl:param may not be used here
by Vasu Chakkera other posts by this author
Oct 14 2002 9:08AM messages near this date
Re: [xsl] Error xsl:param may not be used here | Re: [xsl] Error xsl:param may not be used here
Ryan,
The problem is that your <xsl:param>  is wrongly placed.<xsl:param> is a top 
level element ie, child of <xsl:stylesheet>  element or if it is in a 
template then it must be the immediate child of the <xsl:template>  element. 
so in your case, because you have an <xsl:variable>  element before the 
<xsl:param>  element, its reporting the error message.


> From: "Ryan Beesley" <RBeesley@[...].org>
> Reply-To: xsl-list@[...].com
> To: <XSL-List@[...].com>
> Subject: [xsl] Error xsl:param may not be used here
> Date: Mon, 14 Oct 2002 03:46:46 -0500
> 
> Repost:  Sorry, I posted the first message as a reply...
> 
> I know that this error has been addressed on this list before, but I don't
> think it has been answered in this context.
> 
> I have been working on a set of svg graphing (xslt) utilities that I'd like
> to make publicly available once my senior design project is complete, but
> I've run into a slight snag.  I wanted to be able to customize different
> parameters in multiple ways.  Below is listed a small segment of my xml and
> xslt.
> 
> ---- graph.xml ----
> <?xml version="1.0" encoding="UTF-8"?>
> <graph type="pie">
>   <!-- Graph data goes here -->
> </graph>
> 
> ---- graph.xslt ----
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
> 
>   <xsl:template match="graph">
>    <xsl:call-template name="drawGraph">
>     <!-- Optional parameters to alter graph -->
>     <xsl:with-param name="type" select="'bar'"/>
>    </xsl:call-template>
>   </xsl:template>
> 
>   <xsl:template name="drawGraph">
>    <xsl:variable name="graph" select="." />
>    <xsl:param name="type">
>     <xsl:choose>
>      <xsl:when test="not(string-length($graph/@type) = 0)">
>       <xsl:value-of select="$graph/@type" />
>      </xsl:when>
>      <xsl:otherwise>x-y</xsl:otherwise>
>     </xsl:choose>
>    </xsl:param>
>    <type>
>     <xsl:value-of select="$type"/>
>    </type>
>   </xsl:template>
> 
> </xsl:stylesheet>
> 
> ---- output.xml ----
> <?xml version="1.0" encoding="UTF-8"?>
> <type>bar</type>
> 
> Although you would probably never include a parameter in both the calling
> template and the xml data, I have included both to demonstrate the use.  
> The
> passed template param should win however.  When evaluating this with XML
> Spy, in debug mode, it works exactly as I want it too.  I can change the
> value of @type either while calling the template, or directly from the xml
> data.  If neither parameter was provided, the template assumes a default.
> 
> Xalan and MSXML fail completely.  If I place my params inside the choose,
> then they aren't recognized, as should be, but it doesn't seem to like my
> nested choose for the param either.  I suspect that this structure is the
> source of my error: xsl:param may not be used here.
> 
> If anyone has suggestions as to how I can make this work, I'm always eager
> to learn.  I believe I could use a variable to make this work, but then I
> wouldn't be able to change it from the template, right?
> 
> Ryan Beesley
> Rbeesley@[...].org
> Founder, Atum Innovations
> 
> 
> 
>   XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
Thread:
Vasu Chakkera
Ryan Beesley

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved