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]

Re: A really easy (hopefully) question


> > The "current node" and "current node list" are XSLT concepts,
> > not XPath
> > concepts. What would you expect current() to return in
> > another non-XSLT implementation of XPath?
> 
> It would be quite easy to define it as "the node that is the context node
> for the XPath expression as a whole, outside any predicates". I assume
> no-one thought that would be useful enough to justify it.

4XPath doesn't, but I do agree that it makes some sense.  We'd probably 
require current() to be qualified with the XSLT namespace if used in 
free-standing 4XPath.

> It would be interesting to know whether free-standing XPath implementations
> actually provide this function or not. As far as I can see neither
> Microsoft's nor Xalan's free-standing XPath processors give you any
> (documented) way of defining variables, which ARE part of the XPath spec.

In 4XPath this looks like

from xml.xpath.Context import Context
from xml.xpath import Evaluate
vars = {('http://spam.com', 'sillyvar'): 'hello world'}
nss = {'pref': 'http://spam.com'}
con = Context(dom_node, varBindings=vars, processorNss=nss)
result = Evaluate('$pref:sillyvar', context=con)

Quick n dirty Python primer for the above

{a: b, c: d} is a dictionary or associative array with a & c as the keys and b 
& d as the values.
(a, b, c) is a tuple of values, similar to a list


-- 
Uche Ogbuji                               Principal Consultant
uche.ogbuji@fourthought.com               +1 303 583 9900 x 101
Fourthought, Inc.                         http://Fourthought.com 
4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA
Software-engineering, knowledge-management, XML, CORBA, Linux, Python



 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]