/// <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); }
internal JReceiver GetReceiver(JConfiguration config) { return(config.getSerializerFactory().getReceiver( GetResult(), config.makePipelineConfiguration(), GetOutputProperties())); }
internal JReceiver GetReceiver(JConfiguration config) { JPipelineConfiguration pipe = config.makePipelineConfiguration(); return(config.getSerializerFactory().getReceiver( GetResult(pipe), pipe, GetOutputProperties(), characterMap)); }
/// <summary> /// Compile a schema, delivered using an <c>XmlReader</c>. The resulting schema components are added /// to the cache. /// </summary> /// <remarks> /// The <c>XmlReader</c> is responsible for parsing the document; this method builds a tree /// representation of the document (in an internal Saxon format) and compiles it. /// The <c>XmlReader</c> is used as supplied; it is the caller's responsibility to ensure that /// its settings are appropriate for parsing a schema document (for example, that entity references /// are expanded and whitespace is retained). /// </remarks> /// <param name="reader">The <c>XmlReader</c> (that is, the XML parser) used to supply the source schema document</param> public void Compile(XmlReader reader) { JPullProvider pp = new JDotNetPullProvider(reader); pp.setPipelineConfiguration(config.makePipelineConfiguration()); // pp = new PullTracer(pp); /* diagnostics */ JPullSource ss = new JPullSource(pp); ss.setSystemId(reader.BaseURI); schemaManager.load (ss); }
/// <summary> /// Load an XML document, delivered using an XmlReader. /// </summary> /// <remarks> /// <para>The XmlReader is responsible for parsing the document; this method builds a tree /// representation of the document (in an internal Saxon format) and returns its document node. /// The XmlReader is not required to perform validation but it must expand any entity references. /// Saxon uses the properties of the <c>XmlReader</c> as supplied.</para> /// <para>Use of a plain <c>XmlTextReader</c> is discouraged, because it does not expand entity /// references. This should only be used if you know in advance that the document will contain /// no entity references (or perhaps if your query or stylesheet is not interested in the content /// of text and attribute nodes). Instead, with .NET 1.1 use an <c>XmlValidatingReader</c> (with <c>ValidationType</c> /// set to <c>None</c>). The constructor for <c>XmlValidatingReader</c> is obsolete in .NET 2.0, /// but the same effect can be achieved by using the <c>Create</c> method of <c>XmlReader</c> with /// appropriate <c>XmlReaderSettings</c></para> /// <para>Conformance with the W3C specifications requires that the <c>Normalization</c> property /// of an <c>XmlTextReader</c> should be set to <c>true</c>. However, Saxon does not insist /// on this.</para> /// <para>If the <c>XmlReader</c> performs schema validation, Saxon will ignore any resulting type /// information. Type information can only be obtained by using Saxon's own schema validator, which /// will be run if the <c>SchemaValidationMode</c> property is set to <c>Strict</c> or <c>Lax</c></para> /// <para>Note that the Microsoft <c>System.Xml</c> parser does not report whether attributes are /// defined in the DTD as being of type <c>ID</c> and <c>IDREF</c>. This is true whether or not /// DTD-based validation is enabled. This means that such attributes are not accessible to the /// <c>id()</c> and <c>idref()</c> functions.</para> /// <para>Note that setting the <c>XmlResolver</c> property of the <c>DocumentBuilder</c> /// has no effect when this method is used; if an <c>XmlResolver</c> is required, it must /// be set on the <c>XmlReader</c> itself.</para> /// </remarks> /// <param name="reader">The XMLReader that supplies the parsed XML source</param> /// <returns>An <c>XdmNode</c>, the document node at the root of the tree of the resulting /// in-memory document /// </returns> public XdmNode Build(XmlReader reader) { PullProvider pp = new DotNetPullProvider(reader); pp.setPipelineConfiguration(config.makePipelineConfiguration()); // pp = new PullTracer(pp); /* diagnostics */ Source source = new PullSource(pp); source.setSystemId(reader.BaseURI); source = augmentSource(source); DocumentInfo doc = config.buildDocument(source); return((XdmNode)XdmValue.Wrap(doc)); }
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); } }
/// <summary> /// Load an XML document, delivered using an XmlReader. /// </summary> /// <remarks> /// <para>The XmlReader is responsible for parsing the document; this method builds a tree /// representation of the document (in an internal Saxon format) and returns its document node. /// The XmlReader is not required to perform validation but it must expand any entity references. /// Saxon uses the properties of the <c>XmlReader</c> as supplied.</para> /// <para>Use of a plain <c>XmlTextReader</c> is discouraged, because it does not expand entity /// references. This should only be used if you know in advance that the document will contain /// no entity references (or perhaps if your query or stylesheet is not interested in the content /// of text and attribute nodes). Instead, with .NET 1.1 use an <c>XmlValidatingReader</c> (with <c>ValidationType</c> /// set to <c>None</c>). The constructor for <c>XmlValidatingReader</c> is obsolete in .NET 2.0, /// but the same effect can be achieved by using the <c>Create</c> method of <c>XmlReader</c> with /// appropriate <c>XmlReaderSettings</c></para> /// <para>Conformance with the W3C specifications requires that the <c>Normalization</c> property /// of an <c>XmlTextReader</c> should be set to <c>true</c>. However, Saxon does not insist /// on this.</para> /// <para>If the <c>XmlReader</c> performs schema validation, Saxon will ignore any resulting type /// information. Type information can only be obtained by using Saxon's own schema validator, which /// will be run if the <c>SchemaValidationMode</c> property is set to <c>Strict</c> or <c>Lax</c></para> /// <para>Note that the Microsoft <c>System.Xml</c> parser does not report whether attributes are /// defined in the DTD as being of type <c>ID</c> and <c>IDREF</c>. This is true whether or not /// DTD-based validation is enabled. This means that such attributes are not accessible to the /// <c>id()</c> and <c>idref()</c> functions.</para> /// <para>Note that setting the <c>XmlResolver</c> property of the <c>DocumentBuilder</c> /// has no effect when this method is used; if an <c>XmlResolver</c> is required, it must /// be set on the <c>XmlReader</c> itself.</para> /// </remarks> /// <param name="reader">The XMLReader that supplies the parsed XML source</param> /// <returns>An <c>XdmNode</c>, the document node at the root of the tree of the resulting /// in-memory document /// </returns> public XdmNode Build(XmlReader reader) { PullProvider pp = new DotNetPullProvider(reader); pp.setPipelineConfiguration(config.makePipelineConfiguration()); // pp = new PullTracer(pp); /* diagnostics */ Source source = new PullSource(pp); source.setSystemId(reader.BaseURI); source = augmentSource(source); DocumentInfo doc = null; try { doc = config.buildDocument(source); } catch (net.sf.saxon.trans.XPathException e) { throw new StaticError(e); } return((XdmNode)XdmValue.Wrap(doc)); }
/// <summary> /// Gets the receiver. /// </summary> /// <param name="config">Config.The Saxon configuration. This is supplied so that the destination can /// use information from the <code>Configuration</code> (for example, a reference to the name pool) /// to construct or configure the returned Receiver.</param> /// <returns>The receiver.</returns> public JReceiver GetReceiver(JConfiguration config) { builder.setPipelineConfiguration(config.makePipelineConfiguration()); return(builder); }
internal JReceiver GetReceiver(JConfiguration config) { return config.getSerializerFactory().getReceiver( GetResult(), config.makePipelineConfiguration(), GetOutputProperties()); }
/// <summary> /// Serialize an XdmNode to the selected output destination using this serializer /// </summary> /// <param name="node">The node to be serialized</param> /// <remarks>since 9.8</remarks> public void SerializeXdmNode(XdmNode node) { net.sf.saxon.query.QueryResult.serialize(node.Implementation, GetResult(config.makePipelineConfiguration()), GetOutputProperties()); }