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

RE: Error xsl:param may not be used here

Subject: RE: Error xsl:param may not be used here
From: "Andrew Welch" <awelch@xxxxxxxxxxxxxxx>
Date: Mon, 14 Oct 2002 10:26:02 +0100
xsl choose param
><xsl:when test="not(string-length($graph/@type) = 0)">

Here you are treating the variable $graph as a nodeset, when it is only
a string.


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

You can just drop $graph here and use @type on its own, as the current
node will always be '.'

I understand this is a fictional example, but wouldnt you just need:

 <xsl:template name="drawGraph">
   <xsl:choose>
    <xsl:when test="string-length(@type)">
     <xsl:value-of select="@type" />
    </xsl:when>
    <xsl:otherwise>x-y</xsl:otherwise>
   </xsl:choose>
 </xsl:template>

This will produce the same results as the above template.

cheers
andrew

> -----Original Message-----
> From: Ryan Beesley [mailto:RBeesley@xxxxxxxxxxxx]
> Sent: 14 October 2002 09:42
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Error xsl:param may not be used here
> 
> 
> 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 publically 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 probibly 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@xxxxxxxxxxxx
> Founder, Atum Innovations
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.394 / Virus Database: 224 - Release Date: 03/10/2002
>  
> 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.394 / Virus Database: 224 - Release Date: 03/10/2002
 

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.