Connecting Tech Pros Worldwide Forums | Help | Site Map

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

killy971
Guest
 
Posts: n/a
#1: Aug 15 '08
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 !

Johannes Koch
Guest
 
Posts: n/a
#2: Aug 15 '08

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


killy971 schrieb:
Quote:
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.
Quote:
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.)
Johannes Koch
Guest
 
Posts: n/a
#3: Aug 15 '08

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


Johannes Koch schrieb:
Quote:
killy971 schrieb:
Quote:
>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.
>
Quote:
>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.)
Closed Thread