Package net.sf.saxon.om

Examples of net.sf.saxon.om.Orphan


                    break;
                }

            case ATTRIBUTE:
                if (out instanceof SequenceReceiver) {
                    Orphan o = new Orphan(in.getPipelineConfiguration().getConfiguration());
                    o.setNameCode(getNameCode());
                    o.setNodeKind(Type.ATTRIBUTE);
                    o.setStringValue(getStringValue());
                    ((SequenceReceiver)out).append(o, 0, 0);
                    break;
                } else {
                    out.attribute(getNameCode(), getTypeAnnotation(), getStringValue(), 0, 0);
                    break;
                    //throw new XPathException("Cannot serialize a free-standing attribute node");
                }

            case NAMESPACE:
                 if (out instanceof SequenceReceiver) {
                    Orphan o = new Orphan(in.getPipelineConfiguration().getConfiguration());
                    o.setNameCode(getNameCode());
                    o.setNodeKind(Type.NAMESPACE);
                    o.setStringValue(getStringValue());
                    ((SequenceReceiver)out).append(o, 0, 0);
                    break;
                } else {
                     int nsCode = getNamePool().getNamespaceCode(getNameCode());
                     out.namespace(nsCode, 0);
View Full Code Here


            for (int a=0; a<attributes.size(); a++) {
                NodeInfo oldAtt = (NodeInfo)attributes.get(a);
                int oldCode = oldAtt.getNameCode();
                int newCode = fixup(pool, oldCode, a);
                if (oldCode != newCode) {
                    Orphan att = new Orphan(oldAtt.getConfiguration());
                    att.setNodeKind(Type.ATTRIBUTE);
                    att.setNameCode(newCode);
                    att.setStringValue(oldAtt.getStringValue());
                    att.setTypeAnnotation(oldAtt.getTypeAnnotation());
                    att.setSystemId(oldAtt.getSystemId());
                    attributes.set(a, att);
                }
            }
        }
    }
View Full Code Here

        setTypeCode(StandardNames.XS_UNTYPED);
        if (attributes != null) {
            for (int i=0; i<attributes.size(); i++) {
                NodeInfo att = (NodeInfo)attributes.get(i);
                if (att.getTypeAnnotation() != StandardNames.XS_UNTYPED_ATOMIC) {
                    Orphan o = new Orphan(att.getConfiguration());
                    o.setNodeKind(Type.ATTRIBUTE);
                    o.setNameCode(att.getNameCode());
                    o.setStringValue(att.getStringValue());
                    o.setSystemId(att.getSystemId());
                    o.setTypeAnnotation(StandardNames.XS_UNTYPED_ATOMIC);
                    attributes.set(i, o);
                }
            }
        }
    }
View Full Code Here

                                pendingTextNodeIsMutable = false;
                            } else if (pendingTextNodeIsMutable) {
                                FastStringBuffer sb = (FastStringBuffer)((Orphan)pendingTextNode).getStringValueCS();
                                sb.append(((NodeInfo)e).getStringValueCS());
                            } else {
                                Orphan o = new Orphan(config);
                                o.setNodeKind(Type.TEXT);
                                FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.SMALL);
                                sb.append(pendingTextNode.getStringValueCS());
                                sb.append(((NodeInfo)e).getStringValueCS());
                                o.setStringValue(sb);
                                pendingTextNode = o;
                                pendingTextNodeIsMutable = true;
                            }
                            continue;
                        default:
                            if (pendingTextNode != null) {
                                pendingOutput = e;
                                PullEvent next = pendingTextNode;
                                pendingTextNode = null;
                                return next;
                            } else {
                                return e;
                            }
                    }
                } else if (e instanceof AtomicValue) {
                    if (prevAtomic) {
                        FastStringBuffer sb = (FastStringBuffer)((Orphan)pendingTextNode).getStringValueCS();
                        sb.append(' ');
                        sb.append(((AtomicValue)e).getStringValueCS());
                    } else if (pendingTextNode != null) {
                        prevAtomic = true;
                        if (pendingTextNodeIsMutable) {
                            FastStringBuffer sb = (FastStringBuffer)((Orphan)pendingTextNode).getStringValueCS();
                            sb.append(((AtomicValue)e).getStringValueCS());
                        } else {
                            Orphan o = new Orphan(config);
                            o.setNodeKind(Type.TEXT);
                            FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.SMALL);
                            sb.append(pendingTextNode.getStringValueCS());
                            sb.append(((AtomicValue)e).getStringValueCS());
                            o.setStringValue(sb);
                            pendingTextNode = o;
                            pendingTextNodeIsMutable = true;
                        }
                    } else {
                        prevAtomic = true;
                        Orphan o = new Orphan(config);
                        o.setNodeKind(Type.TEXT);
                        FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.SMALL);
                        sb.append(((AtomicValue)e).getStringValueCS());
                        o.setStringValue(sb);
                        pendingTextNode = o;
                        pendingTextNodeIsMutable = true;
                    }
                    //continue;
                } else {
View Full Code Here

                if (controller != null) {
                    context = controller.newXPathContext();
                }
            }
            if (element == null) {
                element = new Orphan(pipe.getConfiguration());
                element.setNodeKind(Type.ELEMENT);
            }
        }
    }
View Full Code Here

        return null;
    }

    public Item evaluateItem(XPathContext context) throws XPathException {
        Orphan o = (Orphan)super.evaluateItem(context);
        if (schemaType != null) {
            try {
                schemaType.validateContent(o.getStringValue(), DummyNamespaceResolver.getInstance());
                o.setTypeAnnotation(schemaType.getFingerprint());
                if (schemaType.isNamespaceSensitive()) {
                    throw new DynamicError("Cannot validate a parentless attribute whose content is namespace-sensitive");
                }
            } catch (ValidationException err) {
                throw new ValidationException("Attribute value " + Err.wrap(o.getStringValue(), Err.VALUE) +
                                               " does not the match the required type " +
                                               schemaType.getDescription() + ". " +
                                               err.getMessage());
            }
        } else if (validationAction==Validation.STRICT ||
                validationAction==Validation.LAX) {
            long res = context.getController().getConfiguration().validateAttribute(nameCode,
                                                                         o.getStringValue(),
                                                                         validationAction);
            int ann = (int)(res & 0xffffffff);
            int opt = (int)(res >> 32);
            if (opt != 0) {
                throw new DynamicError("Cannot validate a parentless attribute whose content is namespace-sensitive");
            }
            o.setTypeAnnotation(ann);
        }

        return o;
    }
View Full Code Here

    }

    public Item evaluateItem(XPathContext context) throws XPathException {
        try {
            CharSequence val = expandChildren(context);
            Orphan o = new Orphan(context.getController().getNamePool());
            o.setNodeKind(Type.TEXT);
            o.setStringValue(val);
            return o;
        } catch (XPathException err) {
            throw new DynamicError(err);
        }
    }
View Full Code Here

                    val = "";
                }
            } else {
                val = item.getStringValueCS();
            }
            Orphan o = new Orphan(context.getController().getConfiguration());
            o.setNodeKind(Type.TEXT);
            o.setStringValue(val);
            return o;
        } catch (XPathException err) {
            err.maybeSetLocation(this);
            throw err;
        }
View Full Code Here

                    val = "";
                }
            } else {
                val = item.getStringValueCS();
            }
            Orphan o = new Orphan(context.getController().getConfiguration());
            o.setNodeKind(Type.TEXT);
            o.setStringValue(val);
            return o;
        } catch (XPathException err) {
            err.maybeSetLocation(this);
            throw err;
        }
View Full Code Here

            for (int a=0; a<attributes.size(); a++) {
                NodeInfo oldAtt = (NodeInfo)attributes.get(a);
                int oldCode = oldAtt.getNameCode();
                int newCode = fixup(pool, oldCode, a);
                if (oldCode != newCode) {
                    Orphan att = new Orphan(oldAtt.getConfiguration());
                    att.setNodeKind(Type.ATTRIBUTE);
                    att.setNameCode(newCode);
                    att.setStringValue(oldAtt.getStringValue());
                    att.setTypeAnnotation(oldAtt.getTypeAnnotation());
                    att.setSystemId(oldAtt.getSystemId());
                    attributes.set(a, att);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.om.Orphan

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.