RE: [xsl] 2.0 feature request

Subject: RE: [xsl] 2.0 feature request
From: "Evan Lenz" <elenz@xxxxxxxxxxx>
Date: Tue, 20 Feb 2001 10:16:44 -0800
> (Q4) List the names of the second-level managers of all employees whose
> rating is "Poor".
>
> /emp[rating = "Poor"]/@mgr->emp/@mgr->emp/name
>
> the -> operator is our old id() function in new clothes.

I think it's a bad idea to introduce new syntax to XPath when there's no new
functionality. I would like to still be able to say "steps are separated by
slashes", but this would change that (I think). In any case, the function
syntax of id() is overloaded enough to make it pretty quickly familiar to
anyone learning XPath.

To show that readability can still be attained without deviating from the
current XPath standard, here's an example using a variable (variables are
part of XPath, you know):

id($poorManagers/@mgr)/name

<xsl:variable name="poorManagers" select="id(/emp[rating='Poor'/@mgr)"/>

On the other hand, maybe the -> syntax does introduce new functionality.
Following -> is emp/@mgr, whereas id() will return *all* referenced elements
(not just those named 'emp'). This distinction is not made in the prose of
the XQuery WD. In fact, with the new syntax, how *do* we dereference all
referenced elements regardless of name (presumably ->*/name )? The XPath
equivalent would be:

id($poorManagers/@mgr)[self::emp]/name

<xsl:variable name="poorManagers"
select="id(/emp[rating='Poor']/@mgr)[self::emp]"/>

Or, without a variable:
id(id(/emp[rating = "Poor"]/@mgr)[self::emp]/@mgr)[self::emp]/name

Sure, theirs is more readable...for this particular straw man. But XPath has
been designed and used for well over a year now. Why should we start
changing its syntax?

Also, it's not clear in the XQuery draft whether their -> syntax will
operate on only IDREF and IDREFS, or values of any type (as is the case with
XPath).

Ultimately, this is another example of the XQuery people reinventing the
wheel. More on this at XSLT-UK, or maybe sooner....

Evan Lenz
XYZFind Corp.



-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of
DPawson@xxxxxxxxxxx
Sent: Monday, February 19, 2001 12:44 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] 2.0 feature request


Straight out of xml query.
http://www.w3.org/TR/xquery/#section-Path-Expressions

However, the right-arrow notation is designed to be easier to read,
especially in path expressions that involve multiple dereferences. For
example, suppose that a given document contains a set of <emp> elements,
each of which contains a "mgr" attribute. The "mgr" attribute is of type
IDREF, and it references another <emp> element that represents the manager
of the given employee. The name of each employee is represented by a <name>
element nested inside the <emp> element.
(Q4) List the names of the second-level managers of all employees whose
rating is "Poor".

/emp[rating = "Poor"]/@mgr->emp/@mgr->emp/name

the -> operator is our old id() function in new clothes.

I think this would be extremely useful.

DaveP

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


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


Current Thread