Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > XML Validation: Cannot find the declaration of element 'vxml'

Reply
Thread Tools

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

 
 
chucky
Guest
Posts: n/a
 
      04-01-2008
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.ErrorHandl erWrapper.createSAXParseException(ErrorHandlerWrap per.java:
195)
at
com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.error(ErrorHandlerWrapper.java:
131)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(XMLErrorReporter.java:
384)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(XMLErrorReporter.java:
31
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSche maValidator.handleStartElement(XMLSchemaValidator. java:
1887)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSche maValidator.startElement(XMLSchemaValidator.java:
685)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocum entScannerImpl.scanStartElement(XMLNSDocumentScann erImpl.java:
400)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocum entScannerImpl
$NSContentDriver.scanRootElementHook(XMLNSDocument ScannerImpl.java:
626)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl
$FragmentContentDriver.next(XMLDocumentFragmentSca nnerImpl.java:3084)
at com.sun.org.apache.xerces.internal.impl.XMLDocumen tScannerImpl
$PrologDriver.next(XMLDocumentScannerImpl.java:912 )
at
com.sun.org.apache.xerces.internal.impl.XMLDocumen tScannerImpl.next(XMLDocumentScannerImpl.java:
645)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocum entScannerImpl.next(XMLNSDocumentScannerImpl.java:
140)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument(XMLDocumentFragm entScannerImpl.java:
50
at
com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:
807)
at
com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:
737)
at
com.sun.org.apache.xerces.internal.jaxp.validation .StreamValidatorHelper.validate(StreamValidatorHel per.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)
 
Reply With Quote
 
 
 
 
Arne Vajh°j
Guest
Posts: n/a
 
      04-01-2008
chucky wrote:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nokogiri::XML::Schema Cannot find the declaration of element frantisek.svoboda@gmail.com Ruby 0 12-18-2012 09:17 AM
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
Element <link> cannot be nested inside element <div> Rick ASP .Net 1 07-19-2007 01:56 PM
Element TABLE cannot be nested within element 'p' Fred Flintstone ASP .Net 2 09-13-2006 08:15 PM
validate with schema cvc-elt.1: Can't find the declaration of element sk XML 2 06-09-2006 12:29 AM



Advertisments