Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

Validating an XML against an XSD - root element not found

Thread view: 
Andrew Thompson - 23 Sep 2007 11:40 GMT
AAArrrghh!  I have been trying to validate XML
files against XSD files when both are on the
local file system, on and off for the last month.

It is 'almost' working, except that the validator
always reports that the *root* element of the XML
file is missing (for a JNLP file, that would be
the jnlp element).  Frustratingly, apart from that,
it seems to work as I expect.

Here is a zip of the current files (a build file,
the Java source, and some XML and XSD files).
<http://www.physci.org/test/xml/xmlvalidate.zip>
(under 30 Kb).  If you run the build.xml 'launch'
task, it should compile (build etc.) and throw the
GUI onto screen.

The problem can be seen by openning (for example)
yaxv.jnlp (which has an intentionally invalid
attribute - 'tootip') into the left hand side of
the GUI, then loading the JNLP-6.0.xsd into the
RHS of the GUI and clicking the Validate button
(lower left of GUI, above the list).

This will produce an error list of three items.
The second and third relate to the 'tootip', but
I cannot figure why I am getting the first error...
"cvc-elt. 1: Cannot find the delcaration of element 'jnlp'."

If I validate the documents using the ant
xmlvalidate task, it does not show that
first error.  That suggests it is not a
problem with the XSD file (which I developed
based on an initial DTD->XSD conversion by
Piotr Kobzda), but the GUI code I am using.

Can anybody spot the problem that is causing
the first error, and advise how I can 'suppress
it'?

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Andrew Thompson - 24 Sep 2007 08:36 GMT
Solved!

After a lot of searching, it turned out all I needed
to do was add was this line when configuring the
DocumentBuilderFactory..

factory.setAttribute(
 "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation
",
 schemaSource.toString());

Now, to move on with the testing.

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.