Lists Home |
Date Index |
> About pattern matching, I'm trying to fix some issues with Jaxen :
I try to avoid commenting on other people's implementations (I've had nasty
letters from people's lawyers when I've done so!)
> What do you think of such a strategy ?
> Did you made something similar in Saxon ?
The only kind of XPath expressions that Saxon attempts to evaluate in
streaming mode are the limited path expressions used in XML Schema integrity
constraints - basically downwards-only selections with no predicates. It
wouldn't be hard to add a few extra features such as constant numeric
predicates or predicates that test the values of attributes. The more
general case is pretty difficult. There have been some research papers on
the topic, but I think most of them fail to tackle the difficult cases such
as a predicate of [last()-2] or a step of preceding-sibling::x. (Of
course that's the luxury of doing research, you can leave the difficult
problems as a reason for applying for a further grant...)
> >>Will you be hurted if someone (like me) was writting
> >>something like this :
> >> $foo/@bar/@oof
> I don't want to design a language similar to XPath that works on a
> different data model, but rather design a data model different to
> XPath's on which XPath can be applied :)
> Why couldn't I design a data model where the value of an attribute is
> not a string but any object ?
Well, obviously if the data model changes then the semantics change, so it's
a different language.
XPath 2.0 does in fact recognize that the value of an attribute can be a
typed value such as a list of integers. But it doesn't allow the value of an
attribute to be, say, an XML element, or an employee.
> For the moment, there are few things that I bypassed in XPath :
> -it is said somewhere that :
> -any object can be bound to a variable.
> -the result of an XPath expression is either a (possible
> empty) node
> set, a boolean, a string, or a number.
This is so 1990s... You're talking XPath 1.0.
> If my XPath expression is $foo, why is it not allowed to get the
> original object ? Thus, I consider that it is possible to get
> an object.
XSLT (more specifically than XPath) recognizes that vendors can extend the
type system to allow XPath values that encapsulate external objects,
typically as the result of extension functions. This is unchanged in 2.0.
It's a big step from allowing such things in XPath variables to allowing
them as the typed value of an element or attribute - but not necessarily an
impossible one. I think I prefer a model where the attribute holds a URI and
the URI can be dereferenced to get the external object.
> -comparisons on comparable objects are not done regarding the XPath
> rules, but on their comparator ; this is also the same when a
> typed data
> is bound to a node (I know there are similar mechanisms in
> XPath 2.0.),
> like shown in this example :
> ...which works like PSVI on W3C XML Schema, but I don't
> think that
> the type in this example can be defined with WXS (in order to
> sort it in the same way).
I'm not sure what you're trying to say here.
> Now, let's consider again the question about objects contained in
> attribute values : with PSVI, it is possible to bind a typed
> data with
> it. So, I can consider that the attribute value is a
> (textual) reference
> that will be parsed by my type library that will supply the object
> expected. We like to be contortionists in computer science,
> but I prefer
> a straightforward way to get a result almost identical
> (without needing
> to design a useless string value as a reference to my
> object). This is
> like setting anonymous objects : if I don't care about the name (the
> textual reference), why forcing me to use one ?
I think it's a mistake to forget XML's origins as a markup language. XML in
my view is fundamentally text, and that is its great strength. Data types
are merely a way of creating higher-level views of the underlying text. If
you want to build trees of arbitrary objects, there are better ways of doing
it than bending XML.