internal JReceiver GetReceiver(Serializer serializer) { net.sf.saxon.expr.instruct.Executable executable = exp.getExecutable(); JConfiguration config = executable.getConfiguration(); JPipelineConfiguration pipe = config.makePipelineConfiguration(); pipe.setHostLanguage(executable.getHostLanguage()); JProperties baseProps = new JProperties(executable.getDefaultOutputProperties()); JCharacterMapIndex charMapIndex = executable.getCharacterMapIndex(); JCharacterMapIndex characterMap = serializer.GetCharacterMap(); if (charMapIndex.isEmpty()) { charMapIndex = characterMap; } else if (characterMap != null && !characterMap.isEmpty() && charMapIndex != characterMap) { // Merge the character maps java.util.Iterator mapIter = characterMap.iterator(); while (mapIter.hasNext()) { net.sf.saxon.serialize.CharacterMap map = (net.sf.saxon.serialize.CharacterMap)mapIter.next(); charMapIndex.putCharacterMap(map.getName(), map); } } JProperties properties = serializer.GetOutputProperties(); object [] propSet = properties.entrySet().toArray(); for (int i = 0; i < properties.size(); i++) { java.util.Map.Entry entry = (java.util.Map.Entry)propSet[i]; net.sf.saxon.om.StructuredQName name = net.sf.saxon.om.StructuredQName.fromClarkName((String)entry.getKey()); net.sf.saxon.expr.instruct.ResultDocument.setSerializationProperty( baseProps, name.getURI(), name.getLocalPart(), (String)entry.getValue(), null, true, config); } serializer.SetDefaultOutputProperties(baseProps); serializer.SetCharacterMap(charMapIndex); JReceiver target = serializer.GetReceiver(pipe); return(target); }
/// <summary> /// Copy an XdmValue to an XmlDestination /// </summary> /// <remarks> /// This method can be used to copy any kind of <c>XdmValue</c> to any kind /// of <c>XdmDestination</c>. The supplied <c>XdmValue</c> is first converted /// to an XML document according to the rules of the XSLT/XQuery serialization /// specification (for example, if the <c>XdmValue</c> is a sequence of atomic /// values, they will be turned in a text node in which the values are converted /// to strings and separated by single spaces). The resulting document is then /// written to the supplied <c>XmlDestination</c>.</remarks> /// <param name="sequence">The value to be written</param> /// <param name="destination">The destination to which the value should be written</param> /// public void WriteXdmValue(XdmValue sequence, XmlDestination destination) { JResult result = destination.GetResult(); JReceiver r = config.getSerializerFactory().getReceiver(result, config.makePipelineConfiguration(), new JProperties()); r = new JNamespaceReducer(r); JTreeReceiver tree = new JTreeReceiver(r); tree.open(); tree.startDocument(0); foreach (XdmItem it in sequence) { tree.append((Item)it.Unwrap(), 0, JNodeInfo.__Fields.ALL_NAMESPACES); } tree.endDocument(); tree.close(); }
/// <summary> /// Copy an XdmValue to an XmlDestination /// </summary> /// <remarks> /// This method can be used to copy any kind of <c>XdmValue</c> to any kind /// of <c>XdmDestination</c>. The supplied <c>XdmValue</c> is first converted /// to an XML document according to the rules of the XSLT/XQuery serialization /// specification (for example, if the <c>XdmValue</c> is a sequence of atomic /// values, they will be turned in a text node in which the values are converted /// to strings and separated by single spaces). The resulting document is then /// written to the supplied <c>XmlDestination</c>.</remarks> /// <param name="sequence">The value to be written</param> /// <param name="destination">The destination to which the value should be written</param> /// public void WriteXdmValue(XdmValue sequence, XmlDestination destination) { try { JPipelineConfiguration pipe = config.makePipelineConfiguration(); JResult result = destination.GetResult(pipe); JReceiver r = config.getSerializerFactory().getReceiver(result, pipe, destination.GetOutputProperties()); r = new JNamespaceReducer(r); JTreeReceiver tree = new JTreeReceiver(r); tree.open(); tree.startDocument(0); foreach (XdmItem it in sequence) { tree.append((Item)it.Unwrap(), 0, JNodeInfo.__Fields.ALL_NAMESPACES); } tree.endDocument(); tree.close(); } catch (JXPathException err) { throw new DynamicError(err); } }
public TreeProtector(JReceiver next) : base(next) { }