DOM Validation "on-the-fly"

G

Ghee

Hello,

I have a (java) DOM object that adheres to an XML schema. I want to
manipulate it in code, but to ensure that the object still sticks to
the schema (ie, validation during the life-cycle of the DOM object, not
just upon initial parsing). Is this possible?

My investigation so far has revealed that DOM3 does provide validation
mechanisms for this, but no current parsers implement them. I've
picked up on something called the "post-schema-validation infoset"
(PSVI), but it looks like another full-blown API to learn - I just want
(ideally) a flag to indicate that I want the DOM object to reject
changes that cause it to become invalid.

I've also seem many other postings on this kind of question, but there
have never been any replies... Is this the kind of question that shows
I haven't grasped what XML and friends are all about and you're
laughing at my lack of understanding (I am new to this and am trying to
teach myself)? Should I really have another DOM object with the XSD
document in and use that to manually validate the other object?

Does anybody have any clues regarding this?

Ghee
 
M

Martin Honnen

Ghee wrote:

I have a (java) DOM object that adheres to an XML schema. I want to
manipulate it in code, but to ensure that the object still sticks to
the schema (ie, validation during the life-cycle of the DOM object, not
just upon initial parsing). Is this possible?

Java 1.5 allows you to (re)validate a document against a schema by using
the javax.xml.validation namespace with SchemaFactory, Schema, Validator
objects and the validate method of Validator.
I don't see any features in there however to find out whether a certain
change is allowed in the way DOM Level 3 validation supports it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top