Code Monkey home page Code Monkey logo

Comments (7)

cowtowncoder avatar cowtowncoder commented on May 30, 2024

@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.

Chandan83 avatar Chandan83 commented on May 30, 2024

@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.

cowtowncoder avatar cowtowncoder commented on May 30, 2024

@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.

Chandan83 avatar Chandan83 commented on May 30, 2024

@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.

cowtowncoder avatar cowtowncoder commented on May 30, 2024

@Chandan83 sounds good. I think it actually does make sense to first try implement feature, then clean up API via stax2.

from woodstox.

Chandan83 avatar Chandan83 commented on May 30, 2024

@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.

cowtowncoder avatar cowtowncoder commented on May 30, 2024

@Chandan83 That sounds possibly useful, if you still have it. So PR would be welcome.

from woodstox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.