2525import java .io .StringReader ;
2626import java .text .SimpleDateFormat ;
2727import java .util .Date ;
28+
29+ import javax .xml .parsers .ParserConfigurationException ;
30+ import javax .xml .parsers .SAXParserFactory ;
2831import javax .xml .transform .Source ;
2932import javax .xml .transform .sax .SAXSource ;
3033import org .xml .sax .InputSource ;
3134import org .xml .sax .SAXException ;
3235import org .xml .sax .XMLReader ;
33- import org .xml .sax .helpers .XMLReaderFactory ;
3436
3537/**
3638 *
@@ -47,10 +49,12 @@ public static String getStandardXsDateFormat(Date data) {
4749 * Metodo che consente di ignorare i namespace multipli all'interno di un xml passato dalle applicazioni. Senza
4850 * questo filtro JAXB esplode con gli XML che vengono passati.
4951 */
50- public static Source getSaxSourceForUnmarshal (String datiXml ) throws SAXException {
51- XMLReader reader = XMLReaderFactory .createXMLReader ();
52+ public static Source getSaxSourceForUnmarshal (String datiXml ) throws SAXException , ParserConfigurationException {
53+ final SAXParserFactory sax = SAXParserFactory .newInstance ();
54+ sax .setNamespaceAware (true );
55+ final XMLReader xmlReader = sax .newSAXParser ().getXMLReader ();
5256 NamespaceFilterForUnmashal inFilter = new NamespaceFilterForUnmashal ();
53- inFilter .setParent (reader );
57+ inFilter .setParent (xmlReader );
5458 InputSource is = new InputSource (new StringReader (datiXml ));
5559 // Crea un SAXSource specificando il filtro per ignorare i namespaces
5660 return new SAXSource (inFilter , is );
0 commit comments