Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 1st, 2007, 08:17 AM
Registered User
 
Join Date: Oct 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Parse xml (with validation)

When parsing an xml document I would like to use validation (Java/SAXParser).

Just to make sure that my xml doc is valid I have used XMLSpy which told me the xml doc was 100% valid.

When I am parsing the xml doc by the SAXParser in Java the xml is *INVALID*. The reason for this is the error message "A schema cannot contain two global components with the same name; this schema contains two occurrences of...".
This error message make sense, but my XML is structured this way and I would like to keep it like that.

Therefore does anyone know if there is work around or a way to make the SAXParser avoid the above error message? Or do I need to use a different parser? and thirdly why is XMLSpy not complaining like the SAXParser?

Thanks in advance for any help!
 
Old October 1st, 2007, 08:49 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It's a good idea to make sure that an XML Schema that you use is valid against the W3C XML Schema recommendation. Xerces tends to apply more rigorous checks than XML Spy, so in the absence of evidence to the contrary I would assume that Xerces is right to reject your schema and XML Spy is wrong to accept it. If this is true then you need to fix your schema.

Alternatively it's possible that this is a schema composition issue - same object in two different schema documents - and in this case the W3C spec leaves implementations some flexibility. If this is the case then there may be ways of invoking Xerces that avoid the failure condition.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 2nd, 2007, 08:27 AM
Registered User
 
Join Date: Oct 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the answer!






Similar Threads
Thread Thread Starter Forum Replies Last Post
parse xml data everest SQL Server 2005 0 March 6th, 2008 02:40 AM
Parse XML in ASP delaneyp Classic ASP XML 1 February 6th, 2006 08:42 AM
Parse XML response atulb XML 1 October 30th, 2005 07:05 AM
about XML receive by tomcatand XML parse by java taianmhzy Servlets 0 May 20th, 2004 01:59 AM
about XML receive ang XML parse by tomcat taianmhzy Apache Tomcat 0 May 20th, 2004 01:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.