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)
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)