Package net.sf.saxon.xpath

Examples of net.sf.saxon.xpath.DynamicError


        try {
            if (lexicalHandler != null) {
                lexicalHandler.comment(chars.toString().toCharArray(), 0, chars.length());
            }
        } catch (SAXException err) {
            throw new DynamicError(err);
        }
    }
View Full Code Here


    public TailCall processLeavingTail(XPathContext context) throws XPathException {
        Controller controller = context.getController();
        String prefix = name.evaluateAsString(context);

        if (!(prefix.equals("") || XMLChar.isValidNCName(prefix))) {
            DynamicError err = new DynamicError("Namespace prefix is invalid: " + prefix, this);
            err.setErrorCode("XT0920");
            err.setXPathContext(context);
            context.getController().recoverableError(err);
            return null;
        }

        if (prefix.equals("xml") || prefix.equals("xmlns")) {
            DynamicError err = new DynamicError("Namespace prefix '" + prefix + "' is not allowed", this);
            err.setErrorCode("XT0920");
            err.setXPathContext(context);
            context.getController().recoverableError(err);
            return null;
        }

        String uri = expandChildren(context).toString();

        if (uri.equals("")) {
            DynamicError err = new DynamicError("Namespace URI is an empty string", this);
            err.setErrorCode("XT0930");
            err.setXPathContext(context);
            context.getController().recoverableError(err);
            return null;
        }

        int nscode = controller.getNamePool().allocateNamespaceCode(prefix, uri);
View Full Code Here

            case ALL_READ:
                return new ListIterator(reservoir);

            case BUSY:
                // this indicates a recursive entry, probably on an error path while printing diagnostics
                throw new DynamicError("Attempt to access a lazily-evaluated variable while it is being evaluated");

            default:
                throw new IllegalStateException("Unknown iterator state");

        }
View Full Code Here

                            res.inCharset(0x3400)) {
                        res = new BuggyCharacterSet(charset);
                    }
                    return res;
                } catch (IllegalCharsetNameException err) {
                    throw new DynamicError("Invalid encoding name: " + encoding);
                } catch (UnsupportedCharsetException err) {
                    //System.err.println("Unknown encoding " + encoding + ": reverting to ASCII");
                    return ASCIICharacterSet.getInstance();
                }
            } else {
                try {
                    Object obj = Loader.getInstance(csname);
                    if (obj instanceof PluggableCharacterSet) {
                        return (PluggableCharacterSet)obj;
                    }
                } catch (Exception err) {
                    throw new DynamicError("Failed to load " + csname);
                }
            }
        }
      return null;
  }
View Full Code Here

        }

    try {
          parser.setFeature("http://xml.org/sax/features/namespaces", true);
        } catch (SAXNotSupportedException err) {    // SAX2 parsers MUST support this feature!
            throw new DynamicError(
                "The SAX2 parser does not recognize the 'namespaces' feature");
      } catch (SAXNotRecognizedException err) {
            throw new DynamicError(
                "The SAX2 parser does not support setting the 'namespaces' feature to true");
      }

    try {
          parser.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
        } catch (SAXNotSupportedException err) {    // SAX2 parsers MUST support this feature!
            throw new DynamicError(
                "The SAX2 parser does not recognize the 'namespace-prefixes' feature");
      } catch (SAXNotRecognizedException err) {
            throw new DynamicError(
                "The SAX2 parser does not support setting the 'namespace-prefixes' feature to false");
      }

        if ((validation & Validation.VALIDATION_MODE_MASK) != Validation.PRESERVE) {
            // Add a document validator to the pipeline
            receiver = config.getDocumentValidator(receiver,
                                                   source.getSystemId(),
                                                   config.getNamePool(),
                                                   validation);
        }

        ReceivingContentHandler ce = new ReceivingContentHandler();
        ce.setReceiver(receiver);
        ce.setConfiguration(config);
        parser.setContentHandler(ce);
      parser.setDTDHandler(ce);

        try {
          parser.setProperty("http://xml.org/sax/properties/lexical-handler", ce);
        } catch (SAXNotSupportedException err) {    // this just means we won't see the comments
      } catch (SAXNotRecognizedException err) {
      }

        try {
            parser.parse(source.getInputSource());
        } catch (SAXException err) {
            Exception nested = err.getException();
            if (nested instanceof XPathException) {
                throw (XPathException)nested;
            } else {
                throw new DynamicError(err);
            }
        } catch (java.io.IOException err) {
            throw new DynamicError(err);
        }
    }
View Full Code Here

                                            DocumentInfo doc,
                                            XPathContext context) throws XPathException {

        List definitions = getKeyDefinitions(fingerprint);
        if (definitions==null) {
            DynamicError de = new DynamicError("Key " +
                context.getController().getNamePool().getDisplayName(fingerprint) +
                          " has not been defined");
            de.setXPathContext(context);
            de.setErrorCode("XT1260");
            throw de;
        }

        HashMap index = new HashMap();
View Full Code Here

        }

        Object indexObject = getIndex(doc, fingerprint, itemType);
        if (indexObject instanceof String) {
            // index is under construction
            DynamicError de = new DynamicError("Key definition is circular");
            de.setXPathContext(context);
            de.setErrorCode("XT0640");
            throw de;
        }
        HashMap index = (HashMap)indexObject;

        // If the index does not yet exist, then create it.
View Full Code Here

    public void startElement (int namecode, int typecode, int locationId, int properties)
    throws XPathException {
        terminated = true;
      // abort the parse when the first start element tag is found
        throw new DynamicError("#start#");
    }
View Full Code Here

                      ( reqTitle==null ) ||
                      ( piTitle!=null && piTitle.equals(reqTitle) ) ) )
            {
                String href = ProcInstParser.getPseudoAttribute(value, "href");
                if (href==null) {
                    throw new DynamicError("xml-stylesheet PI has no href attribute");
                }

        // System.err.println("Adding " + href);
                if (piTitle==null && (piAlternate==null || piAlternate.equals("no"))) {
                    stylesheets.add(0, href);
View Full Code Here

            badDuration("non-numeric component", s);
        }
    }

    protected void badDuration(String msg, CharSequence s) throws XPathException {
        DynamicError err = new DynamicError("Invalid duration value '" + s + "' (" + msg + ")");
        err.setErrorCode("FORG0001");
        throw err;
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.xpath.DynamicError

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.