/** * Get a SequenceWrapper, a class that serializes an XDM sequence with full annotation of item types, node kinds, * etc. There are variants for Saxon-HE and Saxon-PE * @param destination the place where the wrapped sequence will be sent * @return the new SequenceWrapper */ public SequenceWrapper newSequenceWrapper(Receiver destination) { return new SequenceWrapper(destination); }
/** * Create a sequence wrapper. This creates an XML representation of the items sent to destination * in which the types of all items are made explicit * @param destination the sequence being wrapped */ public SequenceWrapper(Receiver destination) { out = destination; // out = new TracingFilter(out); setPipelineConfiguration(destination.getPipelineConfiguration()); }
/** * Notify an attribute. Attributes are notified after the startElement event, and before any * children. Namespaces and attributes may be intermingled. * * @param nameCode The name of the attribute, as held in the name pool * @param typeCode The type of the attribute, as held in the name pool * @param properties Bit significant value. The following bits are defined: * <dd>DISABLE_ESCAPING</dd> <dt>Disable escaping for this attribute</dt> * <dd>NO_SPECIAL_CHARACTERS</dd> <dt>Attribute value contains no special characters</dt> * @throws IllegalStateException: attempt to output an attribute when there is no open element * start tag */ public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties) throws XPathException { if (depth==0) { out.startElement(resultAttribute, StandardNames.XS_UNTYPED, 0, 0); if ((nameCode &~ NamePool.FP_MASK) != 0) { out.namespace(getNamePool().allocateNamespaceCode(nameCode), 0); } out.attribute(nameCode, typeCode, value, locationId, properties); out.startContent(); out.endElement(); } else { out.attribute(nameCode, typeCode, value, locationId, properties); } }
/** * Output an item (atomic value or node) to the sequence */ public void append(Item item, int locationId, int copyNamespaces) throws XPathException { if (item instanceof AtomicValue) { final NamePool pool = getNamePool(); out.startElement(resultAtomicValue, StandardNames.XS_UNTYPED, 0, 0); AtomicType type = (AtomicType)((AtomicValue)item).getItemType(getConfiguration().getTypeHierarchy()); int nameCode = type.getNameCode(); String prefix = pool.getPrefix(nameCode); String localName = pool.getLocalName(nameCode); String uri = pool.getURI(nameCode); if (prefix.length() == 0) { prefix = pool.suggestPrefixForURI(uri); if (prefix == null) { prefix = "p" + uri.hashCode(); } } int nscode = pool.allocateNamespaceCode(prefix, uri); String displayName = prefix + ':' + localName; out.namespace(nscode, 0); out.attribute(xsiType, StandardNames.XS_UNTYPED_ATOMIC, displayName, 0, 0); out.startContent(); out.characters(item.getStringValue(), 0, 0); out.endElement(); } else { ((NodeInfo)item).copy(this, NodeInfo.ALL_NAMESPACES, true, locationId); } }
/** * Notify an attribute. Attributes are notified after the startElement event, and before any * children. Namespaces and attributes may be intermingled. * * @param nameCode The name of the attribute, as held in the name pool * @param typeCode The type of the attribute, as held in the name pool * @param properties Bit significant value. The following bits are defined: * <dd>DISABLE_ESCAPING</dd> <dt>Disable escaping for this attribute</dt> * <dd>NO_SPECIAL_CHARACTERS</dd> <dt>Attribute value contains no special characters</dt> * @throws IllegalStateException: attempt to output an attribute when there is no open element * start tag */ public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties) throws XPathException { if (depth==0) { out.startElement(resultAttribute, StandardNames.XS_UNTYPED, 0, 0); if ((nameCode &~ NamePool.FP_MASK) != 0) { out.namespace(getNamePool().allocateNamespaceCode(nameCode), 0); } out.attribute(nameCode, typeCode, value, locationId, properties); out.startContent(); out.endElement(); } else { out.attribute(nameCode, typeCode, value, locationId, properties); } }
/** * Output an item (atomic value or node) to the sequence */ public void append(Item item, int locationId, int copyNamespaces) throws XPathException { if (item instanceof AtomicValue) { final NamePool pool = getNamePool(); out.startElement(resultAtomicValue, StandardNames.XS_UNTYPED, 0, 0); AtomicType type = (AtomicType)((AtomicValue)item).getItemType(getConfiguration().getTypeHierarchy()); int nameCode = type.getNameCode(); String prefix = pool.getPrefix(nameCode); String localName = pool.getLocalName(nameCode); String uri = pool.getURI(nameCode); if (prefix.length() == 0) { prefix = pool.suggestPrefixForURI(uri); if (prefix == null) { prefix = "p" + uri.hashCode(); } } int nscode = pool.allocateNamespaceCode(prefix, uri); String displayName = prefix + ':' + localName; out.namespace(nscode, 0); out.attribute(xsiType, StandardNames.XS_UNTYPED_ATOMIC, displayName, 0, 0); out.startContent(); out.characters(item.getStringValue(), 0, 0); out.endElement(); } else { ((NodeInfo)item).copy(this, NodeInfo.ALL_NAMESPACES, true, locationId); } }
/** * Get a SequenceWrapper, a class that serializes an XDM sequence with full annotation of item types, node kinds, * etc. There are variants for Saxon-HE and Saxon-PE * @param destination the place where the wrapped sequence will be sent * @return the new SequenceWrapper */ public SequenceWrapper newSequenceWrapper(Receiver destination) { return new SequenceWrapper(destination); }
final NamePool pool = getNamePool(); out.startElement(resultAtomicValue, Untyped.getInstance(), ExplicitLocation.UNKNOWN_LOCATION, 0); AtomicType type = ((AtomicValue) item).getItemType();
/** * Create a sequence wrapper. This creates an XML representation of the items sent to destination * in which the types of all items are made explicit * @param destination the sequence being wrapped */ public SequenceWrapper(Receiver destination) { out = destination; // out = new TracingFilter(out); setPipelineConfiguration(destination.getPipelineConfiguration()); }
/** * Take a sequence supplied in the form of an iterator and generate a wrapped represention of the * items in the sequence, the wrapped representation being a sequence of events sent to a supplied * Receiver, in which each item is wrapped in a containing element that identifies its type * @param iterator the input sequence * @param destination the Receiver to accept the wrapped output * @since 8.8 */ public static void sendWrappedSequence(SequenceIterator iterator, Receiver destination) throws XPathException { SequenceCopier.copySequence(iterator, new SequenceWrapper(destination)); }
final NamePool pool = getNamePool(); out.startElement(resultAtomicValue, Untyped.getInstance(), ExplicitLocation.UNKNOWN_LOCATION, 0); AtomicType type = ((AtomicValue) item).getItemType();
/** * Take a sequence supplied in the form of an iterator and generate a wrapped represention of the * items in the sequence, the wrapped representation being a sequence of events sent to a supplied * Receiver, in which each item is wrapped in a containing element that identifies its type * @param iterator the input sequence * @param destination the Receiver to accept the wrapped output * @since 8.8 */ public static void sendWrappedSequence(SequenceIterator iterator, Receiver destination) throws XPathException { SequenceCopier.copySequence(iterator, new SequenceWrapper(destination)); }
public void open() throws XPathException { NamePool pool = getNamePool(); resultSequence = pool.allocate("result", RESULT_NS, "sequence"); resultDocument = pool.allocate("result", RESULT_NS, "document"); resultElement = pool.allocate("result", RESULT_NS, "element"); resultAttribute = pool.allocate("result", RESULT_NS, "attribute"); resultText = pool.allocate("result", RESULT_NS, "text"); resultComment = pool.allocate("result", RESULT_NS, "comment"); resultPI = pool.allocate("result", RESULT_NS, "processing-instruction"); resultNamespace = pool.allocate("result", RESULT_NS, "namespace"); resultAtomicValue = pool.allocate("result", RESULT_NS, "atomic-value"); xsiType = pool.allocate("xsi", NamespaceConstant.SCHEMA_INSTANCE, "type"); out.open(); out.startDocument(0); out.startElement(resultSequence, StandardNames.XS_UNTYPED, 0, 0); out.namespace(pool.allocateNamespaceCode("result", RESULT_NS), 0); out.namespace(pool.allocateNamespaceCode("xs", NamespaceConstant.SCHEMA), 0); out.namespace(pool.allocateNamespaceCode("xsi", NamespaceConstant.SCHEMA_INSTANCE), 0); out.startContent(); }
receiver = new SequenceWrapper(receiver);
public void open() throws XPathException { NamePool pool = getNamePool(); resultSequence = pool.allocate("result", RESULT_NS, "sequence"); resultDocument = pool.allocate("result", RESULT_NS, "document"); resultElement = pool.allocate("result", RESULT_NS, "element"); resultAttribute = pool.allocate("result", RESULT_NS, "attribute"); resultText = pool.allocate("result", RESULT_NS, "text"); resultComment = pool.allocate("result", RESULT_NS, "comment"); resultPI = pool.allocate("result", RESULT_NS, "processing-instruction"); resultNamespace = pool.allocate("result", RESULT_NS, "namespace"); resultAtomicValue = pool.allocate("result", RESULT_NS, "atomic-value"); xsiType = pool.allocate("xsi", NamespaceConstant.SCHEMA_INSTANCE, "type"); out.open(); out.startDocument(0); out.startElement(resultSequence, StandardNames.XS_UNTYPED, 0, 0); out.namespace(pool.allocateNamespaceCode("result", RESULT_NS), 0); out.namespace(pool.allocateNamespaceCode("xs", NamespaceConstant.SCHEMA), 0); out.namespace(pool.allocateNamespaceCode("xsi", NamespaceConstant.SCHEMA_INSTANCE), 0); out.startContent(); }
receiver = new SequenceWrapper(outputter); } else {
receiver = new SequenceWrapper(outputter); } else {
receiver = new SequenceWrapper(receiver);