• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSD Validation Failure

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
I have an XSD and The validation is getting failed with the following error message

org.xml.sax.SAXParseException: cvc-length-valid: Value '' with length = '0' is not facet-valid with respect to length '16' for type 'null'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidType(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.processElementContent(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

org.xml.sax.SAXParseException: cvc-type.3.1.3: The value '' of element 'UREF' is not valid.

The XSD Declaration is as follows for the errored element
#########################################################
<xs:element name="UREF" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="16"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
##################################################

I think the BLANK String messages can be parsed successfully.
Kindly suggest a way in the parsing code bt which i can get rid of this error?
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The schema says that the UREF element must have a length of exactly 16 characters. The error message says the offending element has a length of zero characters.

So you have two choices:

1. Fix the XML document to conform with the schema.

2. Process the XML document without validating it against the schema.

If your requirement was to do something in the Java code to get rid of the error, then only #2 will work.
 
Gagan Tiwari
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul

Many thanks for the reply actually the validation is a compulsory step and since we cannot change the XSD as it is shared by 3 parties.

Now since i understand the BLANK Tag is a valid case. (In DTD we can parse it)
Then why its failing in an XSD.

May be there is some step in Parsing itself which takes care of it?
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your schema says the string must be exactly 16 characters. If your requirements say that it's also valid to have a string with 0 characters, then you need to fix your schema to say that. Either you're going to validate against the schema or you aren't. There's nothing you can do in your code to stop specific parts of the schema from working.

I don't know why you bring up DTDs. You're using a schema here, not a DTD.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic