Ecco il codice. Il parser funziona correttamente ma come ti dicevo non riesco a catturare l'eccezione di un errore volontario.
Che robe, è la prima volta che mi succede questa cosa.


package ReaderXSD;

import org.xml.sax.*;
import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import java.io.IOException;


public class ReadSchema {

public ReadSchema(String file) {

DOMParser parser=new DOMParser();

try{
parser.setFeature("http://xml.org/sax/features/validation",true);
parser.setFeature("http://apache.org/xml/features/validation/schema",true);
//parser.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar",false);
//parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
//parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
//parser.setFeature("http://apache.org/xml/features/validation/schema/element-default",true);

}catch (SAXNotRecognizedException e){
System.err.println("lkfdlfkkfl");
}catch (SAXNotSupportedException e){
System.err.println("fdkfjdjfdkjfkfjdkfjdkfj");
}

try{
parser.parse(file);
}catch (SAXParseException e){
System.out.println("Andrà");
}catch (SAXException e){
System.out.println("fdfd");
}catch (IOException e){
System.out.println("defdfdkl");
}catch (Exception e){
System.out.println("gfgfgkflgk");
}
Document doc =parser.getDocument();
traverse(doc);
}

private void name_attribute(Node tag){
for (int i=0; i<tag.getAttributes().getLength(); i++)
{
// Lettura del nome e del valore dell'attributo
if (tag.getAttributes().item(i).getNodeValue()==""){
System.out.println("Attributo: "+tag.getAttributes().item(i).getLocalName()+" = "+"''");
}else{
System.out.println("Attributo: "+tag.getAttributes().item(i).getLocalName()+" = "+ tag.getAttributes().item(i).getNodeValue());
}
}
}
//Procedura Traverse: permette di visitare il documento XML, visualizzandolo nella console.
private void traverse (Node node){

int type=node.getNodeType();
if (type==Node.ELEMENT_NODE)

System.out.println(node.getNodeName().toUpperCase( ));

if (node.hasAttributes()== true)
//System.out.println("TAG: "+node.getNodeName().toUpperCase());
name_attribute(node);
// RIcavo gli attributi del singolo nodo
//AttrList att=node.getAttributes();

NodeList children= node.getChildNodes();
if (children!= null){
int lun=children.getLength();
for (int i=0; i<lun; i++)
traverse (children.item(i));
}
}
//Warning
/*public void warning (SAXParseException e) throws SAXException
{
System.err.println("Warning: "+e);
}

//Error
public void error (SAXParseException e) throws SAXException
{
System.err.println("Error: "+e);
}

//FatalError
public void fatalError (SAXParseException e) throws SAXException
{
System.err.println("Fatal Error: "+e);
}*/

//Main
public static void main(String[] args) throws Exception {
ReadSchema read= new ReadSchema("http://localhost:8080/InvoiceXML.xml");
}
}


Non so come ringraziarti per l'aiuto che mi stai dando. Gentilissimo. Grazie ancora.
DP