[Xpath-ng] My favorite XPath language
David Rosenborg
darolst at pantor.com
Wed Nov 20 18:31:39 MST 2002
Hi all!
An excellent initiative Uche! Let's just hope it gets enough momentum. I'll start
off here with some unsorted ideas and opinions just to get the discussion going.
If you're interested in a historical perspective you might want to have
a look at FXPath (http://www.pantor.com/fxpath/) which was an earlier attempt
where I tried to consolidate ideas about a successor to XPath 1.0.
To summarize my favorite XPath language I'd start with XQuery,
remove the XML Schema stuff, use the XPath 1.0 data
model, and add a dose of functional programming.
Self-sufficiency
------------------------------------------------------
I choose XQuery as the starting point to illustrate that I think
that XPath Ng should be a self-sufficient language i.e., not
dependent on a context like XSLT or XPointer. It should
however have the capabilities to inherit properties like
variables from a host language if present.
To be self sufficient I think XPath Ng should have constructs for
* declaring namespaces, here you could borrow the syntax from Relax Ng
(as in XQuery without the 'declare' word)
* defining variables, like in XQuery: let $a := 'foo', or without the 'let' as in FXPath: $a := 'foo'
* defining functions. In my opinion the most powerfull option would be to have
first class function objects. This would allow for functions to be stored in variables
and passed as parameters and return values. This was suggested in my FXPath
spec and further elaborated in my own test implementation. The following
example outlines the general idea:
$find-member := func ($struct, $name) { $struct/member [@name = $name] }
...
$find-member ($some-struct, 'foo')
Backward compatibility
------------------------------------------------------
XPath 1.0 expressions should work unmodifed when processed by an XPath Ng
processor.
Schema support
------------------------------------------------------
XPath Ng should not mandate support for any particular schema language. Instead
it should provide a generic facility for tunneling auxiliary information from, for example,
a schema to the XPath Ng language. Such facilities have recently been discussed
on xml-dev where sugestions ranges from a single annotation () function to multiple
extensible axes.
Constructors
------------------------------------------------------
In my opinion it wouldn't be to bad to have the so called "Computed Constructors"
from XQuery available in XPath Ng. Though this might be too great of an overlap
with XSLT.
List type
------------------------------------------------------
Instead of treating everyting as a sequnce as XPath 2.0 does, I think XPath Ng
could have a separate list type and a set of functions and possibly primitives
that operates on list instances.
Function library import
------------------------------------------------------
Maybe some more advanced function library handling could be used. As it is now
you'd always use prefixes for named user defined functions. It would be nice
to be able to import functions for use without prefixes. Much in the same way
Java package import works.
XML syntax mapping
------------------------------------------------------
A normative XML mapping of the XPath Ng syntax could be usefull. Just as there is
an XML and compact syntax for Relax Ng, there could be two syntaxes for XPath Ng too,
just that we'd use the compact form for the primary spec.
That's all for now
Cheers,
David
-------------------------------------
David Rosenborg
Pantor Engineering AB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fourthought.com/pipermail/xpath-ng/attachments/20021121/e2de4a31/attachment.html
More information about the Xpath-ng
mailing list