|
Subject: Re: [xsl] Re: The Perils of Sudden Type-Safety in XSLT 2.0 From: "Kurt Cagle" <kurt@xxxxxxxxxxxxx> Date: Thu, 27 Feb 2003 00:42:06 -0800 |
I think this discussion misses the point. Changing the version number to
allow/disallow type is at best a kludge. Personally, I think that maybe a
type-safety attribute sitting on the <xsl:stylesheet> node would do the
trick. This would instruct the processor to perform type-safety checking if
enabled, and would turn that feature off if not. This would mean that
non-type-safe code would be less safe but probably more efficient. As
type-safety is pretty much a concession to Microsoft anyway, it seems to me
reasonable to make this a flag. Yes, it makes more work for the
implementation coders ... but so what. I've worked with the type-safe mode
now for a couple of weeks, and frankly, its a pain in the butt that lends
very little real benefit for a lot more work.
-- Kurt
----- Original Message -----
From: "Charles White" <chuck@xxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, February 25, 2003 1:46 PM
Subject: Re: [xsl] Re: The Perils of Sudden Type-Safety in XSLT 2.0
> ----- Original Message -----
> From: "Gunther Schadow" <gunther@xxxxxxxxxxxxxxxxxxxxxx>
>
> > Certainly there may still be issues with
> > things like
> >
> > string-pad(' ', @indent + 2)
> >
> > because this would @indent + 2 would probably result in an
> > xs:decimal and not an xs:integer and then there would still be
> > complaints.
>
> Hi Gunther:
>
> Except I think you're forgetting about the solution of changing the
version
> number to 1.0, which, when using XSLT processors that can process 2.0
files,
> will give you access to XSLT 2.0 elements and attributes without the
> datatyping. That is, if I am correctly interpreting Jeni's response
earlier
> in this thread.
>
> That leads to more weirdness, that when you have version="1.0" you are
> sometimes working with 2.0 documents.
>
> I actually did my own tests a week or so ago because you took so long to
> answer the post you answered previously today. <grin/>
>
> The following won't work in Saxon if the version number is 2.0, but will
if
> you change the version number to version="1.0":
>
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns="http://www.w3.org/1999/xhtml">
>
> <xsl:output method="html"/>
> <xsl:variable name="import" select="products" />
>
> <xsl:template match="/">
> <html>
> <head>
> <title>Links to text documents</title>
> </head>
> <body>
> <p>Click a link to view the files output for this stylesheet</p>
> <ul>
> <xsl:apply-templates select="products/product"/>
> </ul>
> </body>
> </html>
> </xsl:template>
>
> <xsl:template match="product">
> <xsl:variable name="doclink"
> select="normalize-space(concat(local-name(), position(), '.htm'))"/>
>
> <li>
> <a href="{$doclink}">
> <xsl:value-of select="string-pad($doclink, 1)"/>
> </a>
> </li>
>
> </xsl:template>
>
> </xsl:stylesheet>
>
> Oh, and this is the source document:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <products>
> <product >
> <name>Bert's Coffee</name>
> <quantity>1</quantity>
> <quantity>3</quantity>
> <quantity>3.4</quantity>
> <quantity>8</quantity>
> <selldate>2003-01-21</selldate>
> </product>
> <product >
> <name>Bert's Tea</name>
> <quantity>11</quantity>
> <quantity>22</quantity>
> <quantity>11.5</quantity>
> <quantity>8</quantity>
> <selldate>2003-02-21</selldate>
> </product>
> <product >
> <name>Bert's Soda</name>
> <quantity>3</quantity>
> <quantity>2</quantity>
> <quantity>5</quantity>
> <quantity>1.5</quantity>
> <selldate>2002-02-15</selldate>
> </product>
> </products>
>
> The offending statement is this:
>
> <xsl:variable name="doclink" select="normalize-space(concat(local-name(),
> position(), '.htm'))"/>
>
> I only used the string-pad function to see if I could use XPath 2.0
> functions in Saxon while (or, for you English folks out there, whilst)
using
> 1.0 as the version attribute value, and found that I could.
>
> Of course, you can fix the above statement and make it work with
> version="2.0" by doing this:
>
> <xsl:variable name="doclink" select="normalize-space(concat(local-name(),
> string(position()), '.htm'))"/>
>
> But you don't have to even do that, you can just change the stylesheet's
> version attribute value to 1.0.
>
> So, in summary, it seems as though data typing is available if you want it
> to be, and not available if you don't want it to be. If you don't want it
to
> be, you use version="1.0", and you still get to use XSLT/XPath 2.0 syntax,
> without type casting. If you do want a stricter type casting model, you
use
> version="2.0".
>
> Please, somebody correct me if my interpretation is erroneous!!
>
> I'm not against strict data typing ***IF*** there's a clean way out, and
> there seems to be, sort of.
>
> Cheers,
>
>
> Chuck White
> Author, Mastering XSLT, Sybex Books
> http://www.javertising.com/webtech
> http://www.tumeric.net
>
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Re: The Perils of Sudden , Charles White | Thread | Re: [xsl] Re: The Perils of Sudden , Charles White |
| [xsl] XSL 2.0 xsl:result-document a, Jarkko Moilanen | Date | [xsl] [News] Antenna House XSL Form, Keiko Hiraide |
| Month |