rajeevr
05-28-2009, 11:50 AM
Hi,
I am using Xerces for validating a XML against a XSD. Xsd validation can be done by two ways: noNamespaceSchemaLocation/schemaLocation.
1
I successfully validated it against XSD by using noNamespaceSchemaLocation like this:
<?xml version="1.0"?>
<dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="c:/dictionary.xsd">
2
But I am facing problem in schemaLocation. When I provide schemaLocation which is well accessible and available in my local machine, Xerces throws this error: cvc-elt.1: Cannot find the declaration of element 'dictionary'. I put dictionary.xsd file under tomcat and started the tomcat server. So it is available by http://localhost:8080/a1/dictionary.xsd. But still error continues.
<?xml version="1.0"?>
<dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://localhost:8080/a1/ http://localhost:8080/a1/dictionary.xsd">
XSD File;
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="dictionary" type="dictionaryType"/>
<xsd:complexType name="dictionaryType">
<xsd:sequence>
<xsd:element name="word" type="wordType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
Someone please help me out to understand the exact problem.
Regards,
Rajeev
I am using Xerces for validating a XML against a XSD. Xsd validation can be done by two ways: noNamespaceSchemaLocation/schemaLocation.
1
I successfully validated it against XSD by using noNamespaceSchemaLocation like this:
<?xml version="1.0"?>
<dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="c:/dictionary.xsd">
2
But I am facing problem in schemaLocation. When I provide schemaLocation which is well accessible and available in my local machine, Xerces throws this error: cvc-elt.1: Cannot find the declaration of element 'dictionary'. I put dictionary.xsd file under tomcat and started the tomcat server. So it is available by http://localhost:8080/a1/dictionary.xsd. But still error continues.
<?xml version="1.0"?>
<dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://localhost:8080/a1/ http://localhost:8080/a1/dictionary.xsd">
XSD File;
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="dictionary" type="dictionaryType"/>
<xsd:complexType name="dictionaryType">
<xsd:sequence>
<xsd:element name="word" type="wordType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
Someone please help me out to understand the exact problem.
Regards,
Rajeev