Package net.sf.saxon.event

Examples of net.sf.saxon.event.SequenceReceiver


            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


    */

    public TailCall processLeavingTail(XPathContext context) throws XPathException
    {
        Controller controller = context.getController();
        SequenceReceiver out = context.getReceiver();
        int opt = options;
        int ann = annotation;

      // we may need to change the namespace prefix if the one we chose is
      // already in use with a different namespace URI: this is done behind the scenes
      // by the Outputter

        String value = expandChildren(context).toString();
        if (schemaType != null) {
            // test whether the value actually conforms to the given type
            try {
                schemaType.validateContent(value, DummyNamespaceResolver.getInstance());
                if (schemaType.isNamespaceSensitive()) {
                    opt |= ReceiverOptions.NEEDS_PREFIX_CHECK;
                }
            } catch (ValidationException err) {
                throw new ValidationException("Attribute value " + Err.wrap(value, Err.VALUE) +
                                               " does not the match the required type " +
                                               schemaType.getDescription() + ". " +
                                               err.getMessage());
            }
        } else if (validationAction==Validation.STRICT ||
                validationAction==Validation.LAX) {
            long res = controller.getConfiguration().validateAttribute(nameCode,
                                                                         value,
                                                                         validationAction);
            ann = (int)(res & 0xffffffff);
            opt |= (int)(res >> 32);
        }
        try {
            out.attribute(nameCode, ann, value, locationId, opt);
        } catch (NoOpenStartTagException err) {
            DynamicError e = new DynamicError(
                    "Cannot write an attribute node when no element start tag is open");
            e.setXPathContext(context);
            e.setErrorCode(err.getErrorCode());
View Full Code Here

    public TailCall processLeavingTail(XPathContext context) throws XPathException {
        Controller controller = context.getController();
        XPathContext c2 = context.newMinorContext();
        c2.setOrigin(this);
        SequenceReceiver out = c2.getReceiver();
        TinyBuilder builder = new TinyBuilder();
        Receiver receiver = builder;
        receiver.setConfiguration(controller.getConfiguration());
        receiver.open();
View Full Code Here

    public void typeCheck(StaticContext env, ItemType contextItemType) {

    }

    public TailCall processLeavingTail(XPathContext context) throws XPathException {
        SequenceReceiver out = context.getReceiver();
        out.characters(expandChildren(context), locationId, options);
        return null;
    }
View Full Code Here

                result,
                true,
                validationAction,
                schemaType);
        processChildren(c2);
        SequenceReceiver out = c2.getReceiver();
        out.close();
        if (resolver != null) {
            try {
                resolver.close(result);
            } catch (TransformerException e) {
                throw XPathException.wrap(e);
View Full Code Here

    public TailCall processLeavingTail(XPathContext context) throws XPathException {
        String expandedName = evaluateName(context);
        if (expandedName != null) {
            String data = expandChildren(context).toString();
            data = checkContent(data, context);
            SequenceReceiver out = context.getReceiver();
            out.processingInstruction(expandedName, data, locationId, 0);
        }
        return null;
    }
View Full Code Here

     * @param state   a stack on which the instruction can save state information during the call on processLeft()
     */

    public final void processLeft(Stack<XPathContext> contextStack, Stack state) throws XPathException {
        XPathContext context = contextStack.peek();
        SequenceReceiver out = context.getReceiver();
        state.push(out);
        SequenceOutputter out2 = new SequenceOutputter();
        out2.setPipelineConfiguration(out.getPipelineConfiguration());
        context.setReceiver(out2);
    }
View Full Code Here

     */

    public final void processRight(Stack<XPathContext> contextStack, Stack state) throws XPathException {
        XPathContext context = contextStack.peek();
        SequenceOutputter out2 = (SequenceOutputter)context.getReceiver();
        SequenceReceiver out = (SequenceReceiver)state.pop();
        SequenceIterator iter = out2.iterate();
        FastStringBuffer buff = new FastStringBuffer(100);
        while (true) {
            Item item = iter.next();
            if (item == null) {
View Full Code Here

     * @param context The dynamic context, giving access to the current node,
     *                the current variables, etc.
     */

    public void process(XPathContext context, int locationId, int options) throws XPathException {
        SequenceReceiver out = context.getReceiver();
        if (isSingleton && isAtomic) {
            Item item = select.evaluateItem(context);
            if (item != null) {
                out.characters(item.getStringValueCS(), locationId, options);
            }
        } else {
            SequenceIterator iter = select.iterate(context);
            boolean prevText = false;
            boolean first = true;
            CharSequence sep = null;
            while (true) {
                Item item = iter.next();
                if (item==null) {
                    break;
                }
                if (item instanceof NodeInfo) {
                    if (((NodeInfo)item).getNodeKind() == Type.TEXT) {
                        CharSequence s = item.getStringValueCS();
                        if (s.length() > 0) {
                            if (!first && !prevText) {
                                if (sep == null) {
                                    sep = separator.evaluateItem(context).getStringValueCS();
                                }
                                out.characters(sep, locationId, options);
                            }
                            first = false;
                            out.characters(s, locationId, options);
                            prevText = true;
                        }
                    } else {
                        prevText = false;
                        SequenceIterator iter2 = item.getTypedValue();
                        while (true) {
                            Item item2 = iter2.next();
                            if (item2 == null) {
                                break;
                            }
                            if (!first) {
                                if (sep == null) {
                                    sep = separator.evaluateItem(context).getStringValueCS();
                                }
                                out.characters(sep, locationId, options);
                            }
                            first = false;
                            out.characters(item2.getStringValueCS(), locationId, options);
                        }
                    }
                } else {
                    if (!first) {
                        if (sep == null) {
                            sep = separator.evaluateItem(context).getStringValueCS();
                        }
                        out.characters(sep, locationId, options);
                    }
                    first = false;
                    prevText = false;
                    out.characters(item.getStringValueCS(), locationId, options);
                }
            }
        }

    }
View Full Code Here

     * @return Always returns null
     * @throws XPathException
     */

    public TailCall processLeavingTail(XPathContext context) throws XPathException {
        SequenceReceiver out = context.getReceiver();
        if (select instanceof SimpleContentConstructor) {
            ((SimpleContentConstructor)select).process(context, locationId, options);
        } else {
            Item item = select.evaluateItem(context);
            if (item != null) {
                out.characters(item.getStringValueCS(), locationId, options);
            }
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.event.SequenceReceiver

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.