Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » XML File Validation Using NameSpace
XML File Validation Using NameSpace [message #185572] Thu, 04 January 2007 19:31 Go to next message
Ben Sisson is currently offline Ben SissonFriend
Messages: 202
Registered: July 2009
Senior Member
I have a web service that I created using Eclipse 3.2 and using Apache
Tomcat 5.5.15, with Axis 1.3. I receive an xml file that I want to
validate. I had originally validated this against a schema file that I
knew would always exist using the following code:

Schema schema = this.xmlSchemalValidation(schemaName);

if (schema == null)
return ret_val = BASS_Enumerations.UNDEFINED_ERROR;
Validator v = schema.newValidator();
v.validate(new StreamSource(xml));

which worked fine. Then I was informed that I couldn't use the schema
Name all the time that I needed to use the references in the name space to
validate because they would very some times. I then changed the code to
the following:

// Create URL String from incoming file
String url = "file:" + xml;

final String W3C_XML_SCHEMA = "";

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
MyDefaultHandler dh = new MyDefaultHandler();
Document validDoc = builder.parse(url);
if (!dh.isValid)
ret_val = BASS_Enumerations.UNDEFINED_ERROR;

My understanding was that this would read the schemas specified in the XML
file for valdiation. However, I get the following error:

SAXParseException Error MyDefaultHandler(): cvc-elt.1: Cannot find the
declaration of element 'BOM'.

The XML file looks simlar to this:

<?xml version="1.0" encoding="UTF-8"?>
<!--Created by BOMworks version 1.0-->
<BOM xmlns=""
xsi:schemaLocation=" BOM_v2006.xsd bomworks.xsd">

From what I read it apperars to be setup correctly. I would appreciate
any adivce that you can provide. I notice that the element that it
specifies in the error message is the same as the name space.

Re: XML File Validation Using NameSpace [message #185669 is a reply to message #185572] Fri, 05 January 2007 20:59 Go to previous message
Eclipse UserFriend
Originally posted by:

The namespace is not ment to be a physical location where you can download
the schema. You may need to have an XML Catalog that relates a particular
namespace to a particular XML Schema file. The other option is to use
the schemaLocation attribute to determine which schema file to be used,
but this is only a hint. Your better option is to use the Namespace if
possible and an XML Catalog.

Previous Topic:Extend/use editor in custom plugin (XMLMultiPageEditorPart)
Next Topic:Why is setting up project dependencies so hard?
Goto Forum:

Current Time: Mon May 10 02:57:17 GMT 2021

Powered by FUDForum. Page generated in 0.01412 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top