Package org.exist.xquery.value

Examples of org.exist.xquery.value.Item


        Sequence result;
        final Sequence seq = getArgument(0).eval(contextSequence, contextItem);
        if (seq.isEmpty())
            {result = Sequence.EMPTY_SEQUENCE;}
        else {
          final Item item = seq.itemAt(0);
          NumericValue value;
          if (item instanceof NumericValue) {
        value = (NumericValue) item;
      } else {
        value = (NumericValue) item.convertTo(Type.NUMBER);
      }
            result = value.abs();
        }
        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", result);}
View Full Code Here


        Sequence result;
        if (arg.isEmpty()) {
            result = Sequence.EMPTY_SEQUENCE;
        } else {
            result = new ValueSequence();
            Item item;
            for (final SequenceIterator i = arg.iterate(); i.hasNext(); ) {
                item = i.nextItem();
                result.add(item.atomize());
            }
        }
        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", result);}
        return result;
View Full Code Here

       
        Sequence result;
        if (args[0].isEmpty())
          {result = Sequence.EMPTY_SEQUENCE;}
        else {
          final Item arg = args[0].itemAt(0);
          if (!Type.subTypeOf(arg.getType(), Type.ELEMENT))
              {result = Sequence.EMPTY_SEQUENCE;}
            else {
              final Node n = ((NodeValue)arg).getNode();
              //TODO : think more...
              if (n.hasAttributes()) {
View Full Code Here

            Item contextItem) throws XPathException {
        final List<String> args = new ArrayList<String>(getArgumentCount() + 10);
        for (int i = 0; i < getArgumentCount(); i++) {
            final Sequence seq = getArgument(i).eval(contextSequence, contextItem);
            for (final SequenceIterator j = seq.iterate(); j.hasNext();) {
                final Item next = j.nextItem();
                args.add(next.getStringValue());
            }
        }
        return args;
    }
View Full Code Here

      final String lang = getArgument(0).eval(contextSequence).getStringValue();
     
      String langValue = null;
      Sequence seq = null;
      if (contextSequence.hasOne()) {
        final Item item = contextSequence.itemAt(0);
        if (item.getType() == Type.ATTRIBUTE) {
          langValue = item.getStringValue();
        }
      } else {
        seq = query.eval(contextSequence);
      }
     
View Full Code Here

                }
               
    buf.append(") ");
   
    while(i.hasNext()) {
      final Item next = i.nextItem();
      if( Type.subTypeOf( next.getType(), Type.NODE ) ) {
        final Serializer serializer = context.getBroker().getSerializer();
        serializer.reset();
        try {
          buf.append( serializer.serialize( (NodeValue)next ) );
        }
        catch( final SAXException e ) {
          throw( new XPathException(this, "An exception occurred while serializing node to log: " + e.getMessage(), e ) );
        }
      } else {
        buf.append(next.getStringValue());
      }
    }
   
    if( isCalledAs( "log" ) ) {
      final String priority = args[0].getStringValue();     
View Full Code Here

                {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);}
            if (contextItem != null)
                {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());}
        }
       
        Item item = null;
        // check if the node is passed as an argument or should be taken from the context sequence
        if(getArgumentCount() > 0) {
            final Sequence seq = getArgument(0).eval(contextSequence, contextItem);
            if(!seq.isEmpty())
                {item = seq.itemAt(0);}
        } else {
          if (contextItem == null)
              {throw new XPathException(this, ErrorCodes.XPDY0002, "Undefined context item");}
          item = contextItem;
        }
       
        Sequence result;
        if(item == null)
            {result = AnyURIValue.EMPTY_URI;}
        else {         
            if(!Type.subTypeOf(item.getType(), Type.NODE))
                {throw new XPathException(this, ErrorCodes.XPTY0004, "Context item is not a node; got: " +
                        Type.getTypeName(item.getType()));}
            //TODO : how to improve performance ?
            final Node n = ((NodeValue)item).getNode();
            result = new AnyURIValue(n.getNamespaceURI());
        }
       
View Full Code Here

        }
       
        if(contextItem != null)
            {contextSequence = contextItem.toSequence();}
               
        Item item = null;
        // check if the node is passed as an argument or should be taken from
        // the context sequence
        if(getArgumentCount() > 0) {
            final Sequence seq = getArgument(0).eval(contextSequence);
            if (!seq.isEmpty())
                {item = seq.itemAt(0);}
        } else {
          if (contextSequence == null || contextSequence.isEmpty())
            {throw new XPathException(this, ErrorCodes.XPDY0002, "Undefined context item");}
            item = contextSequence.itemAt(0);
        }
       
        Sequence result;
        if (item == null)
            {result = StringValue.EMPTY_STRING;}
        else {
            if (!Type.subTypeOf(item.getType(), Type.NODE))
              {throw new XPathException(this, ErrorCodes.XPTY0004, "item is not a node; got '" + Type.getTypeName(item.getType()) + "'");}         
            //TODO : how to improve performance ?
            final Node n = ((NodeValue)item).getNode();
            result = new StringValue(n.getLocalName());
        }
       
View Full Code Here

    Sequence result;
        final Sequence seq = getArgument(0).eval(contextSequence, contextItem);
    if (seq.isEmpty())
            {result = Sequence.EMPTY_SEQUENCE;}
        else {
          final Item item = seq.itemAt(0);
          NumericValue value;
          if (item instanceof NumericValue) {
        value = (NumericValue) item;
      } else {
        value = (NumericValue) item.convertTo(Type.NUMBER);
      }
        result = value.floor();
        }
       
        if (context.getProfiler().isEnabled())
View Full Code Here

            serializer.reset();
            serializer.setProperty(OutputKeys.INDENT, indent ? "yes" : "no");
            serializer.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, xinclude ? "yes" : "no");
            serializer.setProperty(EXistOutputKeys.HIGHLIGHT_MATCHES, highlight);
           
            Item item;
            int j = 0;
            for (int i = --start; i < start + howmany; i++, j++) {
                item = seq.itemAt(i);
                if (item == null)
                    {continue;}
                if (item.getType() == Type.ELEMENT) {
                    final NodeValue node = (NodeValue) item;
                    xml[j] = serializer.serialize(node);
                } else {
                    xml[j] = item.getStringValue();
                }
            }
            return xml;
        } catch (final Exception e) {
            LOG.warn(e);
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.