Pierpaolo,
Are you on Java 1.4.2 or V1.5?
I had a similar error when running on 1.4.2 if I did not endorse the
Xerces and JAXP libraries.
brgds
Tim
On 15 Feb 2007, at 17:33, Pierpaolo Vittorini wrote:
As a couple of dozen of million users, I need to validate an xml
document
against an xml schema.
The (relevant portion of the) XML schema follows:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.med.univaq.it/vittorini/
xdtfnse"
xmlns="http://www.med.univaq.it/vittorini/xdtfnse">
<xsd:element name="xdtfnse">
<xsd:complexType>
<xsd:sequence>
...SEVERAL ELEMENTS HERE...
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
The (relevant portion of the) XML document follows:
<?xml version="1.0"?>
<xdtfnse xmlns="http://www.med.univaq.it/vittorini/xdtfnse"
targetNamespace="http://www.med.univaq.it/vittorini/xdtfnse"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.med.univaq.it/vittorini/xdtfnse
xdtfnse.xsd">
... CONTENT ...
</xdtfnse>
Therefore, I wrote a validator in Java (Xerces is
xercesImpl-2.8.1.jar):
try {
SchemaFactory factory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = factory.newSchema(new File("xdtfnse.xsd"));
Validator validator = schema.newValidator();
DocumentBuilder parser =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = parser.parse(new File("doc.xml"));
validator.validate(new DOMSource(document));
} catch (Exception e) {
e.printStackTrace();
}
Unfortunately, when I try to validate the above XML document
against the
Schema, I get the following error:
org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the
declaration of
element 'xdtfnse'.
Question is: wrong namespace? namespace not correctly specified?
After several long searches in the web, I could not find any solution.
Please help me or please let me know where to find an answer.
Kind regards and please apologize if this question already appeared
in the
mailing list, but -- again -- all I found/read about this problem
didn't
suffice.
Pierpaolo Vittorini.
--
Pierpaolo Vittorini, PhD
Assistant Professor
INF/01 - Computer science
Department of Internal Medicine and Public Health
Via S. Salvatore - Edificio Delta 6 - 67010 L'Aquila fraz. Coppito
ITALY
E-mail address: [EMAIL PROTECTED]
Personal web page: http://www.med.univaq.it/vittorini
Phone: +39 0862 434650
Fax: +39 0862 434656
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
___________________________________________________________
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]