Re: [xsl] inserting a child element while honoring the parent element's content model

Subject: Re: [xsl] inserting a child element while honoring the parent element's content model
From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 22 Feb 2023 09:37:26 -0000
> With respect to *testing* against (not processing in view of) content models
- I hesitate to mention it but there is the approach of writing out the
sequence of element names as a string and then testing that against a regex
mapped out from the content model. One of several problems with this approach
is that the error messages it produces are pretty useless.Limiting the content
model in certain ways can make this easier e.g. forbidding repeated sequence
groups (even worse than 'or' groups).
>

In 2018, in https://www.saxonica.com/papers/markupuk-2018mhk.pdf

I described how you could write a schema validator in XSLT 3.0. It uses the
finite state machines in an SCM file generated by a Java schema processor; I
never got around to writing the other half of the system (the schema compiler
that generates the FSM) in XSLT, but it's certainly doable.

The actual testing of a sequence of elements against the FSM is implemented
using xsl:iterate and is very straightforward - see section 4.3 of the paper.

Michael Kay
Saxonica

Current Thread