Package net.sf.saxon.value

Examples of net.sf.saxon.value.AtomicValue


    /**
    * Iterate over the results of the function
    */

    public SequenceIterator iterate(XPathContext c) throws XPathException {
        AtomicValue sv = (AtomicValue)argument[0].evaluateItem(c);
        if (sv==null) {
            return EmptyIterator.getInstance();
        }
        CharSequence input = sv.getStringValueCS();
        if (input.length() == 0) {
            return EmptyIterator.getInstance();
        }

        RegularExpression re = regexp;
        if (re == null) {

            sv = (AtomicValue)argument[1].evaluateItem(c);
            CharSequence pattern = sv.getStringValueCS();

            CharSequence flags;
            if (argument.length==2) {
                flags = "";
            } else {
                sv = (AtomicValue)argument[2].evaluateItem(c);
                flags = sv.getStringValueCS();
            }

            try {
                final int xmlVersion = c.getConfiguration().getXMLVersion();
                int flagBits = JRegularExpression.setFlags(flags);
View Full Code Here


        // Evaluate the "use" expression against this context node

        SequenceIterator useval = use.iterate(xc);
        while (true) {
            AtomicValue item = (AtomicValue)useval.next();
            if (item == null) {
                break;
            }
            int actualItemType = item.getItemType().getPrimitiveType();
            if (!Type.isComparable(actualItemType, soughtItemType)) {
                // if the types aren't comparable, simply ignore this key value
                break;
            }
            Object val;

            if (soughtItemType==Type.UNTYPED_ATOMIC) {
                // if the supplied key value is untyped atomic, we build an index using the
                // actual type returned by the use expression
                if (collation==null) {
                    val = item.getStringValue();
                } else {
                    val = collation.getCollationKey(item.getStringValue());
                }
            } else if (soughtItemType==Type.STRING) {
                // if the supplied key value is a string, there is no match unless the use expression
                // returns a string or an untyped atomic value
                if (collation==null) {
                    val = item.getStringValue();
                } else {
                    val = collation.getCollationKey(item.getStringValue());
                }
            } else {
                // Ignore NaN values
                if (item instanceof NumericValue && ((NumericValue)item).isNaN()) {
                    break;
                }
                try {
                    val = item.convert(soughtItemType, xc);
                } catch (XPathException err) {
                    // ignore values that can't be converted to the required type
                    break;
                }
            }
View Full Code Here

    /**
    * Evaluate in a general context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        AtomicValue sv = (AtomicValue)argument[0].evaluateItem(c);
        if (sv==null) {
            sv = StringValue.EMPTY_STRING;
        }
        String s = sv.getStringValue();

        if (shortcut) {
            return new IntegerValue((s.length()>0 ? 1 : 0));
        } else {
            return new IntegerValue(StringValue.getLength(s));
View Full Code Here

    */

    public SequenceIterator iterate(XPathContext context) throws XPathException {
        AtomicComparer comparer = getAtomicComparer(2, context);
        SequenceIterator seq = argument[0].iterate(context);
        AtomicValue val = (AtomicValue)argument[1].evaluateItem(context);
        return new IndexIterator(seq, val, comparer);
    }
View Full Code Here

            this.comparer = comparer;
        }

        public Item next() throws XPathException {
            while (true) {
                AtomicValue i = (AtomicValue)base.next();
                if (i==null) break;
                index++;
                if (comparer.comparesEqual(i, value)) {
                    current = new IntegerValue(index);
                    position++;
View Full Code Here

    * Evaluate the function
    */

    public Item evaluateItem(XPathContext context) throws XPathException {

        AtomicValue sv = (AtomicValue)argument[0].evaluateItem(context);
        if (sv==null) {
            sv = StringValue.EMPTY_STRING;
        };
        String s1 = sv.getStringValue();

        sv = (AtomicValue)argument[1].evaluateItem(context);
        String s2 = sv.getStringValue();

        sv = (AtomicValue)argument[2].evaluateItem(context);
        String s3 = sv.getStringValue();

        return new StringValue(translate(s1, s2, s3));
    }
View Full Code Here

    * Evaluate the expression
    */

    public Item evaluateItem(XPathContext context) throws XPathException {
        NamePool namePool = context.getController().getNamePool();
        AtomicValue arg0 = (AtomicValue)argument[0].evaluateItem(context);

        String qname = arg0.getStringValue();
        String[] parts;
        try {
            parts = Name.getQNameParts(qname);
        } catch (QNameException err) {
            dynamicError(err.getMessage(), "FOCA0002", context);
View Full Code Here

    /**
    * Evaluate in a general context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        AtomicValue gp0 = (AtomicValue)argument[0].evaluateItem(c);
        NumericValue gp = (NumericValue)gp0.getPrimitiveValue();
        RegexIterator iter = c.getCurrentRegexIterator();
        if (iter == null) return null;
        String s = iter.getRegexGroup((int)gp.longValue());
        if (s == null) return null;
        return new StringValue(s);
View Full Code Here

    * Evaluate the function in a string context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {

        AtomicValue arg0 = (AtomicValue)argument[0].evaluateItem(c);
        if (arg0==null) {
            return StringValue.EMPTY_STRING;
        }

        AtomicValue arg2 = (AtomicValue)argument[2].evaluateItem(c);
        String replacement = arg2.getStringValue();
        checkReplacement(replacement, c);

        Pattern re = regexp;
        if (re == null) {

            AtomicValue arg1 = (AtomicValue)argument[1].evaluateItem(c);

            String flags;

            if (argument.length == 3) {
                flags = "";
            } else {
                AtomicValue arg3 = (AtomicValue)argument[3].evaluateItem(c);
                flags = arg3.getStringValue();
            }

            try {
                String javaRegex = RegexTranslator.translate(
                        arg1.getStringValue(), true);
View Full Code Here

    * Evaluate in a general context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        Controller controller = c.getController();
        AtomicValue content = (AtomicValue)argument[0].evaluateItem(c);
        StringReader sr = new StringReader(content.getStringValue());
        InputSource is = new InputSource(sr);
        is.setSystemId(baseURI);
        SAXSource source = new SAXSource(is);
        source.setSystemId(baseURI);
        Builder b = controller.makeBuilder();
View Full Code Here

TOP

Related Classes of net.sf.saxon.value.AtomicValue

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.