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

Discussion in 'Java' started by chucky, Apr 1, 2008.

  1. chucky

    chucky Guest

    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)
     
    chucky, Apr 1, 2008
    #1
    1. Advertising

  2. chucky

    Arne Vajhøj Guest

    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
     
    Arne Vajhøj, Apr 1, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    411
  2. Richard Kasperowski

    Boston Mobile March meeting announcement: VXML

    Richard Kasperowski, Feb 13, 2005, in forum: XML
    Replies:
    0
    Views:
    397
    Richard Kasperowski
    Feb 13, 2005
  3. Richard Kasperowski

    Boston Mobile March 24 meeting: VXML

    Richard Kasperowski, Mar 20, 2005, in forum: XML
    Replies:
    0
    Views:
    407
    Richard Kasperowski
    Mar 20, 2005
  4. Replies:
    0
    Views:
    428
  5. Replies:
    0
    Views:
    365
Loading...

Share This Page