Subject: Re: [xsl] Best Practice: use @as wherever possible From: "John Lumley john@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 6 May 2022 19:24:30 -0000 |
Think of the division between @as and xsl:assert in the following way: If what you want to check is the type of a single variable as optional/one or more/any of a given type attach @as to the defining statement (xsl:variable, xsl:param, xsl:sequence). As Michael says, the compiler can do much more with that, either in static or dynamic phases. If you need to check something much more complex (e..g. count(items) > 6, $node/parent::container[count(*) gt 5]), add an xsl:assert binstructionb. John Lumley > On 6 May 2022, at 20:02, Roger L Costello costello@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > o;?Michael Kay wrote: > -------------------------------------------------------------------------- > If you can express the condition with an @as attribute, > use that in preference to an xsl:assert, because it's much > more amenable to static analysis - certainly with Saxon, > xsl:assert will only ever give you a run-time error. The > diagnostics for type errors will also tend to be better. > -------------------------------------------------------------------------- > > Fantastic! > > Thank you Michael. > > /Roger
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Best Practice: use @as wherev, Roger L Costello cos | Thread | [xsl] Initial whitespace in PI from, Bauman, Syd s.bauman |
[xsl] Best Practice: use @as wherev, Roger L Costello cos | Date | Re: [xsl] Defensive programming in , Liam R. E. Quin liam |
Month |