This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: XPath incompatibilities


Happy New Year :)

Mike wrote:
> I think we still have some work to do on schema-less documents and
> untyped nodes.

I guess that one possibility that would help in the case of < would be
to convert the nodes to whatever type they look like. If they look
like numbers, treat them as numbers; if they look like dates, treat
them as dates and so on.

The major benefit of this would be that it would mean you wouldn't
have to do explicit casts in many cases - it keeps XPath simple for
those of us that don't want to worry about what types things are all
the time. The major headaches come in the specification of how you
recognise a type - how do you tell whether something is a decimal or a
gYear, a string or a QName (though I think that these are details that
could be worked out) - and I guess that it would slow down the
implementation.

But this already seems to be used in arithmetic expressions (Section
2.5 of the XPath 2.0 WD). Point 4 there states:

  If any operand is an untyped simple value (such as character data in
  a schemaless document), it is cast to the type suggested by its
  lexical form. For example, the untyped value 12 is cast to the type
  xs:integer.

If you can do it with arithmetic expressions, why not with
comparisons?

>> I think that there are lots and lots and lots of stylesheets that
>> use the implicit conversion to numbers when doing comparisons, and
>> that it would be very confusing to have lexicographic comparison.
>
> My own guess is that most examples will do comparison against a
> numeric literal, e.g. @max>3. If one of the operands is numeric, the
> comparison will be numeric.

Both guesses can be true, of course. There are probably also a lot of
a stylesheets that have something like:

  <xsl:variable name="min">3</xsl:variable>
  <xsl:if test="@number > $min">...</xsl:if>

because people commonly use the body of xsl:variable rather than the
select attribute. I think these would lead to lexicographic
comparisons as well.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]