Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: is this stylesheet valid?

From: David Carlisle <david-news@---------.-----.--.-->
To: NULL
Date: 6/1/2007 10:01:00 PM

Andy Fish wrote:
> hi,
> 
> i'm porting some xsl code from .net 1.1 to 2.0 and I have come across a 
> transform which works in .net 1.1 and works in mxsml but does not work in 
> .net 2.0. the stylesheet is this:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>  <xsl:template match="foo">
>   <xsl:param name="param1"/>
>   <xsl:value-of select="$param1/*"/>
>   <xsl:apply-templates/>
>  </xsl:template>
> </xsl:stylesheet>
> 
> and the input file is simply
> 
> <foo />
> 
> so $param1 has no value (empty string? empty node set? I'm not sure)
> 
> with .net 2.0 I get an error message Unhandled Exception: 
> System.Xml.XPath.XPathException: Expression must evaluate to a node-set. I'm 
> guessing this is because the default parameter value is an empty string.
> 
> in the real stylesheet, the parameter (if it is passed in) will be a node 
> set. so to make sure I don't evaluate an illegal expression, I need to be 
> able to tell whether the parameter value is an empty string (i.e. default) 
> or a node set. how can I achieve this?
> 
> Andy
> 
> 


rather than have it default to an empty string, and then having to test 
for that to avoid using the variable in path expressions, it's usually 
simpler just to make it default to an empty node set, add
<xsl:param name="param1" select="/.."/>

David


-- 
http://dpcarlisle.blogspot.com


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent