XML Validation: Cannot find the declaration of element 'vxml'

C

chucky

Hi,
I have a problem validating VoiceXML file. I believe it is trivial,
but I can't figure it out.

This is my program:

public class VxmlValidator {
public static void main(String[] args) throws MalformedURLException,
SAXException, IOException {
SchemaFactory factory =
SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
URL schemaURL = new URL("http://www.w3.org/TR/voicexml20/vxml.xsd");
Schema schema = factory.newSchema(schemaURL);
Validator validator = schema.newValidator();
Source source = new StreamSource(args[0]);
validator.validate(source); // here it fails
}
}


And this is a minimal test.vxml file I am trying to validate:

<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0">
</vxml>


When I run
java VxmlValidator test.vxml
I get the following error message.
Thanks for any help!


Exception in thread "main" org.xml.sax.SAXParseException: cvc-elt.1:
Cannot find the declaration of element 'vxml'.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:
195)
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:
131)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:
384)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:
318)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:
1887)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:
685)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:
400)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl
$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:
626)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3084)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl
$PrologDriver.next(XMLDocumentScannerImpl.java:912)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:
645)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:
140)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:
508)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:
807)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:
737)
at
com.sun.org.apache.xerces.internal.jaxp.validation.StreamValidatorHelper.validate(StreamValidatorHelper.java:
144)
at
com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:
107)
at javax.xml.validation.Validator.validate(Validator.java:127)
at VxmlValidator.main(VxmlValidator.java:22)
 
A

Arne Vajhøj

chucky said:
public class VxmlValidator {
public static void main(String[] args) throws MalformedURLException,
SAXException, IOException {
SchemaFactory factory =
SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
URL schemaURL = new URL("http://www.w3.org/TR/voicexml20/vxml.xsd");
Schema schema = factory.newSchema(schemaURL);
Validator validator = schema.newValidator();
Source source = new StreamSource(args[0]);
validator.validate(source); // here it fails
}
}
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0">
</vxml>
java VxmlValidator test.vxml
Exception in thread "main" org.xml.sax.SAXParseException: cvc-elt.1:
Cannot find the declaration of element 'vxml'.

Try:

<?xml version="1.0" encoding="UTF-8"?>
<vxml:vxml xmlns:vxml="http://www.w3.org/2001/vxml" version="2.0">
</vxml:vxml>

You will get a new exceptions, but that one is more obvious
how to resolve.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top