Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XSD 1.1 support? #92

Open
CeruleanJaguar opened this issue Nov 6, 2019 · 5 comments
Open

XSD 1.1 support? #92

CeruleanJaguar opened this issue Nov 6, 2019 · 5 comments

Comments

@CeruleanJaguar
Copy link

I'm trying to use woodstox with a schema that is conformant to the XSD v1.1 specification (specifically that it contains conditional type alternatives using xPath 2.0 assertions) and it would seem that MSV doesn't support this unless there are any construction options that I am unaware of, as I repeatedly get the error element "xs:alternative" is not allowed here upon an attempt to construct the XMLSchemaGrammar via XMLSchemaReader::parse using a SAXParserFactory from com.ctc.wstx.msv.BaseSchemaFactory::getSaxFactory.

Does woodstox support XSD v1.1 validation? If not, does woodstox support alternative validators other than MSV?

I tried using xerces-2.12.0 to parse the XSD and construct the validator to inject into woodstox as it does support conditional type assignment, but had issues with resolving it in the classpath via the standard mechanism:

        SchemaFactory versionFactory = SchemaFactory.newInstance("http://www.w3.org/XML/XMLSchema/v1.1");

As specified here: https://xerces.apache.org/xerces2-j/faq-xs.html#faq-1

@cowtowncoder
Copy link
Member

Woodstox has MSV-based validator implementation, and MSV has not been developed for years.

If you or someone else finds alternate validator that can work on incremental/streaming input, it is possible to implement alternative validator implementation: code within parser is not MSV-specific, just requires certain callbacks to be implemented.
I do not have time or interest to work on such things, but could help with integration.

@michaelhkay
Copy link

It should be possible to run the Woodstox XML parser with the Saxon schema validator, simply by invoking Saxon's SchemaValidator API (see https://www.saxonica.com/documentation/index.html#!javadoc/net.sf.saxon.s9api/SchemaValidator) using validate(Source) where the supplied Source is a StaxSource.

Saxon's schema validator runs in push mode, so it can't be run in tandem with Woodstox within a pull pipeline, but the pull-push combination is still fully streamed. You could also construct a pull pipeline that "tees" events off into the validator, if you don't want anything from the validator other than notification of invalidities.

@cowtowncoder
Copy link
Member

@michaelhkay unless I misunderstand what you mean by Saxon's schema validator running in push mode, this seems compatible with the way Woodstox works both for Stax (pull) and SAX modes (push) -- Woodstox will call state update methods on validator like you describe (and not just with parser but also, optionally, generator). If so, all (?) that would be needed would be an additional Woodstox component to call proper methods in Saxon validator instead of MSV validators.

Such a component probably should live in an artifact of its own, depending on stax2-api and Saxon package, and easily pluggable on Woodstox parser and generators.
Existing MSV-based validator(s) would be starting places to see how to write such adaptors.

@michaelhkay
Copy link

michaelhkay commented Jan 8, 2021

Yes, I always think of Woodstox as a pull parser because that's how I use it, but now you mention it, you can do the pull-push loop either in Woodstox or in Saxon, either should work perfectly well.

What you can't do is to put the Saxon validator onto a pull pipeline.

@cowtowncoder
Copy link
Member

@michaelhkay yes, right, makes sense. For practical reasons (to be able to use MSV validators), validation approach is pull/push combination with a simple interface to allow plugging in different backends (although that possibility has been mostly theoretical so far). There may of course be some differences between what MSV expects and what Saxon's validator expects, but conceptually it should match I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants