Announcement Announcement Module
No announcement yet.
XSD validation with CastorMarshaller from Spring Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • XSD validation with CastorMarshaller from Spring

    I am using Spring CastorMarshaller for unmarshalling from xml-> Java.
    I want to validate the xml against the xsd before unmarshalling it.

    I have enabled validation using the following in file.


    # Comma separated list of SAX 2 features that should be enabled for the
    # default parser.

    # True for parser to support Namespaces.
    # Defaults to false.

    # Defines the default XML parser to be used by Castor. .internal.parsers.SAXParser

    The xml file has correct schema defined in xsi:schemaLocation.

    But I always get this trace while unmarshal
    Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'rankings'.
    at erWrapper.createSAXParseException(ErrorHandlerWrap
    at erWrapper.error(
    at porter.reportError(
    at porter.reportError(
    at maValidator.handleStartElement(XMLSchemaValidator. java:1944)
    at maValidator.startElement( 05)
    at entScannerImpl.scanStartElement(XMLNSDocumentScann
    at entScannerImpl$NSContentDispatcher.scanRootElement Hook(
    at tFragmentScannerImpl$FragmentContentDispatcher.dis patch(
    at tFragmentScannerImpl.scanDocument(XMLDocumentFragm
    at nfiguration.parse(
    at nfiguration.parse(
    at er.parse(
    at tSAXParser.parse(
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmar

    Appreciate your help.
    Thanks in advance.