Tabnine Logo
SAXParseException
Code IndexAdd Tabnine to your IDE (free)

How to use
SAXParseException
in
org.xml.sax

Best Java code snippets using org.xml.sax.SAXParseException (Showing top 20 results out of 8,262)

Refine searchRefine arrow

  • ErrorHandler
  • SAXException
  • InputSource
  • URL
  • InputStream
  • SAXParser
  • TransformerException
  • DocumentBuilder
origin: cmusphinx/sphinx4

protected void loadXML() throws IOException {
  try {
    SAXParserFactory factory = SAXParserFactory.newInstance();
    XMLReader xr = factory.newSAXParser().getXMLReader();
    rules = new HashMap<String, JSGFRule>();
    GrXMLHandler handler = new GrXMLHandler(baseURL, rules, logger);
    xr.setContentHandler(handler);
    xr.setErrorHandler(handler);
    InputStream is = baseURL.openStream();
    xr.parse(new InputSource(is));
    is.close();
  } catch (SAXParseException e) {
    String msg = "Error while parsing line " + e.getLineNumber() + " of " + baseURL + ": " + e.getMessage();
    throw new IOException(msg);
  } catch (SAXException e) {
    throw new IOException("Problem with XML: " + e);
  } catch (ParserConfigurationException e) {
    throw new IOException(e.getMessage());
  }
  return;
}

origin: stanfordnlp/CoreNLP

@Override
public void fatalError(SAXParseException ex) throws SAXParseException {
 throw new SAXParseException(makeBetterErrorString("Fatal Error", ex),
     ex.getPublicId(), ex.getSystemId(), ex.getLineNumber(), ex.getColumnNumber());
 // throw new RuntimeException(makeBetterErrorString("Fatal Error", ex));
}
origin: apache/geode

/**
 * Throws back the exception with the name of the XML file and the position where the exception
 * occurred.
 */
@Override
public void error(final SAXParseException exception) throws SAXException {
 throw new SAXParseException("Error while parsing XML at line " + exception.getLineNumber()
   + " column " + exception.getColumnNumber() + ": " + exception.getMessage(), null,
   exception);
}
origin: DozerMapper/dozer

  private String getMessage(String level, SAXParseException e) {
    return "Parsing "
        + level
        + "\n" + "Line:    "
        + e.getLineNumber()
        + "\n" + "URI:     "
        + e.getSystemId() + "\n"
        + "Message: "
        + e.getMessage();
  }
}
origin: nu.validator.htmlparser/htmlparser

    throw new IllegalArgumentException("Null input.");
  if (is.getByteStream() == null && is.getCharacterStream() == null) {
    String systemId = is.getSystemId();
    if (systemId == null) {
      throw new IllegalArgumentException(
      is = new InputSource();
      is.setSystemId(systemId);
      is.setByteStream(new URL(systemId).openStream());
  throw new ParsingException(e.getMessage(), e.getSystemId(), e.getLineNumber(),
      e.getColumnNumber(), e);
} catch (SAXException e) {
  throw new ParsingException(e.getMessage(), e);
origin: org.hibernate/hibernate-annotations

  doc = saxReader.read( new InputSource( xmlInputStream ) );
if ( errors.size() != 0 ) {
  SAXParseException exception = errors.get( 0 );
  final String errorMessage = exception.getMessage();
  for ( SAXParseException error : errors ) {
    errorMessage.append( "Error parsing XML (line" )
        .append( error.getLineNumber() )
        .append( " : column " )
        .append( error.getColumnNumber() )
        .append( "): " )
        .append( error.getMessage() )
        .append( "\n" );
  xmlInputStream.close();
origin: org.apache.ant/ant

  inputSource = new InputSource(inputStream);
  inputSource.setSystemId(uri);
  project.log("parsing buildfile " + bFile + " with URI = " + uri, Project.MSG_VERBOSE);
  HandlerBase hb = new RootHandler(this);
  parser.parse(inputSource);
} catch (SAXParseException exc) {
  Location location = new Location(exc.getSystemId(), exc.getLineNumber(), exc
      .getColumnNumber());
  Throwable t = exc.getException();
  if (t instanceof BuildException) {
    BuildException be = (BuildException) t;
  throw new BuildException(exc.getMessage(), t, location);
} catch (SAXException exc) {
  Throwable t = exc.getException();
  if (t instanceof BuildException) {
    throw (BuildException) t;
  throw new BuildException(exc.getMessage(), t);
} catch (FileNotFoundException exc) {
  throw new BuildException(exc);
origin: robovm/robovm

public void parse(InputSource source) throws SAXException, IOException
  systemId = source.getSystemId();
  contentHandler.setDocumentLocator(this);
          SAXParseException saxException = new SAXParseException(
            "null source systemId" , this);
          errorHandler.fatalError(saxException);
          return;
          final URL url = new URL(systemId);
          stream = url.openStream();
        } catch (MalformedURLException nue) {
          try {
            stream = new FileInputStream(systemId);
          } catch (FileNotFoundException fnfe) {
            final SAXParseException saxException = new SAXParseException(
              "could not open file with systemId "+systemId, this, fnfe);
            errorHandler.fatalError(saxException);
            return;
    final SAXParseException saxException = new SAXParseException(
      "parsing initialization error: "+ex, this, ex);
      final SAXParseException saxException = new SAXParseException(
        "expected start tag not"+pp.getPositionDescription(), this);
    final SAXParseException saxException = new SAXParseException(
      "parsing initialization error: "+ex, this, ex);
origin: ontopia/ontopia

 URLConnection conn = new URL(url).openConnection();        
 parser.parse(new InputSource(conn.getInputStream()));
} catch (SAXParseException e) {
 throw new OntopiaRuntimeException("XML parsing problem: " + e.toString() + " at: "+
                  e.getSystemId() + ":" + e.getLineNumber() + ":" +
                  e.getColumnNumber(), e);
} catch (SAXException e) {
 if (e.getException() instanceof IOException)
  throw new OntopiaRuntimeException(e.getException());
 throw new OntopiaRuntimeException(e);
} catch (Exception e) {
origin: org.fitnesse/fitnesse

private static Document newDocument(InputSource source) throws IOException, SAXException {
 try {
  return getDocumentBuilder().parse(source);
 } catch (SAXParseException e) {
  throw new SAXException(String.format("SAXParseException at line:%d, col:%d, %s", e.getLineNumber(), e.getColumnNumber(), e.getMessage()));
 }
}
origin: org.kuali.maven.impex/torque-generator

  try {
    in = getInputStream(location);
    InputSource is = new InputSource(in);
    is.setSystemId(location);
    parser.parse(is, this);
  } finally {
    in.close();
  throw new EngineException("Sax error on line " + e.getLineNumber() + " column " + e.getColumnNumber() + " : " + e.getMessage(), e);
} catch (Exception e) {
  throw new EngineException(e);
origin: robovm/robovm

String qualifiedName = null;
DocumentType doctype = null;
String inputEncoding = source.getEncoding();
String systemId = source.getSystemId();
DocumentImpl document = new DocumentImpl(
    dom, namespaceURI, qualifiedName, doctype, inputEncoding);
  parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, namespaceAware);
  if (source.getByteStream() != null) {
    parser.setInput(source.getByteStream(), inputEncoding);
  } else if (source.getCharacterStream() != null) {
    parser.setInput(source.getCharacterStream());
  } else if (systemId != null) {
    URL url = new URL(systemId);
    URLConnection urlConnection = url.openConnection();
    urlConnection.connect();
    throw new SAXParseException("InputSource needs a stream, reader or URI", null);
    throw new SAXParseException("Unexpected end of document", null);
  locator.setColumnNumber(ex.getColumnNumber());
  SAXParseException newEx = new SAXParseException(ex.getMessage(), locator);
    errorHandler.error(newEx);
origin: org.apache.ivy/ivy

public PomReader(URL descriptorURL, Resource res) throws IOException, SAXException {
  InputStream stream = new AddDTDFilterInputStream(URLHandlerRegistry.getDefault()
      .openStream(descriptorURL));
  InputSource source = new InputSource(stream);
  source.setSystemId(XMLHelper.toSystemId(descriptorURL));
  try {
    Document pomDomDoc = XMLHelper.parseToDom(source, new EntityResolver() {
          throws SAXException, IOException {
        if ((systemId != null) && systemId.endsWith("m2-entities.ent")) {
          return new InputSource(PomReader.class
              .getResourceAsStream("m2-entities.ent"));
    if (!PROJECT.equals(projectElement.getNodeName())
        && !MODEL.equals(projectElement.getNodeName())) {
      throw new SAXParseException("project must be the root tag", res.getName(),
          res.getName(), 0, 0);
  } finally {
    try {
      stream.close();
    } catch (IOException e) {
origin: com.adobe.blazeds/blazeds-common

if (!in.markSupported())
  in = new BufferedInputStream(in);
if (FileUtils.UTF_8.equals(encoding) || FileUtils.UTF_16.equals(encoding))
  InputSource inputSource = new InputSource(in);
  inputSource.setEncoding(encoding);
  doc = docBuilder.parse(inputSource);
  doc = docBuilder.parse(in);
Integer line = new Integer(ex.getLineNumber());
Integer col = new Integer(ex.getColumnNumber());
String message = ex.getMessage();
e.setMessage(ex.getMessage());
e.setRootCause(ex);
throw e;
origin: tomcat/catalina

    + "] web configuration resource " + source.getSystemId());
  source.setByteStream(stream);
  log.error(sm.getString("contextConfig.defaultParse"), e);
  log.error(sm.getString("contextConfig.defaultPosition",
           "" + e.getLineNumber(),
           "" + e.getColumnNumber()));
  ok = false;
} catch (Exception e) {
  try {
    if (stream != null) {
      stream.close();
origin: commons-io/commons-io

  private boolean doesSaxSupportCharacterSet(final String charSetName) throws ParserConfigurationException, SAXException, IOException {
    final byte[] data = ("<?xml version=\"1.0\" encoding=\"" + charSetName + "\"?><Z/>").getBytes(charSetName);
    final DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    try {
      final InputSource is = new InputSource(new ByteArrayInputStream(data));
      is.setEncoding(charSetName);
      documentBuilder.parse(is);
    } catch (final SAXParseException e) {
      if (e.getMessage().contains(charSetName)) {
        return false;
      }
    }
    return true;
  }
}
origin: org.apache.uima/textmarker-core

public void readXML(InputStream stream, String encoding) throws IOException {
 try {
  InputStreamReader streamReader = new InputStreamReader(stream, encoding);
  this.root = new TextNode();
  XMLEventHandler handler = new XMLEventHandler(root);
  SAXParserFactory factory = SAXParserFactory.newInstance();
  SAXParser parser = factory.newSAXParser();
  XMLReader reader = parser.getXMLReader();
  // XMLReader reader = XMLReaderFactory.createXMLReader();
  reader.setContentHandler(handler);
  reader.setErrorHandler(handler);
  reader.parse(new InputSource(streamReader));
 } catch (SAXParseException spe) {
  StringBuffer sb = new StringBuffer(spe.toString());
  sb.append("\n  Line number: " + spe.getLineNumber());
  sb.append("\n Column number: " + spe.getColumnNumber());
  sb.append("\n Public ID: " + spe.getPublicId());
  sb.append("\n System ID: " + spe.getSystemId() + "\n");
  System.out.println(sb.toString());
 } catch (SAXException se) {
  System.out.println("loadDOM threw " + se);
  se.printStackTrace(System.out);
 } catch (ParserConfigurationException e) {
  e.printStackTrace();
 }
}
origin: Sable/soot

 DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
 DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
 Document doc = docBuilder.parse(new File(fileName));
 System.out.println("Retrieving Metric List from xml file: " + fileName);
 System.out.println("** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId());
 System.out.println(" " + err.getMessage());
} catch (SAXException e) {
 Exception x = e.getException();
 ((x == null) ? e : x).printStackTrace();
} catch (Throwable t) {
origin: ical4j/ical4j

private void parse(InputSource in, ContentHandler handler) throws IOException, ParserException {
  try {
    Document d = BUILDER_FACTORY.newDocumentBuilder().parse(in);
    buildCalendar(d, handler);
  } catch (ParserConfigurationException e) {
    throw new CalendarException(e);
  } catch (SAXException e) {
    if (e instanceof SAXParseException) {
      SAXParseException pe = (SAXParseException) e;
      throw new ParserException("Could not parse XML", pe.getLineNumber(), e);
    }
    throw new ParserException(e.getMessage(), -1, e);
  }
}
origin: apache/royale-compiler

public static void load( final ConfigurationBuffer buffer, final InputStream r, final String path, 
             final String context, String rootElement, boolean ignoreUnknownItems ) throws ConfigurationException
{
  ThreadLocalToolkit.log( new LoadingConfiguration(path) );
  Handler h = new Handler( buffer, path, context, rootElement, ignoreUnknownItems );
  SAXParserFactory factory = SAXParserFactory.newInstance();
  try
  {
    SAXParser parser = factory.newSAXParser();
    InputSource source = new InputSource( r );
    parser.parse( source, h );
  }
  catch (SAXConfigurationException e)
  {
    throw e.innerException;
  }
  catch (SAXParseException e)
  {
    throw new ConfigurationException.OtherThrowable( e, null, path, e.getLineNumber() );
  }
  catch (Exception e)
  {
    throw new ConfigurationException.OtherThrowable( e, null, path, -1 );
  }
}
org.xml.saxSAXParseException

Javadoc

Encapsulate an XML parse error or warning.
This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY. See http://www.saxproject.org for further information.

This exception may include information for locating the error in the original XML document, as if it came from a Locatorobject. Note that although the application will receive a SAXParseException as the argument to the handlers in the org.xml.sax.ErrorHandler interface, the application is not actually required to throw the exception; instead, it can simply read the information in it and take a different action.

Since this exception is a subclass of org.xml.sax.SAXException, it inherits the ability to wrap another exception.

Most used methods

  • getLineNumber
    The line number of the end of the text where the exception occurred.The first line is line 1.
  • getMessage
  • getColumnNumber
    The column number of the end of the text where the exception occurred.The first column in a line is
  • getSystemId
    Get the system identifier of the entity where the exception occurred.If the system identifier is a U
  • <init>
    Wrap an existing exception in a SAXParseException.This constructor is especially useful when an appl
  • getPublicId
    Get the public identifier of the entity where the exception occurred.
  • toString
    Override toString to provide more detailed error message.
  • getException
  • getLocalizedMessage
  • printStackTrace
  • getCause
  • initCause
  • getCause,
  • initCause,
  • init,
  • fillInStackTrace,
  • getStackTrace

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • findViewById (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Kernel (java.awt.image)
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • JPanel (javax.swing)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now