[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Why can a template rule match on a child of multip
XPath 1.0 expressions (and therefore XSLT 1.0 patterns) only allow a RelativeLocationPath on the RHS of the "/" operator. A RelativeLocationPath is essentially a sequence of one or more Steps separated by "/", and a Step (unless abbreviated) takes the form AxisSpecifier NodeTest Predicate*. XPath 2.0 generalized the syntax (and semantics) so any expression could appear on the RHS of the "/" operator (written in parentheses if necessary). XSLT 2.0 however kept the syntax much more restricted for patterns, to ensure efficient matching: patterns in 2.0 allowed basically only the Step syntax of 1.0 (plus the ability to call the id() function). XSLT 3.0 then removed these restrictions to allow a parenthesized expression on the RHS of "/". It's worth noting that this opened up a very wide range of possibilities which weren't immediately covered by test cases or by the Saxon implementation; we're still occasionally finding cases that aren't implemented or are implemented incorrectly, see for example https://saxonica.plan.io/issues/5368 https://saxonica.plan.io/issues/4755 As to the "why" question, I don't know why XPath 1.0 imposed the restriction, though it's fairly obvious why it was subsequently relaxed. One of the design debates you can have here is paternalism versus orthogolnality. Paternalism says there's no point writing an expression on the RHS that doesn't depend on the context item (for example, a literal or a variable reference), so it should be flagged as an error. Orthogonality says you don't ban things just because they appear to be useless: for example, you don't make it an error to write $x + 0, so why make it an error to write $x / 0 ? And then paternalism says, anyone who writes $x / 0 has probably made a mistake. There are arguments both ways, which is why the spec isn't always consistent. Michael Kay Saxonica > On 19 May 2022, at 14:22, Roger L Costello costello@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Hi Folks, > > Why can I have a template rule like this: > > <xsl:template match="(sidRunwayTransition|sidCommonRoute|sidEnrouteTransition)/supplemental Data"> > > But I cannot have a template rule like this: > > <xsl:template match="sid/(sidRunwayTransition|sidCommonRoute|sidEnrouteTransition)"> > > /Roger
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|