/// <summary> /// Add an instance document to the list of documents to be validated /// </summary> /// <param name="reader">Source document supplied as an <c>XmlReader</c></param> public void AddSource(XmlReader reader) { JPullProvider pp = new JDotNetPullProvider(reader); JPipelineConfiguration pipe = config.makePipelineConfiguration(); pipe.setUseXsiSchemaLocation(schemaValidator.isUseXsiSchemaLocation()); pp.setPipelineConfiguration(pipe); // pp = new PullTracer(pp); /* diagnostics */ JPullSource psource = new JPullSource(pp); psource.setSystemId(reader.BaseURI); sources.Add(psource); }
/// <summary> /// Supply the instance document to be validated, in the form of an XmlReader. /// </summary> /// <remarks> /// The XmlReader is responsible for parsing the document; this method validates it. /// </remarks> /// <param name="reader">The <c>XmlReader</c> used to read and parse the instance /// document being validated. This is used as supplied. For conformance, use of a /// plain <c>XmlTextReader</c> is discouraged, because it does not expand entity /// references. This may cause validation failures. /// </param> public void SetSource(XmlReader reader) { JPullProvider pp = new JDotNetPullProvider(reader); JPipelineConfiguration pipe = config.makePipelineConfiguration(); pipe.setUseXsiSchemaLocation(useXsiSchemaLocation); pp.setPipelineConfiguration(pipe); // pp = new PullTracer(pp); /* diagnostics */ JPullSource psource = new JPullSource(pp); psource.setSystemId(reader.BaseURI); this.source = psource; sources.Clear(); }
/// <summary> /// Return a Receiver. Saxon calls this method to obtain a Receiver, to which it then sends /// a sequence of events representing the content of an XML document. /// </summary> /// <returns>The receiver to which events are to be sent</returns> /// <param name="pipe">Pipe. The Saxon configuration. This is supplied so that the destination can /// use information from the configuration (for example, a reference to the name pool) /// to construct or configure the returned Receiver.</param> public override JReceiver GetReceiver(JPipelineConfiguration pipe) { builder = (treeModel == TreeModel.TinyTree ? (JBuilder) new JTinyBuilder(pipe) : (JBuilder) new JLinkedTreeBuilder(pipe)); if (baseUri != null) { builder.setBaseURI(baseUri.ToString()); } TreeProtector protector = new TreeProtector(builder); JComplexContentOutputter cco = new JComplexContentOutputter(pipe); JNamespaceReducer reducer = new JNamespaceReducer(protector); cco.setReceiver(reducer); return(cco); }
/// <summary inherit="yes"/> internal JResult GetResult(JPipelineConfiguration pipe) { if (outputStream != null) { return(new JStreamResult(outputStream)); } else if (writer != null) { return(new JStreamResult(writer)); } else { return(new JStreamResult(new JDotNetWriter(Console.Out))); } }
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> /// Run the validation of the supplied source document, optionally /// writing the validated document to the supplied destination. /// </summary> public void Run() { JAugmentedSource aug = JAugmentedSource.makeAugmentedSource(source); aug.setSchemaValidationMode(lax ? JValidation.LAX : JValidation.STRICT); JReceiver receiver; JPipelineConfiguration pipe = config.makePipelineConfiguration(); if (destination == null) { receiver = new JSink(pipe); } else if (destination is Serializer) { receiver = ((Serializer)destination).GetReceiver(config); } else { Result result = destination.GetReceiver(pipe); if (result is JReceiver) { receiver = (JReceiver)result; } else { throw new ArgumentException("Unknown type of destination"); } } pipe.setUseXsiSchemaLocation(useXsiSchemaLocation); receiver.setPipelineConfiguration(pipe); JParseOptions parseOptions = null; if (errorList != null) { invalidityHandler = new net.sf.saxon.lib.InvalidityHandlerWrappingErrorListener(new ErrorGatherer(errorList)); } parseOptions = new JParseOptions(); parseOptions.setInvalidityHandler(invalidityHandler); JSender.send(aug, receiver, parseOptions); }
/// <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); } }
/// <summary> /// Get a <c>Result</c> to which the XML document can be sent as a series /// of events. This method is intended primarily for internal use. /// </summary> /// <remarks> /// The returned value must be an implementation of the JAXP <c>Result</c> interface that is /// recognized by Saxon. /// </remarks> /// <param name="pipe">Configuration information for use by the implementation</param> public abstract JReceiver GetReceiver(JPipelineConfiguration pipe);
/// <summary> /// Gets the receiver. /// </summary> /// <returns>The receiver.</returns> /// <param name="pipe">Pipe. The PipelineConfiguration</param> public override JReceiver GetReceiver(JPipelineConfiguration pipe) { return(new JSink(pipe)); }
/// <summary> /// Return a Receiver. Saxon calls this method to obtain a Receiver, to which it then sends /// a sequence of events representing the content of an XML document. /// </summary> /// <param name="pipe">Pipe. The Saxon pipeline configuration. This is supplied so that the destination can /// use information from the <code>PipelineConfiguration</code> (for example, a reference to the name pool) /// to construct or configure the returned Receiver.</param> /// <returns>The receiver.</returns> public override JReceiver GetReceiver(JPipelineConfiguration pipe) { builder.setPipelineConfiguration(pipe); return(builder); }
public override JReceiver GetReceiver(JPipelineConfiguration pipe) { return(GetReceiver(pipe.getConfiguration())); }
public MessageListenerProxy(JPipelineConfiguration pipe, IMessageListener ml) : base(pipe) { listener = ml; }
public ResultDocumentHandlerWrapper(IResultDocumentHandler handler, JPipelineConfiguration pipe) { this.handler = handler; this.pipe = pipe; }
/// <summary> /// Return a <c>Receiver</c>. Saxon calls this method to obtain a Java <c>Receiver</c>, to which it then sends /// a sequence of events representing the content of an XML document. The method is intended /// primarily for internal use, and may give poor diagnostics if used incorrectly. /// </summary> /// <returns>The receiver</returns> /// <param name="pipe">The Saxon configuration as a <c>JPipelineConfiguration</c>. /// This is supplied so that the destination can /// use information from the configuration (for example, a reference to the name pool) /// to construct or configure the returned <c>Receiver</c>.</param> /// <param name="value2">Serialization parameters known to the caller of the method; typically, output /// properties defined in a stylesheet or query. These will mainly be of interest if the destination is performing serialization, but /// soem properties (such as <c>item-separator</c>) are also used in other situations.</param> public override JReceiver getReceiver(JPipelineConfiguration pipe, JSerializationProperties value2) { return(GetReceiver(pipe, value2)); }