Package net.sf.saxon.om

Examples of net.sf.saxon.om.NodeInfo


    /**
    * Evaluate the function
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        NodeInfo node = (NodeInfo)argument[0].evaluateItem(c);
        if (node==null) {
            return StringValue.EMPTY_STRING;
        }

        try {
            StringWriter result = new StringWriter();
            XPathContext c2 = c.newMinorContext();
        c.setOriginatingConstructType(Location.SAXON_SERIALIZE);

            c2.changeOutputDestination(outputProperties,
                                               new StreamResult(result),
                                               false,
                                               Validation.PRESERVE,
                                               null);
            SequenceReceiver out = c2.getReceiver();
            out.open();
            node.copy(out, NodeInfo.ALL_NAMESPACES, true, locationId);
            out.close();
            return new StringValue(result.toString());
        } catch (XPathException err) {
            throw new DynamicError(err);
        }
View Full Code Here


                index++;
            }
        }

        NodeInfo parent = document.getNode(currentElement).getParent();
        if (parent==null || parent.getNodeKind()==Type.DOCUMENT) {
            if (nodeTest.matches(Type.NAMESPACE, xmlNamespace, -1)) {
                index = 0;
            } else {
                index = -1;
            }
View Full Code Here

        String xmlBase = getAttributeValue(StandardNames.XML_BASE);
        if (xmlBase!=null) {
            return xmlBase;
        }
        String startSystemId = getSystemId();
        NodeInfo parent = getParent();
        if (parent==null) {
            return startSystemId;
        }
        String parentSystemId = parent.getSystemId();
        if (startSystemId.equals(parentSystemId)) {
            return parent.getBaseURI();
        } else {
            return startSystemId;
        }
    }
View Full Code Here

        // now add the namespaces defined on the ancestor nodes. We rely on the receiver
        // to eliminate multiple declarations of the same prefix

        if (includeAncestors && document.isUsingNamespaces()) {
            NodeInfo parent = getParent();
            if (parent != null) {
                parent.outputNamespaceNodes(out, true);
            }
            // terminates when the parent is a root node
        }
    }
View Full Code Here

          // don't close text nodes
          closePending = false;

          // output copy of PI
          NodeInfo pi = document.getNode(next);
          receiver.processingInstruction(pi.getLocalPart(), pi.getStringValue(), locationId, 0);
          break;
                }
      }

      next++;
View Full Code Here

     private void advance() throws XPathException {
         currentMembers = new ArrayList();
         currentMembers.add(current);
         while (true) {
             NodeInfo nextCandidate = (NodeInfo)population.next();
             if (nextCandidate == null) {
                 break;
             }
             if (startPattern.matches(nextCandidate, context)) {
                 next = nextCandidate;
View Full Code Here

    /**
    * Evaluate the function in a string context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        NodeInfo node = (NodeInfo)argument[0].evaluateItem(c);
        if (node==null) {
            // All the functions that allow the argument to be an empty sequence
            // return an empty string, except for node-name()
            if (operation == NODE_NAME) {
                return null;
            } else {
                return StringValue.EMPTY_STRING;
            }
        }

        String s;
        switch (operation) {
            case NAME:
                s = node.getDisplayName();
                break;
            case LOCAL_NAME:
                s = node.getLocalPart();
                break;
            case NAMESPACE_URI:
                String uri = node.getURI();
                s = (uri==null ? "" : uri);
                        // null should no longer be returned, but the spec has changed, so it's
                        // better to be defensive
                break;
            case GENERATE_ID:
                s = node.generateId();
                break;
            case DOCUMENT_URI:
                s = node.getSystemId();
                break;
            case NODE_NAME:
                int nc = node.getNameCode();
                if (nc == -1) {
                    return null;
                }
                return new QNameValue(node.getNamePool(), nc);
            default:
                throw new UnsupportedOperationException("Unknown name operation");
        }
        return new StringValue(s);
    }
View Full Code Here

                Item item = iter.next();
                if (item == null) {
                    break;
                }
                if (item instanceof NodeInfo) {
                    NodeInfo node = (NodeInfo) item;
                    //sb.append(""+node.getDocumentRoot().getDocumentNumber());
                    //sb.append('/');
                    sb.append(node.generateId());
                } else {
                    sb.append("" + Type.displayTypeName(item));
                    sb.append('/');
                    sb.append(item.getStringValue());
                }
View Full Code Here

        // of the called template

        if (template != null) {
            AxisIterator declaredParams = template.iterateAxis(Axis.CHILD);
            while(true) {
                NodeInfo param = (NodeInfo)declaredParams.next();
                if (param == null) {
                    break;
                }
                if (param instanceof XSLParam && ((XSLParam)param).isRequiredParam()
                                              && !((XSLParam)param).isTunnelParam()) {
                    AxisIterator actualParams = iterateAxis(Axis.CHILD);
                    boolean ok = false;
                    while(true) {
                        NodeInfo withParam = (NodeInfo)actualParams.next();
                        if (withParam == null) {
                            break;
                        }
                        if (withParam instanceof XSLWithParam &&
                                ((XSLWithParam)withParam).getVariableFingerprint() ==
                                    ((XSLParam)param).getVariableFingerprint()) {
                            ok = true;
                            break;
                        }
                    }
                    if (!ok) {
                        compileError("No value supplied for required parameter " +
                                ((XSLParam)param).getVariableName(), "XT0690");
                    }
                }
            }


            // check that every supplied parameter is declared in the called
            // template

            AxisIterator actualParams = iterateAxis(Axis.CHILD);
            while(true) {
                NodeInfo w = (NodeInfo)actualParams.next();
                if (w == null) {
                    break;
                }
                if (w instanceof XSLWithParam && !((XSLWithParam)w).isTunnelParam()) {
                    XSLWithParam withParam = (XSLWithParam)w;
                    AxisIterator formalParams = template.iterateAxis(Axis.CHILD);
                    boolean ok = false;
                    while(true) {
                        NodeInfo param = (NodeInfo)formalParams.next();
                        if (param == null) {
                            break;
                        }
                        if (param instanceof XSLParam &&
                                ((XSLParam)param).getVariableFingerprint() ==
View Full Code Here

    public static GlobalOrderComparer getInstance() {
        return instance;
    }

    public int compare(NodeInfo a, NodeInfo b) {
        NodeInfo r1 = a.getRoot();
        NodeInfo r2 = b.getRoot();
        if (r1.isSameNodeInfo(r2)) {
            return a.compareOrder(b);
        }
        int d1 = r1.getDocumentNumber();
        int d2 = r2.getDocumentNumber();
        return d1 - d2;
    }
View Full Code Here

TOP

Related Classes of net.sf.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.