Package net.sf.saxon.om

Examples of net.sf.saxon.om.DocumentInfo


        props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
        props.setProperty(OutputKeys.INDENT, "yes");

        final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
        final SequenceIterator iter = exp.iterator(dynamicContext);
        final DocumentInfo doc = QueryResult.wrap(iter, config);
        QueryResult.serialize(doc, new StreamResult(System.out), props, config);
    }
View Full Code Here


        // First read the catalog document

        String href = argument[0].evaluateItem(context).getStringValue();

        DocumentInfo catalog =
                (DocumentInfo) Document.makeDoc(href, expressionBaseURI, context);
        if (catalog==null) {
            // we failed to read the catalogue
            dynamicError("Failed to load collection catalogue " + href, context);
            return null;
        }

        // Now return an iterator over the documents that it refers to

        SequenceIterator iter =
                catalog.iterateAxis(Axis.CHILD, NodeKindTest.ELEMENT);
        NodeInfo top = null;
        while (true) {
            top = (NodeInfo)iter.next();
            if (top == null) break;
            if (!("collection".equals(top.getLocalPart()) &&
View Full Code Here

    * the transformation of the constructed document
    */

    public void close() throws XPathException {
        super.close();
        DocumentInfo doc = builder.getCurrentDocument();
        if (doc==null) {
            throw new DynamicError("No source document has been built");
        }
        doc.getNamePool().allocateDocumentNumber(doc);
        try {
            controller.transformDocument(doc, result);
        } catch (TransformerException e) {
            throw XPathException.wrap(e);
        }
View Full Code Here

    public boolean matches(NodeInfo e, XPathContext context) throws XPathException {
        if (e.getNodeKind() != Type.ELEMENT) {
            return false;
        }
        DocumentInfo doc = e.getDocumentRoot();
        if (doc==null) {
            return false;
        }
        AtomicValue idValue = (AtomicValue)idExpression.evaluateItem(context);
        if (idValue == null) {
            return false;
        }
        String ids = idValue.getStringValue();
        if (ids.indexOf(' ') < 0 &&
                ids.indexOf(0x09) < 0 &&
                ids.indexOf(0x0a) < 0 &&
                ids.indexOf(0x0c) < 0) {
            NodeInfo element = doc.selectID(ids);
            if (element==null) return false;
            return (element.isSameNodeInfo(e));
        } else {
            StringTokenizer tokenizer = new StringTokenizer(ids);
            while (tokenizer.hasMoreElements()) {
                String id = (String)tokenizer.nextElement();
                NodeInfo element = doc.selectID(id);
                if (element != null && e.isSameNodeInfo(element)) {
                    return true;
                }
            }
            return false;
View Full Code Here

            Node resultNode = ((DOMResult)result).getNode();
            if (resultNode!=null) {
                if (resultNode instanceof NodeInfo) {
                    // Writing to a SAXON tree is handled specially
                    if (resultNode instanceof DocumentInfo) {
                        DocumentInfo doc = (DocumentInfo)resultNode;
                        if (resultNode.getFirstChild() != null) {
                            throw new DynamicError("Target document must be empty");
                        } else {
                            Builder builder;
                            if (doc instanceof DocumentImpl) {
View Full Code Here

                }
            } else {
                start = (NodeInfo)source;
            }
            if (stripper != null) {
                DocumentInfo docInfo = start.getDocumentRoot();
                StrippedDocument strippedDoc = new StrippedDocument(docInfo, stripper);
                start = strippedDoc.wrap(start);
            }
            return start;
View Full Code Here

    * @param e The NodeInfo representing the Element or other node to be tested against the Pattern
    * @return true if the node matches the Pattern, false otherwise
    */

    public boolean matches(NodeInfo e, XPathContext context) throws XPathException {
        DocumentInfo doc = e.getDocumentRoot();
        if (doc==null) {
            return false;
        }
        KeyManager km = context.getController().getKeyManager();
        SequenceIterator iter = keyexp.iterate(context);
View Full Code Here

                if (sourceInput != null) {
                    if (showTime) {
                        System.err.println("Processing " + sourceInput.getSystemId());
                    }
                    DocumentInfo doc = staticEnv.buildDocument(sourceInput);
                    dynamicEnv.setContextNode(doc);
                }

                try {
                    if (wrap) {
                        SequenceIterator results = exp.iterator(dynamicEnv);
                        DocumentInfo resultDoc = QueryResult.wrap(results, config);
                        QueryResult.serialize(resultDoc,
                                new StreamResult(destination),
                                outputProps,
                                config);
                        destination.close();
View Full Code Here

    */

    public void endDocument() throws SAXException {
        // System.err.println("TransformerHandlerImpl " + this + " endDocument()");
        super.endDocument();
        DocumentInfo doc = builder.getCurrentDocument();
        if (doc==null) {
            throw new SAXException("No source document has been built");
        }
        doc.getNamePool().allocateDocumentNumber(doc);
        try {
            controller.transformDocument(doc, result);
        } catch (TransformerException err) {
            throw new SAXException(err);
        }
View Full Code Here

        Item current = context.getContextItem();
        if (current==null) {
            dynamicError("Finding root of tree: the context item is not set", context);
        }
        if (current instanceof NodeInfo) {
            DocumentInfo doc = ((NodeInfo)current).getDocumentRoot();
            if (doc==null) {
                dynamicError("The root of the tree containing the context item is not a document node", context);
            }
            return doc;
        } else {
View Full Code Here

TOP

Related Classes of net.sf.saxon.om.DocumentInfo

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.