Package net.sf.saxon.trans

Examples of net.sf.saxon.trans.XPathException


        } else if (validationAction== Validation.STRICT ||
                validationAction==Validation.LAX) {
            try {
                ann = context.getConfiguration().validateAttribute(nameCode, value, validationAction);
            } catch (ValidationException e) {
                XPathException err = XPathException.makeXPathException(e);
                err.maybeSetErrorCode((validationAction==Validation.STRICT ? "XTTE1510" : "XTTE1515"));
                err.setXPathContext(context);
                err.maybeSetLocation(this);
                err.setIsTypeError(true);
                throw err;
            }
        }
        if ((nameCode & NamePool.FP_MASK) == StandardNames.XML_ID) {
            value = Whitespace.collapseWhitespace(value);
View Full Code Here


        boolean nonUpdating = false;
        for (int i=0; i<children.length; i++) {
            Expression act = children[i];
            if (!ExpressionTool.isAllowedInUpdatingContext(act)) {
                if (updating) {
                    XPathException err = new XPathException(
                            "If any subexpression is updating, then all must be updating", "XUST0001");
                    err.setLocator(children[i]);
                    throw err;
                }
                nonUpdating = true;
            }
            if (act.isUpdatingExpression()) {
                if (nonUpdating) {
                    XPathException err = new XPathException(
                            "If any subexpression is updating, then all must be updating", "XUST0001");
                    err.setLocator(children[i]);
                    throw err;
                }
                updating = true;
            }
        }
View Full Code Here

        try {
            for (int i = 0; i < locations.length; i++) {
                ss[i] = new StreamSource(xqueryComponent.resolveModuleResource(locations[i]).openStream());
            }
        } catch (Exception e) {
            throw new XPathException("Error resolving resource: " + locations, e);
        }
        return ss;
    }
View Full Code Here

        try {
            for (int i = 0; i < locations.length; i++) {
                ss[i] = new StreamSource(xqueryComponent.resolveModuleResource(locations[i]).openStream());
            }
        } catch (Exception e) {
            throw new XPathException("Error resolving resource: " + locations, e);
        }
        return ss;
    }
View Full Code Here

        if (href == null) {
            href = "";
        }

        if (!(href.equals(collectionElement.getAttributeValue(IDNC)) || (href.equals("") && isDefault))) {
            throw new XPathException("Unknown collection name " + href);
        }

        AxisIterator iter = collectionElement.iterateAxis(
                Axis.CHILD, new NameTest(Type.ELEMENT, inputDocumentNC, pool));
        List documents = new ArrayList(5);

        while (true) {
            NodeInfo m = (NodeInfo)iter.next();
            if (m==null) {
                break;
            }
            String shortName = m.getStringValue();
            String longName = "TestSources/" + shortName + ".xml";
            URI uri;
            try {
                uri = new URI(collectionElement.getBaseURI()).resolve(longName);
            } catch (URISyntaxException e) {
                throw new XPathException(e);
            }
            documents.add(new AnyURIValue(uri.toString()));
        }
        return new ListIterator(documents);
    }
View Full Code Here

            } else {
                styleSource = new StreamSource(new File(xsl));
            }
            sheet = f.newTemplates(styleSource);
        } catch (TransformerConfigurationException e) {
            XPathException e2 = XPathException.makeXPathException(e);
            e2.setIsStaticError(true);
            throw e2;
        }

        if (assertion != null) {
            TinyBuilder builder = new TinyBuilder();
            builder.setPipelineConfiguration(config.makePipelineConfiguration());
            ExpressionPresenter presenter = new ExpressionPresenter(config, builder);
            ((PreparedStylesheet)sheet).explain(presenter);
            presenter.close();
            NodeInfo expressionTree = builder.getCurrentRoot();
            XPathEvaluator xpe = new XPathEvaluator(config);
            XPathExpression exp = xpe.createExpression(assertion);
            Boolean bv = (Boolean)exp.evaluateSingle(expressionTree);
            if (!bv.booleanValue()) {
                System.err.println("** Optimization assertion failed");
                presenter = new ExpressionPresenter(config);
                ((PreparedStylesheet)sheet).explain(presenter);
                presenter.close();
                throw new XPathException("Expected optimization not performed");
            }
        }


        Transformer inst;
        try {
            inst = sheet.newTransformer();
        } catch (TransformerConfigurationException e) {
            XPathException e2 = XPathException.makeXPathException(e);
            e2.setIsStaticError(true);
            throw e2;
        }
        if (initialMode != null) {
            ((Controller)inst).setInitialMode(initialMode);
        }
        if (initialTemplate != null) {
            ((Controller)inst).setInitialTemplate(initialTemplate);
        }
        if (params != null) {
            Iterator iter = params.keySet().iterator();
            while (iter.hasNext()) {
                String name = (String)iter.next();
                String value = (String)params.get(name);
                inst.setParameter(name, value);
            }
        }
        if ("strict".equals(validationMode)) {
            ((Controller)inst).setSchemaValidationMode(Validation.STRICT);
        } else {
            ((Controller)inst).setSchemaValidationMode(Validation.STRIP);
        }
        inst.setURIResolver(factory.getURIResolver());
        inst.setErrorListener(errorListener);
        ((Controller)inst).setRecoveryPolicy(recoverRecoverable ? Configuration.RECOVER_SILENTLY : Configuration.DO_NOT_RECOVER);
        // To avoid test results being dependent on the date and time (and timezone), set a fixed
        // date and time for the run
        //((Controller)inst).setCurrentDateTime(new DateTimeValue("2005-01-01T12:49:30.5+01:00"));

        try {
            inst.transform(source, sr);
        } catch (TransformerException e) {
            XPathException e2 = XPathException.makeXPathException(e);
            e2.setIsStaticError(false);
            throw e2;
        }
    }
View Full Code Here

                try {
                    typeName = getNamePool().getDisplayName(annotation);
                } catch (Exception err) {
                    typeName = annotation + "";
                }
                throw new XPathException("Unknown type annotation " +
                        Err.wrap(typeName) + " in document instance");
            } else {
                return stype.getTypedValue(this);
            }
        }
View Full Code Here

            return new UntypedAtomicValue(getStringValueCS());
        } else {
            SchemaType stype = getConfiguration().getSchemaType(annotation);
            if (stype == null) {
                String typeName = getNamePool().getDisplayName(annotation);
                throw new XPathException("Unknown type annotation " +
                        Err.wrap(typeName) + " in document instance");
            } else {
                return stype.atomize(this);
            }
        }
View Full Code Here

        calculator = Calculator.getCalculator(type0.getFingerprint(), type1.getFingerprint(),
                ArithmeticExpression.mapOpCode(operator), mustResolve);

        if (calculator == null) {
            XPathException de = new XPathException("Arithmetic operator is not defined for arguments of types (" +
                    type0.getDescription() + ", " + type1.getDescription() + ")");
            de.setLocator(this);
            de.setErrorCode("XPTY0004");
            throw de;
        }

        try {
            if ((operand0 instanceof Literal) && (operand1 instanceof Literal)) {
View Full Code Here

                throw err;
            }

            // check that it's not a pattern that matches ""
            if (regexp != null && regexp.matches("")) {
                XPathException err = new XPathException("The regular expression in replace() must not be one that matches a zero-length string");
                err.setErrorCode("FORX0003");
                err.setLocator(this);
                throw err;
            }
        }
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.trans.XPathException

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.