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

RE: XSLT 2.0 and external parameters: a string -> xsd:

Subject: RE: XSLT 2.0 and external parameters: a string -> xsd:integer. How?
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 20 May 2003 20:53:34 +0100
xslt external parameters
> I guess this is another angle on the typing questions that have been 
> floating around the list recently.
> Code that worked with Saxon 7.4 (and that I think would work 
> in XSLT 1.0) 
> is now broken with Saxon 7.5.
> How can I supply an external parameter to a Saxon 7.5 
> stylesheet which is 
> $number and has an integer value and get the XSLT processor 
> to treat it as 
> an xsd:integer. Well, I don't particularly want the parameter to be 
> xsd:integer but I assume I won't be able to do anything 
> numeric with it, 
> unless I make it explicitly numeric.

If you are passing parameters from a JAXP application, you can pass a
Java Integer.

If you want to do it from the command line, you can only pass strings;
you will have to convert the string to an integer within your own code
(this is exactly the same as writing a Java application that reads
arguments from the command line - they arrive as strings).
> If I try to ignore types altogether Saxon 7.5 complains, not 
> surprisingly, 
> that it cannot compare xsd:string to xsd:integer. If there is 
> a way to 
> write a type-agnostic stylesheet to accept a parameter that 
> is intended to 
> be numeric it isn't obvious to me at the moment.


<xsl:param name="p" as="xs:string"/>
<xsl:variable name="p-as-int" as="xs:integer" select="xs:integer($p)"/>

> So I made the input parameter xsd:string and created a new numeric 
> parameter using the xsd:integer() constructor function. Same 
> error message.
> Then I tried making the input parameter xdt:untypedAtomic with the 
> xsd:integer() constructor function to create the second 
> parameter.  Same 
> error message.
> Then I tried adding an as="xsd:integer". Same error message.

I'm afraid it's difficult to tell from this description exactly what you
did, and exactly what messages you got.
> The Saxon 7.5 documentation indicates that "most" such functions are 
> supported. Is this one unsupported or am I missing a basic 
> trick somewhere?

I think you missed a trick somewhere, but from the description I can't
tell where.

Michael Kay

 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.