Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 15th, 2008, 03:05 AM
killy971
Guest
 
Posts: n/a
Default Java, validate XML with XSD, XML not containing "xmlns:xsi=..."

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 !
  #2  
Old August 15th, 2008, 08:45 AM
Johannes Koch
Guest
 
Posts: n/a
Default 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.)
  #3  
Old August 15th, 2008, 11:15 AM
Johannes Koch
Guest
 
Posts: n/a
Default 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.)
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles