/** * Append an arbitrary item (node, atomic value, or function) to the output. * By default, if the item is an element * node, it is copied with all namespaces. * * @param item the item to be appended * @throws net.sf.saxon.trans.XPathException if the operation fails */ public void append(Item item) throws XPathException { append(item, ExplicitLocation.UNKNOWN_LOCATION, ReceiverOptions.ALL_NAMESPACES); }
/** * Notify character data. Note that some receivers may require the character data to be * sent in a single event, but in general this is not a requirement. * * @param chars The characters * @param locationId an integer which can be interpreted using a LocationMap to return * information such as line number and system ID. If no location information is available, * the value zero is supplied. * @param properties Bit significant value. The following bits are defined: * <dt>DISABLE_ESCAPING</dt> <dd>Disable escaping for this text node</dd> * <dt>USE_CDATA</dt> <dd>Output as a CDATA section</dd> */ public void characters(CharSequence chars, int locationId, int properties) throws XPathException { seq1.characters(chars, locationId, properties); seq2.characters(chars, locationId, properties); }
in = EventStackIterator.flatten(in); int level = 0; out.open(); while (true) { PullEvent event = in.next(); out.characters(((Orphan)event).getStringValueCS(), 0, 0); } else if (event instanceof DocumentInfo && level > 0) { AxisIterator kids = ((DocumentInfo)event).iterateAxis(Axis.CHILD); out.append(node, 0, 0); out.append((Item)event, 0, NodeInfo.ALL_NAMESPACES); } else if (event instanceof StartElementEvent) { StartElementEvent see = (StartElementEvent)event; level++; out.startElement(see.getNameCode(), see.getTypeCode(), 0, ReceiverOptions.NAMESPACE_OK); int[] localNamespaces = see.getLocalNamespaces(); for (int n=0; n<localNamespaces.length; n++) { out.namespace(ns, 0); out.attribute(att.getNameCode(), att.getTypeAnnotation(), att.getStringValueCS(), 0, 0); out.startContent(); } else if (event instanceof EndElementEvent) { level--; out.endElement(); } else if (event instanceof StartDocumentEvent) {
Item item = context.getContextItem(); if (!(item instanceof NodeInfo)) { out.append(item, locationId, NodeInfo.ALL_NAMESPACES); return null; out.characters(source.getStringValueCS(), locationId, 0); break; out.processingInstruction(source.getDisplayName(), source.getStringValueCS(), locationId, 0); break; out.comment(source.getStringValueCS(), locationId, 0); break; if (val != out) { SequenceReceiver sr = new TreeReceiver(val); sr.setPipelineConfiguration(out.getPipelineConfiguration()); c2.setReceiver(sr); out = sr; out.startDocument(0); content.process(c2); out.endDocument(); break;
getSchemaType(), validation); if (ini.getSystemId() == null) { ini.setSystemId(getNewBaseURI(c2)); if (ini.getSystemId() == null) { ini.setSystemId(getNewBaseURI(c2)); ini.open(); int properties = (inheritNamespaces ? 0 : ReceiverOptions.DISINHERIT_NAMESPACES); ini.startElement(nameCode, typeCode, locationId, properties); ini.endElement(); ini.close();
if (item instanceof AtomicValue || item instanceof ExternalObject) { if (previousAtomic) { characters(" ", locationId, 0); characters(item.getStringValueCS(), locationId, 0); previousAtomic = true; } else if (item instanceof ArrayItem) { flatten((ArrayItem)item, locationId, copyNamespaces); } else if (item instanceof Function) { String thing = item instanceof MapItem ? "map" : "function item"; String errorCode = getErrorCodeForDecomposingFunctionItems(); if (errorCode.startsWith("SENR")) { throw new XPathException("Cannot serialize a " + thing + " using this output method", errorCode, locationId); characters(item.getStringValueCS(), locationId, ReceiverOptions.DISABLE_ESCAPING); previousAtomic = false; } else if (node.getNodeKind() == Type.DOCUMENT) { startDocument(0); // needed to ensure that illegal namespaces or attributes in the content are caught node.iterateAxis(AxisInfo.CHILD).forEachOrFail( child -> append(child, locationId, copyNamespaces) ); previousAtomic = false; endDocument(); } else { if (node.getNodeKind() == Type.ATTRIBUTE && ((SimpleType) node.getSchemaType()).isNamespaceSensitive()) { XPathException err = new XPathException("Cannot copy attributes whose type is namespace-sensitive (QName or NOTATION): " + Err.wrap(node.getDisplayName(), Err.ATTRIBUTE)); err.setErrorCode(getPipelineConfiguration().getHostLanguage() == Configuration.XSLT ? "XTTE0950" : "XQTY0086"); throw err;
boolean copyBaseURI = (out.getSystemId() == null); out.characters(source.getStringValueCS(), locationId, 0); break; out.setSystemId(source.getBaseURI()); out.processingInstruction(source.getDisplayName(), source.getStringValueCS(), locationId, 0); break; out.comment(source.getStringValueCS(), locationId, 0); break; source.getBaseURI(), validation, Whitespace.NONE, schemaType, -1); val.setPipelineConfiguration(out.getPipelineConfiguration()); if (copyBaseURI) { val.setSystemId(source.getBaseURI()); out.append(item, locationId, NodeInfo.ALL_NAMESPACES);
rec.startDocument(abort ? ReceiverOptions.TERMINATE : 0); Item item; while ((item = iter.next()) != null) { rec.append(item, getLocation(), ReceiverOptions.ALL_NAMESPACES); rec.endDocument(); rec.close(); context.setReceiver(saved); if (abort) {
SequenceReceiver out = c2.getReceiver(); out.open(); out.startDocument(0); content.process(c2); out.endDocument(); out.close(); if (resolver != null) { try {
rec.startDocument(abort ? ReceiverOptions.TERMINATE : 0); break; rec.append(item, locationId, NodeInfo.ALL_NAMESPACES); rec.endDocument();
protected String getErrorCodeForDecomposingFunctionItems() { boolean isXSLT = getPipelineConfiguration().getHostLanguage() == Configuration.XSLT; return isXSLT ? "XTDE0450" : "XQTY0105"; // Use SENR0001 when doing sequence normalization as per the Serialization spec. }
public SequenceReceiver makeSequenceNormalizer(Receiver receiver, Properties properties) { String method = properties.getProperty(OutputKeys.METHOD); if ("json".equals(method) || "adaptive".equals(method)) { return receiver instanceof SequenceReceiver ? (SequenceReceiver)receiver : new TreeReceiver(receiver); } else { PipelineConfiguration pipe = receiver.getPipelineConfiguration(); SequenceReceiver result; String separator = properties.getProperty(SaxonOutputKeys.ITEM_SEPARATOR); if (separator == null || "#absent".equals(separator)) { result = new SequenceNormalizerWithSpaceSeparator(receiver); } else { result = new SequenceNormalizerWithItemSeparator(receiver, separator); } result.setPipelineConfiguration(pipe); return result; } }
/** * Notify the end of a document node */ public void endDocument() throws XPathException { seq1.endDocument(); seq2.endDocument(); }
/** * Notify the start of a document node */ public void startDocument(int properties) throws XPathException { seq1.startDocument(properties); seq2.startDocument(properties); }
@Override public void open() throws XPathException { super.open(); seq1.open(); seq2.open(); }
/** * Notify the end of an element. The receiver must maintain a stack if it needs to know which * element is ending. */ public void endElement() throws XPathException { seq1.endElement(); seq2.endElement(); }
in = EventStackIterator.flatten(in); int level = 0; out.open(); while (true) { PullEvent event = in.next(); out.characters(((Orphan)event).getStringValueCS(), 0, 0); } else if (event instanceof DocumentInfo && level > 0) { AxisIterator kids = ((DocumentInfo)event).iterateAxis(Axis.CHILD); out.append(node, 0, 0); out.append((Item)event, 0, NodeInfo.ALL_NAMESPACES); } else if (event instanceof StartElementEvent) { StartElementEvent see = (StartElementEvent)event; level++; out.startElement(see.getNameCode(), see.getTypeCode(), 0, ReceiverOptions.NAMESPACE_OK); int[] localNamespaces = see.getLocalNamespaces(); for (int n=0; n<localNamespaces.length; n++) { out.namespace(ns, 0); out.attribute(att.getNameCode(), att.getTypeAnnotation(), att.getStringValueCS(), 0, 0); out.startContent(); } else if (event instanceof EndElementEvent) { level--; out.endElement(); } else if (event instanceof StartDocumentEvent) {