[Xpath-ng] List constructor syntax
Jeni Tennison
jeni at jenitennison.com
Thu Dec 5 02:31:02 MST 2002
Hi David,
>> I don't think we should use square or curly braces because []s are
>> used for predicates and {}s are used in XSLT for attribute value
>> templates so I think we should avoid them.
>
> I agree we should avoid them for this purpose. However, I think that
> using braces inside AVTs isn't that problematic. It's just another
> level of nesting.
The nesting can be problematic when it occurs at the beginning or end
of the AVT, e.g. in XPath 2.0:
foo="{validate{$bar}}"
I *think* that the }} at the end will be interpreted as an escaped },
which means that this will generate an error.
In addition, XPath users already try to do things like:
<xsl:for-each select="foo[{$filter}]">...</xsl:for-each>
where $filter is a string holding an XPath expression, because they
think that *all* attributes are AVTs. I think it might be confusing if
{}s are used with another semantic.
I'm not saying that we shouldn't ever use {} for anything -- I think
that they're really useful in an XQuery-like language of the sort that
you're interested in -- I just think that we should avoid them in the
expression-level XPath constructs that are likely to be used in XSLT.
>> I think that we should use a comma operator to create lists with
>> several items, so you can just do:
>>
>> (1, 17)
>>
>> to create a list with two items. That leaves how to create a list
>> with one item or no items. I prefer the list() function as a way of
>> doing that. I'd rather not use characters if we don't need to, and
>> I don't think that creating lists with 0 or 1 items is going to be
>> required that much, so the extra 3 characters involved in a list()
>> function don't seem to be a burden.
>
> Having (1, 17) return a list of two numbers, () return the empty
> list, but (17) just the number 17 isn't consistent enough in my
> opinion. I would instead argue that having to always use the list
> function wouldn't be too big of a burden and would even make things
> clearer in many situations.
OK, let's start using list() in our examples and we'll see whether
it's too much of a burden. I think that you're probably right that it
won't be, because I think that most lists will be generated with
location paths and other expressions rather than being created
explicitly.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
More information about the Xpath-ng
mailing list