Does it make sense to work only with strings?
"Oleg A. Paraschenko" <[email protected]> Wed, 22 Dec 2004 10:42:22 +0300
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Organization | xmlhack.ru |
| Message-ID | <[email protected]> |
Hello,
I work with numbers and SXML trees at the same time. I don't
like to make "number->string" when putting a number to a SXML
tree and then to make "string->number" when getting the number
from the SXML tree. So I put the number into the tree as is.
Unfortunately, I've got a problem:
[code]
;
; This works (numbers are strings)
;
(define tree
'(*TOP*
(item (@ (level "1")))
(item (@ (level "3")))
(item (@ (level "4")))))
(write ((txpath "item[@level>2]") tree))
===> ((item (@ (level "3"))) (item (@ (level "4"))))
;
; And this doesn't work (numbers are numbers):
;
(define tree
'(*TOP*
(item (@ (level 1)))
(item (@ (level 3)))
(item (@ (level 4)))))
(write ((txpath "item[@level>2]") tree))
===> ()
[/code]
As I traced the situation, "@level>2" produces a call to
(sxml:relational-cmp <)
with
obj1: ((level "1")) or ((level 1))
obj2: 2
As obj1 is a nodeset, it's transformed to "nset1" as
(map (lambda (node) (sxml:number (sxml:string-value node))
and the problem lies in "sxml:string-value":
(if (string? node)
node
"") ; for XPath 1.0 it is an incorrect situation
So my questions are:
Is it really useful to return empty string here?
Should I expect similar problems in other functions?
Regards, Oleg
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/