Comments (7)
@Chandan83 I don't remember if this is a requirement for the underlying validator (MSV) or the interface Woodstox specifies for validators, but ultimately I think many if not all validators require full textual event content to be available. That is, they are not designed to work in incremental fashion, regarding logical CDATA segments.
So for all practical purposes there is no way to avoid loading the whole CDATA segment in.
It might be possible to find optimizations so that for some types of cdata segments this could be avoided, based on schema definitions (that is, for kind of text for which no validation is done or something), but even this would require changes.
from woodstox.
@cowtowncoder The MSV validator or any other validator might require the whole content to validate but it makes sense to give the user a way to bypass validation for certain elements of choice. The behavior of the validator is entirely decided by the schema definition and some external config properties. The only case where it will not validate the CDATA segment is when the element is of (complex) mixed type.
Ideally, we would expect the validator to behave just like the reader which breaks a large CDATA segment into multiple smaller text events. A more generic solution will be to allow the user to modify the behavior of the validator. For the later, I was thinking if we can pair the validator returned by XMLValidationSchema with another user defined validator within a ValidatiorPair whose methods can be overriden, the user will have the ability to change the validations.
Unfortunately, we don't have a Validatable.validateAgainst(XMLValidator) even though we do have a Validatable.stopValidationAgainst(XMLValidator) and so even if we change the validator, we cannot use it for validation as per Stax2 API. What do you think should be the right abstraction to overcome this issue.
from woodstox.
@Chandan83 it has been quite a while since I worked on validation part, but my first reaction is that instead of using multiple validators and trying to make them co-operate, it would make more sense to make specific validator (XML Schema one) -- or perhaps base type -- expose a method that would allow disabling validation for specific element (specified by QName). Or allow definition of a callback that is called to allow skipping of element (and/or attribute).
from woodstox.
@cowtowncoder I will come up with a proposal for the woodstox implementation as of now. If it sounds OK to you, I can raise a pull request. I might have to raise a similar discussion on the Stax2 API github page.
from woodstox.
@Chandan83 sounds good. I think it actually does make sense to first try implement feature, then clean up API via stax2.
from woodstox.
@cowtowncoder I have adopted a very specific solution by exposing a public method GenericMsvValidator.allowAnyTextContent(String localName, String uri, String prefix) using which we can register elements for which method validateElementAndAttributes() returns XMLValidator.CONTENT_ALLOW_ANY_TEXT. If you find it good enough, I can raise a pull request. You can suggest improvements.
from woodstox.
@Chandan83 That sounds possibly useful, if you still have it. So PR would be welcome.
from woodstox.
Related Issues (20)
- After update to 6.5.0, in osgi/felix runtime the bundle is not started due to missing dependency HOT 4
- failed to parse xml: Unrecognized property `'com.ctc.wstx.maxEntityCount'` in `woodstox:6.5` HOT 2
- Vulnerability CVE-2023-34411 HOT 3
- W3CMultiSchemaFactory class needs extended to allow for custom resolving of XSD's locations HOT 2
- Woodstox should provide option to leave predefined entities i.e. "<", ">", "'", """ and "&" as it is HOT 2
- Not able to write xml to azure blob storage HOT 1
- WstxValidationException: Unknown reason (at end element </nl:nillableIntElement>) when validating a document with nillable elements HOT 14
- Update `msv-core` dependency to `2022.7`
- Notations declared in external DTD subsets are reported as undefined HOT 6
- 'Undefined ID' not thrown when validating with SimpleNsStreamWriter HOT 1
- 'Element <root> has no attribute "verbose"' not thrown from RepairingNsStreamWriter when validating against a DTD schema HOT 1
- Module `com.ctc.wstx` does not read a module that exports `com.ctc.wstx.shaded.msv.org_isorelax.verifier` HOT 6
- Remove `QNameCreator` compatibility class
- WstxSAXParser error handling when used with JAXB validation HOT 7
- Version 6.6.0 contains a module error (dup of #193 ?) HOT 3
- Fix shading of `isorelax` dependency (and other msv-core components) HOT 12
- Invalid characters inside CDATA section HOT 5
- remove synchronized blocks HOT 1
- Non-conformant `XMLEventFactory.setLocation(null)` HOT 1
- Why is the maximum character count for parsing limited to 4000 each time? Can't it support the caller to customize this setting? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from woodstox.