Package org.pdf4j.saxon.om

Examples of org.pdf4j.saxon.om.NodeInfo


     * @return the root of the tree that is currently being built, or that has been most recently built
     *         using this builder
     */

    public NodeInfo getCurrentRoot() {
        NodeInfo physicalRoot = currentRoot;
        if (physicalRoot instanceof DocumentImpl && ((DocumentImpl)physicalRoot).isImaginary()) {
            return ((DocumentImpl)physicalRoot).getDocumentElement();
        } else {
            return physicalRoot;
        }
View Full Code Here


        return true;
    }

    public void validate() throws XPathException {

        NodeInfo parent = getParent();
        global = (parent instanceof XSLStylesheet);

        if (!((parent instanceof StyleElement) && ((StyleElement)parent).mayContainParam())) {
            compileError("xsl:param must be immediately within a template, function or stylesheet", "XTSE0010");
        }

        if (!global) {
            AxisIterator preceding = iterateAxis(Axis.PRECEDING_SIBLING);
            while (true) {
                NodeInfo node = (NodeInfo)preceding.next();
                if (node == null) {
                    break;
                }
                if (node instanceof XSLParam) {
                    if (this.getVariableQName().equals(((XSLParam)node).getVariableQName())) {
                        compileError("The name of the parameter is not unique", "XTSE0580");
                    }
                } else if (node instanceof StyleElement) {
                    compileError("xsl:param must be the first element within a template or function", "XTSE0010");
                } else {
                    // it must be a text node; allow it if all whitespace
                    if (!Whitespace.isWhite(node.getStringValueCS())) {
                        compileError("xsl:param must not be preceded by text", "XTSE0010");
                    }
                }
            }
View Full Code Here

    public void namespaceFixup() {
        NamePool pool = pipe.getConfiguration().getNamePool();
        nameCode = fixup(pool, nameCode, 0);
        if (attributes != null) {
            for (int a=0; a<attributes.size(); a++) {
                NodeInfo oldAtt = (NodeInfo)attributes.get(a);
                int oldCode = oldAtt.getNameCode();
                int newCode = fixup(pool, oldCode, a);
                if (oldCode != newCode) {
                    Orphan att = new Orphan(oldAtt.getConfiguration());
                    att.setNodeKind(Type.ATTRIBUTE);
                    att.setNameCode(newCode);
                    att.setStringValue(oldAtt.getStringValue());
                    att.setTypeAnnotation(oldAtt.getTypeAnnotation());
                    att.setSystemId(oldAtt.getSystemId());
                    attributes.set(a, att);
                }
            }
        }
    }
View Full Code Here

    public static void main(String[] args) throws Exception {
        XPathEvaluator xpe = new XPathEvaluator();
//        XPathVariable in = xpe.declareVariable("", "in");
        XPathExpression exp = xpe.createExpression(
                "for $v in distinct-values(tokenize($in, '/')) return concat(' +', $v)");
        NodeInfo doc = xpe.getConfiguration().buildDocument(new StreamSource(new File(args[0])));
        XPathDynamicContext context = exp.createDynamicContext(doc);
        //context.setVariable(in, new StringValue(args[1]));
        SequenceIterator results = exp.iterate(context);
        while (true) {
            Item item = results.next();
View Full Code Here

    public void stripTypeAnnotations() {
        setTypeCode(StandardNames.XS_UNTYPED);
        if (attributes != null) {
            for (int i=0; i<attributes.size(); i++) {
                NodeInfo att = (NodeInfo)attributes.get(i);
                if (att.getTypeAnnotation() != StandardNames.XS_UNTYPED_ATOMIC) {
                    Orphan o = new Orphan(att.getConfiguration());
                    o.setNodeKind(Type.ATTRIBUTE);
                    o.setNameCode(att.getNameCode());
                    o.setStringValue(att.getStringValue());
                    o.setSystemId(att.getSystemId());
                    o.setTypeAnnotation(StandardNames.XS_UNTYPED_ATOMIC);
                    attributes.set(i, o);
                }
            }
        }
View Full Code Here

                }
                String href = hrefVal.getStringValue();
                if (href.indexOf('#') >= 0) {
                    return this;
                }
                NodeInfo item = Document.preLoadDoc(href, expressionBaseURI, config, this);
                if (item!=null) {
                    return new Literal(new SingletonNode(item));
                }
            } catch (Exception err) {
                // ignore the exception and try again at run-time
View Full Code Here

        AtomicValue hrefVal = (AtomicValue)argument[0].evaluateItem(context);
        if (hrefVal==null) {
            return null;
        }
        String href = hrefVal.getStringValue();
        NodeInfo item = Document.makeDoc(href, expressionBaseURI, context, this);
        if (item==null) {
            // we failed to read the document
            dynamicError("Failed to load document " + href, "FODC0005", context);
            return null;
        }
View Full Code Here

    /**
    * Evaluate in a general context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        NodeInfo start = (NodeInfo)argument[0].evaluateItem(c);
        if (start==null) {
            return null;
        }
        return start.getRoot();
    }
View Full Code Here

    /**
    * Evaluate in a general context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        NodeInfo target;
        if (argument.length > 1) {
            target = (NodeInfo)argument[1].evaluateItem(c);
        } else {
            Item current = c.getContextItem();
            if (current==null) {
View Full Code Here

    public static boolean isLang(String arglang, NodeInfo target) {


        String doclang = null;
        NodeInfo node = target;

        while(node!=null) {
            doclang = node.getAttributeValue(StandardNames.XML_LANG);
            if (doclang!=null) break;
            node = node.getParent();
            if (node==null) return false;
        }

        if (doclang==null) return false;
View Full Code Here

TOP

Related Classes of org.pdf4j.saxon.om.NodeInfo

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.