Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > validate xml with sax?

Thread Tools

validate xml with sax?

Ray Tayek
Posts: n/a
hi, fooling around with xmlspy (which seems pretty broken when *doing*
xslt's). trying to validate in java using code from
(click on the link). i get an error saying that a doctype
decl is required (see below). i get the same error whether or not i turn
on name space awareness. spy says this file is well formed and valid.
and my java code that transforms it with the same .xslt works as
expected (all the files are at the spy
starts the xml doc that i am trying to validate with:

<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSPY v2004 rel. 3
<inputDocument xmlnssi=""
xsi:noNamespaceSchemaLocation="H:\java\projects\sp y1\spy\inputDocument.xsd">

while the .xsd file starts with:

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 U ( by Ray
Tayek (Freightgate) -->
<xs:schema xmlnss=""
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="inputDocument">
<xs:documentation>input csv converted to xml</xs:documentation>

what i would like to do is to validate the xml doc against it's schema
before applying the transform (in java) . i have not yet tried the dom
example at as i
thought the sax would be a bit more lightweight.

i just started using spy (i had java code that does the transform just
fine). but i used spy to generate the new .xsd and sample xml. so maybe
he put some proprietary junk in there or something?

anaict, doctype is for dtd's, but sax is complainig about a missing doctype.

anybody got a clue?


output from when trying to validate the xml doc:

SYS ID: file:H:/java/projects/spy1/spy/inputDocument.xml
<?xml version='1.0' encoding='UTF-8'?>** Warning, line 4, uri
Valid documents must have a <!DOCTYPE declaration.
** Parsing error, line 4, uri
Element type "inputDocument" is not declared.
org.xml.sax.SAXParseException: Element type "inputDocument" is not declared.
at org.apache.crimson.parser.Parser2.error(Parser2.ja va:3160)
at org.apache.crimson.parser.Parser2.parse(Parser2.ja va:305)
at javax.xml.parsers.SAXParser.parse( 45)
at javax.xml.parsers.SAXParser.parse( 81)
at V.main(
Reply With Quote

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Schema to validate against XML encryption Stefan XML 3 03-29-2008 12:28 PM
Validate, Search and Transform XML with XML Hammer 1.0 rc-3 Edwin Dankert XML 0 01-23-2008 01:52 PM
[ANN] Validate, Search and Transform XML with XML Hammer 1.0 rc-2 Edwin Dankert XML 7 10-06-2007 06:49 PM
Validate XML against DTD and/or XML Schema? Reid Priedhorsky Python 2 04-17-2006 08:46 AM
tool to validate xml file against custom XML Schema file Leona XML 9 11-01-2004 09:51 AM