title: SaxParseException in XSD validation does not give element name
body: <p>I have an xsd file and an xml file, I am validating the xml file against the xsd file using the following code</p>
  
  <pre><code>DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          factory.setValidating(true);
          factory.setAttribute(
                  "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                  "http://www.w3.org/2001/XMLSchema");
          factory.setAttribute(
                  "http://java.sun.com/xml/jaxp/properties/schemaSource",
                  new InputSource(new StringReader(xsd)));
          Document doc = null;
          try {
              DocumentBuilder parser = factory.newDocumentBuilder();
              MyErrorHandler errorHandler = new MyErrorHandler();
              parser.setErrorHandler(errorHandler);
              doc = parser.parse(new InputSource(new StringReader(xml))); 
              return true;
          } catch (ParserConfigurationException e) {
              System.out.println("Parser not configured: " + e.getMessage());
          } catch (SAXException e) {
              System.out.print("Parsing XML failed due to a "
                      + e.getClass().getName() + ":");
              System.out.println(e.getMessage());
          } catch (IOException e) {
              System.out.println("IOException thrown");
              e.printStackTrace();
          }
          return false;
  </code></pre>
  
  <p>MyErrorHanlder is </p>
  
  <pre><code>private static class MyErrorHandler implements ErrorHandler {
          public void warning(SAXParseException spe) throws SAXException {
              System.out.println("Warning: " + spe.getMessage() + " getColumnNumber is " + spe.getColumnNumber() + " getLineNumber " + spe.getLineNumber() + " getPublicId " + spe.getPublicId() + " getSystemId " + spe.getSystemId());
          }
  
          public void error(SAXParseException spe) throws SAXException {
              System.out.println("Error: " + spe.getMessage() + " getColumnNumber is " + spe.getColumnNumber() + " getLineNumber " + spe.getLineNumber() + " getPublicId " + spe.getPublicId() + " getSystemId " + spe.getSystemId());
              throw new SAXException("Error: " + spe.getMessage());
          }
  
          public void fatalError(SAXParseException spe) throws SAXException {
              System.out.println("Fatal Error:  " + spe.getMessage() + " getColumnNumber is " + spe.getColumnNumber() + " getLineNumber " + spe.getLineNumber() + " getPublicId " + spe.getPublicId() + " getSystemId " + spe.getSystemId());
              throw new SAXException("Fatal Error: " + spe.getMessage());
          }
      }
  </code></pre>
  
  <p>And when the xml does not comply with xsd I get an exception.. but this exception does not have the name of the xsd element due to which this error has occured .. The message looks like</p>
  
  <p>Parsing XML failed due to a org.xml.sax.SAXException:Error: cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type 'null'. </p>
  
  <p>Instead of printing the name of the xsd element, the error message just has ''. Because of this I am not able to find and display(to the user) the exact element which is causing the error.</p>
  
  <p>My xsd element looks like this </p>
  
  <pre><code>&lt;xs:element name="FullName_FirstName"&gt;
      &lt;xs:annotation&gt;
          &lt;xs:appinfo&gt;
              &lt;ie:label&gt;First Name&lt;/ie:label&gt;
              &lt;ie:html_element&gt;0&lt;/ie:html_element&gt;
          &lt;/xs:appinfo&gt;
      &lt;/xs:annotation&gt;
      &lt;xs:simpleType&gt;
          &lt;xs:restriction base="xs:string"&gt;
              &lt;xs:minLength value="1"/&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
  &lt;/xs:element&gt;
  </code></pre>
  
  <p>Thanks in advance</p>