Partial XML Validation

A

alan

An XML question.

Does anyone know of an Java API that will validate a single node in
relation to its context. I'm inserting nodes into a document, and
I'd like to check to see if the node to be inserted is ignorable
whitespace.

Cheers.
 
E

enrique

I don't know of any, however if what you're checking is pretty simple
(and it sound like it is) perhaps you can just regex it.

epp
 
A

alan

I don't know of any, however if what you're checking is pretty simple
(and it sound like it is) perhaps you can just regex it.

I'm implementing XUpdate, so I need a general solution. One that
can use an existing validation method, XML Schema, Relax NG,
Schematron, etc.
 
J

John C. Bollinger

An XML question.

Does anyone know of an Java API that will validate a single node in
relation to its context. I'm inserting nodes into a document, and
I'd like to check to see if the node to be inserted is ignorable
whitespace.

This requires knowledge of the content model of the Element into which
you are inserting the node. Such information is available only for a
valid document (one which conforms to a Schema / DTD), and only if the
relevant schema / DTD is available to validate the document. As far as
I know, the validation process takes place only during document parsing,
and the content model information is not thereafter retained.

I know of no way to do the test you describe other than to add the node,
convert the Document to a character stream, and reparse the stream.
If you use a suitably configured DocumentBuilder in validating mode,
then you can cause ignoreable whitespace to be automatically removed.
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top