Re: Do XML Schema processors do backtracking?
Mukul Gandhi <[email protected]>
| Newsgroups | gmane.text.xml.devel |
|---|---|
| Message-ID | <CANGHzgAL_iYdb4jxQkheyQ2UqDt=PJqBYkAQAA=r6e=q9ZGB2A@mail.gmail.com> |
Hi Roger,
I can talk a bit about XercesJ's XML Schema implementation. It builds
DFA content model, corresponding to the underlying XSD syntax (the
xs:choice etc). The XML Schema validator, receives XML document (that needs
to be validated) events from XML parser, and uses the DFA content model
that was built previously to find whether the XML document instance
structure is valid. As Rick wrote, XercesJ's XML Schema implementation,
doesn't seem to do backtracking for validating XML document instance with
xs:choice.
On Tue, Apr 19, 2022 at 5:03 PM Roger L Costello <[email protected]> wrote:
> Hi Folks,
>
> I am reading a compiler book [1] and it says this:
>
> "An important practical criterion is that a parser should not backtrack.
> At all stages it should operate deterministically. A number of authors have
> described backtracking parsers, but those are rarely used in practice. It
> is difficult to undo semantic actions carried out by the parser as is
> necessary if it has to backtrack."
>
> Do XML Schema processors do backtracking? For instance, if the XML
> document has this:
>
> <name>John Doe</name>
>
> and the XML Schema has this choice:
>
> <xs:choice>
> <xs:element name="id" type="xs:int" />
> <xs:element name="name" type="xs:string" />
> </xs:choice>
>
> Does the XML Schema processor try the first branch of the choice,
> backtrack, and then try the second branch?
>
> /Roger
>
>
> [1] Introduction to Compiling Techniques by J.R. Bennett, see bottom of
> page 80.
>
--
Regards,
Mukul Gandhi