Package org.exist.xquery.value

Examples of org.exist.xquery.value.NodeValue


    }

    private final Sequence processText(MemTreeBuilder builder, Sequence nodes, int width,
            FunctionReference callback, FunctionReference resultCallback, Sequence extraArgs) throws XPathException {
        final StringBuilder str = new StringBuilder();
        NodeValue node;
        List<Match.Offset> offsets = null;
        NodeProxy firstProxy = null;
       
        // First step: scan the passed node sequence and collect the string values of all nodes.
        // Translate the relative offsets into absolute offsets.
        for (final SequenceIterator i = nodes.iterate(); i.hasNext(); ) {
            node = (NodeValue) i.nextItem();
            if (node.getImplementationType() == NodeValue.IN_MEMORY_NODE)
                {throw new XPathException(this, "Function kwic-display" +
                        " can not be invoked on constructed nodes");}
            NodeProxy proxy = (NodeProxy) node;
            // remember the first node, we need it later
            if (firstProxy == null)
View Full Code Here


      for (int i = 0; i < ql.length; i++) {
                final Item item = nodes.itemAt(i);
                if (!Type.subTypeOf(item.getType(), Type.NODE))
                    {throw new XPathException(this, "XQuery update expressions can only be applied to nodes. Got: " +
                        item.getStringValue());}
                final NodeValue nv = (NodeValue)item;
                if (nv.getImplementationType() == NodeValue.IN_MEMORY_NODE)
                    {throw new XPathException(this, "XQuery update expressions can not be applied to in-memory nodes.");}
                final Node n = nv.getNode();
                if (n.getNodeType() == Node.DOCUMENT_NODE)
                    {throw new XPathException(this, "Updating the document object is not allowed.");}
        ql[i] = (StoredNode) n;
        final DocumentImpl doc = (DocumentImpl)ql[i].getOwnerDocument();
        //prepare Trigger
View Full Code Here

    else {
      int count = 0;
      for(final SequenceIterator i = args[0].iterate(); i.hasNext(); ) {
          final Item next = i.nextItem();
          if(Type.subTypeOf(next.getType(), Type.NODE)) {
              final NodeValue nv = (NodeValue)next;
              if(nv.getImplementationType() != NodeValue.PERSISTENT_NODE)
                {throw new XPathException(this, getName() + " cannot be applied to in-memory nodes.");}
              final NodeProxy np = (NodeProxy)nv;
              Match match = np.getMatches();
              while (match != null) {
                if (match.getNodeId().isDescendantOrSelfOf(np.getNodeId())) {
View Full Code Here

            }

            // Node provided
            final Serializer serializer = context.getBroker().newSerializer();

            final NodeValue node = (NodeValue) item;
            final InputStream is = new NodeInputStream(serializer, node);
            streamSource.setInputStream(is);

        } else if (item.getType() == Type.BASE64_BINARY || item.getType() == Type.HEX_BINARY) {
            LOG.debug("Streaming base64 binary");
View Full Code Here

        context.pushDocumentContext();
       
        final MemTreeBuilder builder = context.getDocumentBuilder();
        final ValueSequence result = new ValueSequence();
        for (final SequenceIterator i = args[0].iterate(); i.hasNext(); ) {
            final NodeValue v = (NodeValue) i.nextItem();
            if (v.getImplementationType() == NodeValue.IN_MEMORY_NODE) {
                result.add(v);
            } else {
                final NodeProxy p = (NodeProxy) v;
                processText(builder, p, result, func, args[2]);
            }
View Full Code Here

   * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence)
   */
  public Sequence eval(Sequence[] args, Sequence contextSequence)
      throws XPathException {
   
    final NodeValue docNode =(NodeValue) args[0].itemAt(0);
                org.exist.numbering.NodeId nodeId;
    if (docNode.getImplementationType() == NodeValue.IN_MEMORY_NODE) {
                    nodeId = ((NodeImpl)docNode).getNodeId();
                } else {
                    nodeId = ((NodeProxy)docNode).getNodeId();
                }
    return new StringValue(nodeId.toString());
View Full Code Here

    // return 0.0 if the argument sequence is empty
    //TODO : return empty sequence ?
    if(args[0].isEmpty())
      {result = DoubleValue.ZERO;}
    else {
      final NodeValue val = (NodeValue)args[0].itemAt(0);
      // Ranking cannot be applied to constructed nodes
      if(val.getImplementationType() == NodeValue.IN_MEMORY_NODE)
        {throw new XPathException(this, getName() + " cannot be applied to in-memory nodes.");}
      final NodeProxy proxy = (NodeProxy)val;  // this is a persistent node, so casting is safe
 
      int freq = 0;
      Match nextMatch = proxy.getMatches();
View Full Code Here

  public Sequence eval(Sequence[] args, Sequence contextSequence)
      throws XPathException {
   
        final String id = args[1].itemAt(0).getStringValue();
        final NodeId nodeId = context.getBroker().getBrokerPool().getNodeFactory().createFromString(id);
        final NodeValue docNode = (NodeValue) args[0].itemAt(0);
        if (docNode.getImplementationType() == NodeValue.IN_MEMORY_NODE) {
            return ((NodeImpl) docNode).getDocument().getNodeById(nodeId);
        } else {
            final DocumentImpl doc = ((NodeProxy)docNode).getDocument();
            return new NodeProxy(doc, nodeId);
        }
View Full Code Here

  private NodeList seq2nodeList(Sequence contentSeq) throws XPathException {
        final NodeListImpl nl = new NodeListImpl();
        for (final SequenceIterator i = contentSeq.iterate(); i.hasNext(); ) {
            final Item item = i.nextItem();
            if (Type.subTypeOf(item.getType(), Type.NODE)) {
                final NodeValue val = (NodeValue) item;
                nl.add(val.getNode());
            }
        }
        return nl;
    }
View Full Code Here

                if(Type.subTypeOf(seq.getItemType(), Type.NODE)) {
                    if (LOG.isDebugEnabled())
                        {LOG.debug("xpointer found: " + seq.getItemCount());}

                    NodeValue node;
                    for (final SequenceIterator i = seq.iterate(); i.hasNext();) {
                        node = (NodeValue) i.nextItem();
                        serializer.serializeToReceiver(node, false);
                    }
                } else {
View Full Code Here

TOP

Related Classes of org.exist.xquery.value.NodeValue

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.