Salve,
scusate se posto la richiesta in inglese, ma era gia' stata preparata cosi'...


Hello, I have an XML file like this:



<eGov_IT:Intestazione xmlns:eGov_IT="http://www.cnipa.it/schemas/2003/eGovIT/Busta1_0/" xmlns:SOAP_ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cnipa.it/schemas/2003/eGovIT/Busta1_0/

E:\Progetti\EchoPorte\sviluppo\WEBCON~1\WEB-INF\risorse\Messaggio.xsd">



<eGov_IT:IntestazioneMessaggio xmlns:eGov_IT="http://www.cnipa.it/schemas/2003/eGovIT/Busta1_0/">



...



<eGov_IT:Collaborazione>PortaDelegata_PortaDiDomin io_0000001_2007-10-05_12:26</eGov_IT:Collaborazione>



...

<eGov_IT:Identificatore>PortaDelegata_PortaDiDomin io_0000002_2007-10-05_12:26</eGov_IT:Identificatore>



...



</eGov_IT:IntestazioneMessaggio>



---

As you can see there are 2 elements in which the values are really similar. In fact in the Schema we use they have to match the same regular expression; here's the extract from my schema.





<xsd:element name="Collaborazione" type="IdentificatoreType"/>

<xsd:element name="Identificatore" type="IdentificatoreType"/>



<xsd:simpleType name="IdentificatoreType">

<xsd:restriction base="xsd:string">

<xsdattern value="[\w]+_[\w]+_\d{7}_\d{4}\-\d{2}\-\d{2}_\d{2}:\d{2}"/>

</xsd:restriction>

</xsd:simpleType>



I can CORRECTLY validate this expression using this code:





public void validate (String doc, String schema) throws SAXParseException, SAXException

{

try

{

SchemaFactory schemaFactory = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI );



Schema schemaXSD = schemaFactory.newSchema( new File ( schema ) );



Validator validator = schemaXSD.newValidator();



DocumentBuilderFactory.newInstance().newDocumentBu ilder();



ByteArrayInputStream baisDoc = new ByteArrayInputStream(doc.getBytes());



Document document = parser.parse(baisDoc);



validator.validate( new DOMSource( document ) );



...



And, in case the validation fails, I correctly gain a SAXParseException.

The problem is that I can't understand if, in this case, the error is in the "Collaborazione" element or in the "Identificatore" element, because I get the following detailed message from the Exception:



"cvc-pattern-valid: Value '' is not facet-valid with respect to pattern '[\w]+_[\w]+_\d{7}_\d{4}\-\d{2}\-\d{2}_\d{2}:\d{2}' for type 'IdentificatoreType'."



How can I get more detailed informations about this error?


---

In pratica... come posso "migliorare" il codice per avere informazioni dettagliate sull'elemento che scatena l'errore di validazione?
Saluti a tutti,
Cristiano