By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,058 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,058 IT Pros & Developers. It's quick & easy.

Java, validate XML with XSD, XML not containing "xmlns:xsi=..."

P: n/a
I am using java to validate an XML file with a DTD, without having the
DVD declaration inside the original file, by setting the doctype
dynamically to a transformer like this :

transformer.setOutputProperty(OutputKeys.DOCTYPE_S YSTEM, dtd);
transformer.transform(source, new StreamResult(new
StringWriter()));

I would like to know if there is a way to validate an XML file with an
XSD, again, without having the declaration of the xsd file inside the
original XML file, but by declaring it dynamically.

Thank you !
Aug 15 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
killy971 schrieb:
I am using java to validate an XML file with a DTD, without having the
DVD declaration inside the original file, by setting the doctype
dynamically to a transformer like this :

transformer.setOutputProperty(OutputKeys.DOCTYPE_S YSTEM, dtd);
transformer.transform(source, new StreamResult(new
StringWriter()));
DTD validation is tightly connected to parsing. So you can parse the
result of the transformation with a validating parser.
I would like to know if there is a way to validate an XML file with an
XSD, again, without having the declaration of the xsd file inside the
original XML file, but by declaring it dynamically.
Have a look at "Chapter 14. Package javax.xml.validation" of "JSR 206
Java™ API for XML Processing (JAXP) 1.3".

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Aug 15 '08 #2

P: n/a
Johannes Koch schrieb:
killy971 schrieb:
>I am using java to validate an XML file with a DTD, without having the
DVD declaration inside the original file, by setting the doctype
dynamically to a transformer like this :

transformer.setOutputProperty(OutputKeys.DOCTYPE_S YSTEM, dtd);
transformer.transform(source, new StreamResult(new
StringWriter()));

DTD validation is tightly connected to parsing. So you can parse the
result of the transformation with a validating parser.
>I would like to know if there is a way to validate an XML file with an
XSD, again, without having the declaration of the xsd file inside the
original XML file, but by declaring it dynamically.

Have a look at "Chapter 14. Package javax.xml.validation" of "JSR 206
Java™ API for XML Processing (JAXP) 1.3".
In this case I'd transform into a DOMResult and then pass the resulting
node to the schema validation.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Aug 15 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.