xsl-list
[Top] [All Lists]

Re: [xsl] My XPath mistakenly referenced an element that doesn't exist and I got no error message ... is this bad language design?

2021-10-14 10:26:02
On Thu, Oct 14, 2021 at 03:17:08PM -0000, Michael Kay 
mike(_at_)saxonica(_dot_)com scripsit:
I've sometimes wondered whether a "soft" checker (lint-like) that warns you 
of potentially void paths (by reference to a schema and/or instance document) 
might not be a valuable tool.

Any kind of XSLT linter would be a fine thing to have.

Or a run-time checker might be less complicated than a compile-time checker: 
Add an option selection="strict" at the xsl:transform level, and then

Document/foo is treated as one-or-more(Document)/one-or-more(foo)

while if you want zero-or-more(Document)/zero-or-more(foo)

then you have to use some new syntax like opt(Document)/opt(foo)

Even adding req() as a synonym for one-or-more() might be enough to encourage 
people to write req(Document)/req(foo) in order to get better diagnostics.

I prefer keeping the default behaviour of the XPath expression and
adding req().  This would be very handy for those "of course there's a
document, wait, oops" expressions.

Or perhaps a "\" operator that behaves like "/" except the RHS is not allowed 
to be empty.

Overloading backslash seems a titch rash.  And this would be harder to
read than req() would be.


-- 
Graydon Saunders  | graydonish(_at_)gmail(_dot_)com
Þæs oferéode, ðisses swá mæg.
-- Deor  ("That passed, so may this.")
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>