[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Does it make sense to collect elements with a cert

Subject: Re: Does it make sense to collect elements with a certain value then assert that the elements I've collected have that certain value?
From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 31 Jul 2024 16:06:43 -0000
Re:  Does it make sense to collect elements with a cert
> To my way of thinking, there is no benefit. I collected <row> elements with
a matching ARPT_IDENT, then the assert tests that the collected <row> elements
have a matching ARPT_IDENT. The assert seems
pointless/redundant/useless/wasteful. Am I missing something?
>

That's surely the whole point of asserts. You typically assert that
`exists($doc//title)` if (a) you are absolutely sure this is going to be true,
and (b) it's not immediately obvious to everyone that it will always be true.
An assert always asserts something that you are confident will be true, but
where your confidence is the result of some non-trivial reasoning process.
It's there for two reasons: (a) so that the computer can tell you if your
confidence turns out to be misplaced, and (b) so that readers of the code can
see what's going on without having to repeat your reasoning process.

Well, actually, there is another reason to use assertions, namely to test for
external conditions that you want to treat as fatal. For example the assertion
test="doc-available('input.xml')" is there not because you're certain it will
always be true, but because you want to abort processing if it isn't. But
assertions aren't actually the ideal mechanism for that, because they are
often switched off by default when running in production.

Michael Kay
Saxonica

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.