[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] Are there invariants in XML processing?
- From: "Liam R. E. Quin" <liam@fromoldbooks.org>
- To: Roger L Costello <costello@mitre.org>, xml-dev <xml-dev@lists.xml.org>
- Date: Sun, 01 May 2022 14:15:19 -0400
On Sun, 2022-05-01 at 17:38 +0000, Roger L Costello wrote:
> Hi Ken,
>
> What is an invariant?
An aspect of invariant-led programming that's sometimes forgotten is
that it leads to code that's not in a user-centric sense robust - it
can lead to programs that crash whenever the input is in the least
unexpected, which users tend to call buggy or fragile or useless.
Of course, over time the programs get more robust.
There was an article in Byte once that used assertions with a text
editor as the sample program - so if there was an internal error, the
program would crash and you'd lose all your text. Nope.
So, decide whether early exit is appropriate - it often is, in a
validation scenario - or whether error recovery is more helpful. For
example, if you are processing 100,000 documents in a batch and one of
them violates a constraint, well, log it and go on to the next one.
A second aspect that often _is_ considered is this: most systems,
including Saxon, let you turn off assertions for production use. Now,
your program won't crash when it gets wrong input. Instead, it will go
wrong silently in ways you never tested. With assertions turned off,
some of your code is not being run, so if the expressions in your
assertions had side-effects, you're in trouble.
Again, you can plan for this, but it does take care and understanding.
In XSLT 3 and XQuery 3, try/catch can be used in conjunction with
assertions to mitigate some of these issues, but again, it has to be in
a framework, a way of approaching problems, that you do consciously.
liam
--
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]