473,654 Members | 3,109 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

validate xml with sax?

hi, fooling around with xmlspy (which seems pretty broken when *doing*
xslt's). trying to validate in java using code from
http://cermics.enpc.fr/doc/java/j2ee...JAXPSAX13.html
(click on the Echo10.java 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 http://tayek.com/~ray/spy1/). 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
(http://www.xmlspy.com)-->
<inputDocumen t xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "H:\java\projec ts\spy1\spy\inp utDocument.xsd" >
<special>Text </special>
<header>
<inputFieldName >String</inputFieldName>

while the .xsd file starts with:

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by Ray
Tayek (Freightgate) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied">
<xs:element name="inputDocu ment">
<xs:annotatio n>
<xs:documentati on>input csv converted to xml</xs:documentatio n>
</xs:annotation>

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
http://cermics.enpc.fr/doc/java/j2ee.../JAXPDOM9.html 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?

thanks
output from Echo10.java when trying to validate the xml doc:

LOCATOR
SYS ID: file:H:/java/projects/spy1/spy/inputDocument.x ml
START DOCUMENT
<?xml version='1.0' encoding='UTF-8'?>** Warning, line 4, uri
file:H:/java/projects/spy1/spy/inputDocument.x ml
Valid documents must have a <!DOCTYPE declaration.
** Parsing error, line 4, uri
file:H:/java/projects/spy1/spy/inputDocument.x ml
Element type "inputDocum ent" is not declared.
org.xml.sax.SAX ParseException: Element type "inputDocum ent" is not declared.
at org.apache.crim son.parser.Pars er2.error(Parse r2.java:3160)
at
org.apache.crim son.parser.Pars er2.maybeElemen t(Parser2.java: 1322)
at
org.apache.crim son.parser.Pars er2.parseIntern al(Parser2.java :500)
at org.apache.crim son.parser.Pars er2.parse(Parse r2.java:305)
at
org.apache.crim son.parser.XMLR eaderImpl.parse (XMLReaderImpl. java:442)
at javax.xml.parse rs.SAXParser.pa rse(SAXParser.j ava:345)
at javax.xml.parse rs.SAXParser.pa rse(SAXParser.j ava:281)
at V.main(V.java:3 1)
Jul 20 '05 #1
0 3160

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4574
by: SHC | last post by:
Hi all, I have a VC++ .NET 2003 - Windows XP Pro PC. I created a Win32 console application in my VC++ .NET 2003 and copied validateDOM.cpp, books.xml and books.xsd (see the attached files below) from Microfost MSDN Library for my project "validateXML". When I did "Build" on my project, I got the following fatal error C1010: c:\Documents and Settings\SHC\My Documents\Visual Studio Projects\valoidateDOM\valoidateDOM.cpp(273): fatal error...
5
2524
by: Jim Heavey | last post by:
When should you use the Page.Validate() method? I thought you would use this method if you have some Server side validation (CustomControl's) you wanted to use and this would cause them to be invoked. I am probably wrong about that. If I am suppose to use this function, the edits seemed to be invoked even when you have pressed the cancel and the "CausesValidation" is set to false. Is there a way to get around this (might just be an...
11
11754
by: jjbutera | last post by:
I know how to use the ErrorProvider in my winforms..or do I? I validate the values and set the ErrorProvider in the validating event. If not valid, I set e.Cancel = True. I clear the ErrorProvider in the validated event. Is there a way to know if all validated controls pass validation when the user clicks an OK button? In ASP.Net there's the Page.IsValid method. Is there something similar in winforms, or do I still have to write an...
0
2641
by: Marc Scheuner | last post by:
Folks, I'm faced with a dilemma here - I have an XML document and for part of it, I have an XSD schema to validate it - but not for the rest of it. Can I still validate at least part of the XML document? I was hoping to use the XmlDocument.Validate(ValidationEventHandler, XmlNode) method for that - doesn't seem to work...
4
2590
by: Brybot | last post by:
I have a form that i've split up into multiple asp:panels, each panel has a number of validators which work correctly. At on the last panel, i want to commit the data collected to a database. I figured since all the panel data is still being sent through the postbacks, instead of using Sessions, or HttpContext, I could just take the values from the textboxes. This all works fine, except for security. I realized that I could inject...
24
2098
by: Mike Hofer | last post by:
Please forgive the cross-post to multiple forums. I did it intentionally, but I *think* it was appropriate given the nature of my question. I'm working on an open source code library to help automate and clean up parameter validation code. It's almost ready to go into open beta. But one last little glitch is holding me up, and that would be the name of the factory class that serves as the entry point into the library: Validate.
0
8285
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8591
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.