Package org.exist.xquery.value

Examples of org.exist.xquery.value.Item


       
        switch(getArgumentCount()) {
            case 3:
                bodies = args[2];
            case 2: {
                Item i = args[1].itemAt(0);
                if ( i != null ) {
                    href = i.getStringValue();
                }
            }
            case 1:
                request = (NodeValue)args[0].itemAt(0);
                break;
View Full Code Here


    }

    @Override
    public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException
    {
        Item item = (Item)args[0].itemAt(0);

        if(!(item instanceof AbstractDateTimeValue))
          throw new XPathException("Function requires one of xs:dateTime, xs:date, or xs:time as first parameter.");

        ValueSequence result = new ValueSequence();
View Full Code Here

    // create the output
    MemTreeBuilder builder = context.getDocumentBuilder();
    DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder);   
    try {
      SequenceIterator i = result.iterate();
      Item next = i.nextItem();   
      StringBuilder buf = null;
            boolean allowAttribs = true;
            while (next != null) {
          context.proceed(this, builder);
        // if item is an atomic value, collect the string values of all
        // following atomic values and seperate them by a space.
        if (Type.subTypeOf(next.getType(), Type.ATOMIC)) {
            if(buf == null)
                buf = new StringBuilder();
          else if (buf.length() > 0)
            buf.append(' ');
          buf.append(next.getStringValue());
                    allowAttribs = false;
                    next = i.nextItem();            // if item is a node, flush any collected character data and
        //  copy the node to the target doc.
        } else if (Type.subTypeOf(next.getType(), Type.NODE)) {
                    if (buf != null && buf.length() > 0) {
            receiver.characters(buf);
            buf.setLength(0);
          }
                    if (next.getType() == Type.ATTRIBUTE && !allowAttribs)
                        throw new XPathException(this, "XQTY0024: An attribute may not appear after " +
                            "another child node.");
                    next.copyTo(context.getBroker(), receiver);
                    allowAttribs = next.getType() == Type.ATTRIBUTE;
                    next = i.nextItem();
        }
            }
      // flush remaining character data
      if (buf != null && buf.length() > 0)
View Full Code Here

      throw new XPathException("Stylesheet has not been prepared.");
   
    //work around for top xpath child::
    Sequence source = new ValueSequence();

    Item xslItem = xmlSource;
    if (xmlSource instanceof Node) {
      xslItem = (Item) ((Node) xmlSource).getOwnerDocument();
    }
    source.add(xslItem);
   
View Full Code Here

   
    //work around for top xpath child::
    Sequence source = new ValueSequence();
//    for (Item item : xmlSource) {
    for (SequenceIterator iterInner = xmlSource.iterate(); iterInner.hasNext();) {
      Item item = iterInner.nextItem();  
     
      Item xslItem = item;
      if (item instanceof Node) {
        xslItem = (Item) ((Node) item).getOwnerDocument();
      }
      source.add(xslItem);
    }
View Full Code Here

            Properties props = new Properties();
            props.setProperty(OutputKeys.INDENT, "yes");
            SAXSerializer serializer = new SAXSerializer(out, props);
            serializer.startDocument();
            for (SequenceIterator i = seq.iterate(); i.hasNext(); ) {
                Item next = i.nextItem();
                next.toSAX(broker, serializer, props);
            }
            serializer.endDocument();
            //TODO : check content
            System.out.println(out.toString());
View Full Code Here

      Sequence selected = select.eval(contextSequence, contextItem);
     
    Collator collator = getCollator(contextSequence, contextItem, 2);   
    TreeMap<AtomicValue, Sequence> map = new TreeMap<AtomicValue, Sequence>(new ValueComparator(collator));

    Item item;
    AtomicValue value;
    NumericValue firstNaN = null;
    for (SequenceIterator i = selected.iterate(); i.hasNext();) {
      item = i.nextItem();
      value = group_by.eval(selected, item).itemAt(0).atomize(); //UNDERSTAND: is it correct?
      if (!map.containsKey(value)) {
        if (Type.subTypeOf(value.getType(), Type.NUMBER)) {
          if (((NumericValue)value).isNaN()) {
            //although NaN does not equal itself, if $arg contains multiple NaN values a single NaN is returned.
            if (firstNaN == null) {
              Sequence seq = new ValueSequence();
              seq.add(item);
              map.put(value, seq);
              firstNaN = (NumericValue)value;
            } else {
              Sequence seq = map.get(firstNaN);
              seq.add(item);
            }
            continue;
          }
        }
        Sequence seq = new ValueSequence();
        seq.add(item);
        map.put(value, seq);
      } else {
        Sequence seq = map.get(value);
        seq.add(item);
      }
    }

    for (Entry<AtomicValue, Sequence> entry : map.entrySet()) {
      for (SequenceIterator iterInner = entry.getValue().iterate(); iterInner.hasNext();) {
              Item each = iterInner.nextItem();  

              //Sequence seq = childNodes.eval(contextSequence, each);
          Sequence answer = super.eval(contextSequence, each);
          result.addAll(answer);
        }
View Full Code Here

                context.proceed(this, builder);

                StringBuilder buf = new StringBuilder();
                for(SequenceIterator i = contentSeq.iterate(); i.hasNext(); ) {
                    context.proceed(this, builder);
                    Item next = i.nextItem();
                    if(buf.length() > 0)
                        buf.append(' ');
                    buf.append(next.getStringValue());
                }

                if (buf.indexOf("--") != Constants.STRING_NOT_FOUND|| buf.toString().endsWith("-")) {
                    throw new XPathException(this, ErrorCodes.XQDY0072, "'" + buf.toString() + "' is not a valid comment");
                }
View Full Code Here

        preselectResult = null;
        LuceneIndexWorker index = (LuceneIndexWorker) context.getBroker().getIndexController().getWorkerByIndexId(LuceneIndex.ID);

        // DW: contextSequence can be null
        DocumentSet docs = contextSequence.getDocumentSet();
        Item key = getKey(contextSequence, null);
        List<QName> qnames = new ArrayList<>(1);
        qnames.add(contextQName);
        Properties options = parseOptions(contextSequence, null);
        try {
            if (Type.subTypeOf(key.getType(), Type.ELEMENT))
                preselectResult = index.query(context, getExpressionId(), docs, useContext ? contextSequence.toNodeSet() : null,
                    qnames, (Element) ((NodeValue)key).getNode(), NodeSet.DESCENDANT, options);
            else
                preselectResult = index.query(context, getExpressionId(), docs, useContext ? contextSequence.toNodeSet() : null,
                    qnames, key.getStringValue(), NodeSet.DESCENDANT, options);
        } catch (IOException | org.apache.lucene.queryparser.classic.ParseException e) {
            throw new XPathException(this, "Error while querying full text index: " + e.getMessage(), e);
        }
        LOG.trace("Lucene query took " + (System.currentTimeMillis() - start));
        if( context.getProfiler().traceFunctions() ) {
View Full Code Here

            else {
                NodeSet inNodes = input.toNodeSet();
                DocumentSet docs = inNodes.getDocumentSet();
                LuceneIndexWorker index = (LuceneIndexWorker)
                        context.getBroker().getIndexController().getWorkerByIndexId(LuceneIndex.ID);
                Item key = getKey(contextSequence, contextItem);
                List<QName> qnames = null;
                if (contextQName != null) {
                    qnames = new ArrayList<>(1);
                    qnames.add(contextQName);
                }
                Properties options = parseOptions(contextSequence, contextItem);
                try {
                    if (Type.subTypeOf(key.getType(), Type.ELEMENT))
                        result = index.query(context, getExpressionId(), docs, inNodes, qnames,
                                (Element)((NodeValue)key).getNode(), NodeSet.ANCESTOR, options);
                    else
                        result = index.query(context, getExpressionId(), docs, inNodes, qnames,
                                key.getStringValue(), NodeSet.ANCESTOR, options);
                } catch (IOException | org.apache.lucene.queryparser.classic.ParseException e) {
                    throw new XPathException(this, e.getMessage());
                }
            }
            if( context.getProfiler().traceFunctions() ) {
View Full Code Here

TOP

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

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.