/// <summary> /// Compile a stylesheet, delivered using an XmlReader. /// </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. /// If the <c>XmlReader</c> is an <c>XmlTextReader</c>, Saxon will set its <c>Normalization</c> /// property to true, and will wrap it in a (non-validating) <c>XmlValidatingReader</c> to ensure /// that entity references are expanded. /// </remarks> /// <remarks> /// If the <c>XmlReader</c> has a <c>BaseUri</c> property, then that property determines /// the base URI of the stylesheet module, which is used when resolving any <c>xsl:include</c> /// or <c>xsl:import</c> declarations. If the <c>XmlReader</c> has no <c>BaseUri</c> /// property, then the <c>BaseUri</c> property of the <c>Compiler</c> is used instead. /// An <c>ArgumentNullException</c> is thrown if this property has not been supplied. /// </remarks> /// <returns>An <c>XsltExecutable</c> which represents the compiled stylesheet object. /// The XsltExecutable may be run as many times as required, in the same or a different /// thread. The <c>XsltExecutable</c> is not affected by any changes made to the <c>XsltCompiler</c> /// once it has been compiled.</returns> public XsltExecutable Compile(XmlReader reader) { if (reader is XmlTextReader) { ((XmlTextReader)reader).Normalization = true; reader = new XmlValidatingReader(reader); ((XmlValidatingReader)reader).ValidationType = ValidationType.None; } DotNetPullProvider pp = new DotNetPullProvider(reader); JPipelineConfiguration pipe = config.makePipelineConfiguration(); pipe.setLocationProvider(pp); pp.setPipelineConfiguration(pipe); // pp = new PullTracer(pp); /* diagnostics */ JPullSource source = new JPullSource(pp); String baseu = reader.BaseURI; if (baseu == null || baseu == String.Empty) { // if no baseURI is supplied by the XmlReader, use the one supplied to this Compiler if (baseUri == null) { throw new ArgumentNullException("BaseUri"); } baseu = baseUri.ToString(); pp.setBaseURI(baseu); } source.setSystemId(baseu); PreparedStylesheet pss = (PreparedStylesheet)factory.newTemplates(source, info); return(new XsltExecutable(pss)); }
/// <summary> /// Compile a schema, delivered using an XmlReader. 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 XmlReader (that is, the XML parser) used to supply the source schema document</param> public void Compile(XmlReader reader) { PullProvider pp = new DotNetPullProvider(reader); pp.setPipelineConfiguration(config.makePipelineConfiguration()); // pp = new PullTracer(pp); /* diagnostics */ PullSource ss = new PullSource(pp); ss.setSystemId(reader.BaseURI); schemaManager.load(ss); }