Package net.sf.saxon.expr

Examples of net.sf.saxon.expr.ExpressionLocation


     * @param location the StAX Location object
     * @return a Saxon/SAX SourceLocator object
     */

    private ExpressionLocation translateLocation(Location location) {
        ExpressionLocation loc = new ExpressionLocation();
        if (location != null) {
            loc.setLineNumber(location.getLineNumber());
            loc.setColumnNumber(location.getColumnNumber());
            loc.setSystemId(location.getSystemId());
            //loc.setPublicId(location.getPublicId());
        }
        return loc;
    }
View Full Code Here


    private class StaxErrorReporter implements XMLReporter {

        public void report(String message, String errorType,
                           Object relatedInformation, Location location)
                throws XMLStreamException {
            ExpressionLocation loc = translateLocation(location);
            XPathException err = new XPathException("Error reported by XML parser: " + message + " (" + errorType + ')');
            err.setLocator(loc);
            try {
                pipe.getErrorListener().error(err);
            } catch (TransformerException e) {
View Full Code Here

    /**
     * Get a SourceLocator for a given locationId, using this location provider
     */

    public SourceLocator getSourceLocation(long locationId) {
        return new ExpressionLocation(locationProvider, locationId);
    }
View Full Code Here

                    hostLanguage,
                    level<0 || currentLevelIsDocument[level],
                    getPipelineConfiguration().isSerializing());
            LocationProvider lp = getPipelineConfiguration().getLocationProvider();
            if (lp != null) {
                err.setLocator(new ExpressionLocation(lp, locationId));
            }
            throw err;
        }

        // if this is a duplicate attribute, overwrite the original, unless
View Full Code Here

                if (false) throw new XmlException("dummy"); // keeps the compiler happy
                //noinspection ConstantIfStatement
                if (false) throw new XmlSchemaException("dummy", new XmlException("dummy")); // keeps the compiler happy
            } catch (XmlException e) {
                XPathException de = new XPathException("Error reported by XML parser: " + e.getMessage(), e);
                ExpressionLocation loc = new ExpressionLocation();
                loc.setSystemId(getSystemId());
                loc.setLineNumber(e.get_LineNumber());
                loc.setColumnNumber(e.get_LinePosition());
                de.setLocator(loc);
                throw de;
            } catch (XmlSchemaException e) {
                XPathException de = new XPathException("Validation error reported by XML parser: " + e.getMessage(), e);
                ExpressionLocation loc = new ExpressionLocation();
                loc.setSystemId(getSystemId());
                loc.setLineNumber(e.get_LineNumber());
                //System.err.println("** parser reported line " + e.get_LineNumber());
                loc.setColumnNumber(e.get_LinePosition());
                de.setLocator(loc);
                throw de;
            } catch (Exception e) {
                // The Microsoft spec says that the only exception thrown is XmlException. But
                // we've seen others, for example System.IO.FileNotFoundException when the DTD can't
                // be located
                XPathException de = new XPathException("Error reported by XML parser: " + e.getMessage(), e);
                ExpressionLocation loc = new ExpressionLocation();
                loc.setSystemId(getSystemId());
                de.setLocator(loc);
                throw de;
            }
            int intype = parser.get_NodeType().Value;
            isEmptyElement = parser.get_IsEmptyElement();
View Full Code Here

    */

    protected void reportError (SAXParseException e, boolean isFatal) {
        if (errorListener != null) {
            try {
                ExpressionLocation loc =
                        new ExpressionLocation(e.getSystemId(), e.getLineNumber(), e.getColumnNumber());
                XPathException err = new XPathException("Error reported by XML parser", loc, e);
                err.setErrorCode(SaxonErrorCode.SXXP0003);
                if (isFatal) {
                    errorListener.fatalError(err);
                } else {
View Full Code Here

                    XPathException err = new XPathException(
                            "Cannot create an element having two attributes with the same name: " +
                            Err.wrap(att.getDisplayName(), Err.ATTRIBUTE));
                    err.setErrorCode("XQDY0025");
                    if (locationId != -1) {
                        err.setLocator(new ExpressionLocation(pipe.getLocationProvider(), locationId));
                    }
                    throw err;
                } else {
                    // In XSLT, the last attribute to be added wins
                    attributes.set(a, att);
View Full Code Here

      * @param location the StAX Location object
      * @return a Saxon/SAX SourceLocator object
      */

     private ExpressionLocation translateLocation(Location location) {
         ExpressionLocation loc = new ExpressionLocation();
         if (location != null) {
             loc.setLineNumber(location.getLineNumber());
             loc.setColumnNumber(location.getColumnNumber());
             loc.setSystemId(location.getSystemId());
             //loc.setPublicId(location.getPublicId());
         }
         return loc;
     }
View Full Code Here

    private class StaxErrorReporter implements XMLReporter {

        public void report(String message, String errorType,
                           Object relatedInformation, Location location)
                throws XMLStreamException {
            ExpressionLocation loc = translateLocation(location);
            XPathException err = new XPathException("Error reported by XML parser: " + message + " (" + errorType + ')');
            err.setLocator(loc);
            try {
                pipe.getErrorListener().error(err);
            } catch (TransformerException e) {
View Full Code Here

     *
     * @param item the item to be written to the sequence
     */

    public void write(Item item) throws XPathException {
        ExpressionLocation loc = new ExpressionLocation();
        if (locationId != -1) {
            LocationProvider provider = getPipelineConfiguration().getLocationProvider();
            loc.setSystemId(provider.getSystemId(locationId));
            loc.setLineNumber(provider.getLineNumber(locationId));
        }
        listener.message(new XdmNode((NodeInfo)item), terminate, loc);
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.expr.ExpressionLocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.