0

I'm using SAX to build XML file.

The problem is log : org.xml.sax.SAXParseException: cvc-minInclusive-valid: Value '0' is not facet-valid with respect to minInclusive '1' for type 'positiveInteger'.'

I understand the issue : the value '0' is set where a value >0 is necessary. But, is there a method to know which field is concerned ? My XSD contains more than 10 fields with 'positiveInteger' constraint. I would like to avoid using breakpoints to locate the problem.

  • It rather depends on which schema processor you are using. If you don't like the diagnostics from one schema processor, you could always try a different one. – Michael Kay Feb 24 '17 at 20:20
  • That is the question : if SAX can't provide more accurate logs, which processor to use? But it will easier the use the same because the code is already done – Laserator Feb 26 '17 at 12:31
  • If you can show us the source document and schema, then perhaps we can show you what diagnostics some other processors produce to see if they suit you better. Saxon's schema processor allows you to define your own InvalidityHandler callback which allows very detailed error reporting tailored to your needs. – Michael Kay Feb 26 '17 at 16:41
  • I don't know Saxon and I have to keep Sax. However, I found the reason of the bug in my schema. `JAXBContext jaxbContext = JAXBContext.newInstance(beans.myObject.class); marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty(marshaller.JAXB_SCHEMA_LOCATION,"path_to_xsd/ XSD_FILE.xsd"); marshaller.setSchema(schema);` – Laserator Feb 28 '17 at 12:31
  • I don't think you've understood what SAX is. It's an API supported by many different processors, both as provider and as consumer. – Michael Kay Feb 28 '17 at 23:48

0 Answers0