public static SchematronValidator CreateSchematronValidator(this IXsltProcessor processor, IXPathNavigable schemaDoc) { if (processor == null) { throw new ArgumentNullException("processor"); } if (schemaDoc == null) { throw new ArgumentNullException("schemaDoc"); } IXPathNavigable stylesheetDoc = processor.ItemFactory.BuildNode(); XmlWriter builder = stylesheetDoc.CreateNavigator().AppendChild(); processor.BuildSchematronValidatorStylesheet(schemaDoc, builder); builder.Close(); var compileOptions = new XsltCompileOptions(); XPathNavigator schemaNav = schemaDoc.CreateNavigator(); if (!String.IsNullOrEmpty(schemaNav.BaseURI)) { compileOptions.BaseUri = new Uri(schemaNav.BaseURI); } return(new XsltSchematronValidator(processor.Compile(stylesheetDoc, compileOptions))); }
public XsltExecutable Compile(IXPathNavigable module, XsltCompileOptions options) { XsltCompiler compiler = CreateCompiler(options); XPathNavigator nav = module.CreateNavigator(); XdmNode node; if (SaxonExtensions.TryGetXdmNode(nav, out node)) { Uri baseUri = null; try { baseUri = node.BaseUri; } catch (ArgumentNullException) { } catch (UriFormatException) { } try { return(WrapExecutable(compiler.Compile(node), options, baseUri)); } catch (Exception ex) { throw WrapCompileException(ex, compiler); } } else { return(Compile(nav.ReadSubtree(), options)); } }
public XsltExecutable Compile(TextReader module, XsltCompileOptions options) { XsltCompiler compiler = CreateCompiler(options); try { return(WrapExecutable(compiler.Compile(module), options, default(Uri))); } catch (Exception ex) { throw WrapCompileException(ex, compiler); } }
XsltCompiler CreateCompiler(XsltCompileOptions options) { XsltCompiler compiler = this.processor.NewXsltCompiler(); compiler.ErrorList = new ArrayList(); compiler.BaseUri = options.BaseUri; if (options.XmlResolver != null) compiler.XmlResolver = options.XmlResolver; return compiler; }
public XsltExecutable Compile(XmlReader module, XsltCompileOptions options) { XsltCompiler compiler = CreateCompiler(options); string baseUri = module.BaseURI; try { return(WrapExecutable(compiler.Compile(module), options, baseUri)); } catch (Exception ex) { throw WrapCompileException(ex, compiler); } }
public XsltExecutable Compile(XmlReader module, XsltCompileOptions options) { XslCompiledTransform transform = CreateTransform(); try { transform.Load(module, this.Settings, options.XmlResolver); } catch (XsltException ex) { throw new SystemXsltException(ex); } return CreateExecutable(transform, options, module.BaseURI); }
XsltExecutable CreateExecutable(XslCompiledTransform transform, XsltCompileOptions options, string baseUri) { Uri parsedBaseUri = null; if (!String.IsNullOrEmpty(baseUri)) { try { parsedBaseUri = new Uri(baseUri); } catch (UriFormatException) { } } return CreateExecutable(transform, options, parsedBaseUri); }
public XsltExecutable Compile(XmlReader module, XsltCompileOptions options) { XslCompiledTransform transform = CreateTransform(); try { transform.Load(module, this.Settings, options.XmlResolver); } catch (XsltException ex) { throw new SystemXsltException(ex); } return(CreateExecutable(transform, options, module.BaseURI)); }
XsltExecutable WrapExecutable(SaxonApiXsltExecutable xsltExecutable, XsltCompileOptions options, string baseUri) { Uri parsedBaseUri = null; if (!String.IsNullOrEmpty(baseUri)) { try { parsedBaseUri = new Uri(baseUri); } catch (UriFormatException) { } } return(WrapExecutable(xsltExecutable, options, parsedBaseUri)); }
XsltExecutable CreateExecutable(XslCompiledTransform transform, XsltCompileOptions options, string baseUri) { Uri parsedBaseUri = null; if (!String.IsNullOrEmpty(baseUri)) { try { parsedBaseUri = new Uri(baseUri); } catch (UriFormatException) { } } return(CreateExecutable(transform, options, parsedBaseUri)); }
XsltCompiler CreateCompiler(XsltCompileOptions options) { XsltCompiler compiler = this.processor.NewXsltCompiler(); compiler.ErrorList = new ArrayList(); compiler.BaseUri = options.BaseUri; if (options.XmlResolver != null) { compiler.XmlResolver = options.XmlResolver; } return(compiler); }
public XsltExecutable Compile(IXPathNavigable module, XsltCompileOptions options) { XslCompiledTransform transform = CreateTransform(); XPathNavigator nav = module.CreateNavigator(); try { transform.Load(nav, this.Settings, options.XmlResolver); } catch (XsltException ex) { throw new SystemXsltException(ex); } return CreateExecutable(transform, options, nav.BaseURI); }
public XsltExecutable Compile(IXPathNavigable module, XsltCompileOptions options) { XslCompiledTransform transform = CreateTransform(); XPathNavigator nav = module.CreateNavigator(); try { transform.Load(nav, this.Settings, options.XmlResolver); } catch (XsltException ex) { throw new SystemXsltException(ex); } return(CreateExecutable(transform, options, nav.BaseURI)); }
public XsltExecutable Compile(IXPathNavigable module, XsltCompileOptions options) { XsltCompiler compiler = CreateCompiler(options); XPathNavigator nav = module.CreateNavigator(); XdmNode node; if (SaxonExtensions.TryGetXdmNode(nav, out node)) { Uri baseUri = node.BaseUri; try { return WrapExecutable(compiler.Compile(node), options, baseUri); } catch (Exception ex) { throw WrapCompileException(ex, compiler); } } else { return Compile(nav.ReadSubtree(), options); } }
XsltExecutable CreateExecutable(XslCompiledTransform transform, XsltCompileOptions options, Uri baseUri) { return new SystemXsltExecutable(transform, this, baseUri ?? options.BaseUri); }
public XsltExecutable Compile(Stream module, XsltCompileOptions options) { XsltCompiler compiler = CreateCompiler(options); try { return WrapExecutable(compiler.Compile(module), options, default(Uri)); } catch (Exception ex) { throw WrapCompileException(ex, compiler); } }
XsltExecutable CreateExecutable(XslCompiledTransform transform, XsltCompileOptions options, Uri baseUri) { return(new SystemXsltExecutable(transform, this, baseUri ?? options.BaseUri)); }
public XsltExecutable Compile(TextReader module, XsltCompileOptions options) { return Compile(this.ItemFactory.CreateNodeReadOnly(module, new XmlParsingOptions { BaseUri = options.BaseUri, XmlResolver = options.XmlResolver }), options); }
XsltExecutable WrapExecutable(Saxon.Api.XsltExecutable xsltExecutable, XsltCompileOptions options, Uri baseUri) { return new SaxonXsltExecutable(xsltExecutable, this, baseUri ?? options.BaseUri); }
public XsltExecutable Compile(TextReader module, XsltCompileOptions options) { return(Compile(this.ItemFactory.CreateNodeReadOnly(module, new XmlParsingOptions { BaseUri = options.BaseUri, XmlResolver = options.XmlResolver }), options)); }
public static void BuildSchematronValidatorStylesheet(this IXsltProcessor processor, IXPathNavigable schemaDoc, XmlWriter output) { if (processor == null) { throw new ArgumentNullException("processor"); } if (schemaDoc == null) { throw new ArgumentNullException("schemaDoc"); } if (output == null) { throw new ArgumentNullException("output"); } XPathNavigator nav = schemaDoc.CreateNavigator(); if (nav.NodeType != XPathNodeType.Root) { throw new ArgumentException("The schema must be a document node.", "schemaDoc"); } string queryBinding = nav.GetAttribute("queryBinding", ""); decimal procXsltVersion = processor.GetXsltVersion(); string xsltVersion; if (String.IsNullOrEmpty(queryBinding)) { int maxMajorVersion = (procXsltVersion >= 3m) ? 2 : (int)Decimal.Floor(procXsltVersion); xsltVersion = "xslt" + maxMajorVersion.ToStringInvariant(); } else { string qbLower = queryBinding.ToLowerInvariant(); switch (qbLower) { case "xslt": case "xslt1": case "xpath": case "xpath1": xsltVersion = "xslt1"; break; case "xslt2": case "xpath2": if (procXsltVersion < 2) { throw new ArgumentException( "The queryBinding '{0}' is not supported by this processor. Lower the language version or use a different processor.".FormatInvariant(queryBinding), "schemaDoc" ); } xsltVersion = "xslt2"; break; default: throw new ArgumentException( "The queryBinding '{0}' is not supported. Valid values are: {1}.".FormatInvariant(queryBinding, String.Join(", ", GetQueryBindings())), "schemaDoc" ); } } Assembly assembly = Assembly.GetExecutingAssembly(); Uri baseUri = new UriBuilder { Scheme = XmlEmbeddedResourceResolver.UriSchemeClires, Host = null, Path = String.Concat(assembly.GetName().Name, "/", xsltVersion, "/") }.Uri; var compileOptions = new XsltCompileOptions(baseUri) { XmlResolver = new XmlDynamicResolver() // use calling assembly as default }; string[] stages = { "iso_dsdl_include.xsl", "iso_abstract_expand.xsl", String.Concat("iso_svrl_for_", xsltVersion, ".xsl") }; IXPathNavigable input = schemaDoc; for (int i = 0; i < stages.Length; i++) { var stageUri = new Uri(baseUri, stages[i]); using (var stageDoc = (Stream)compileOptions.XmlResolver.GetEntity(stageUri, null, typeof(Stream))) { XsltExecutable executable = processor.Compile(stageDoc, compileOptions); var runtimeOptions = new XsltRuntimeOptions { InitialContextNode = input, InputXmlResolver = compileOptions.XmlResolver }; if (i < stages.Length - 1) { // output becomes the input for the next stage input = executable.Run(runtimeOptions); } else { // last stage is output to writer executable.Run(output, runtimeOptions); } } } }
XsltExecutable WrapExecutable(Saxon.Api.XsltExecutable xsltExecutable, XsltCompileOptions options, string baseUri) { Uri parsedBaseUri = null; if (!String.IsNullOrEmpty(baseUri)) { try { parsedBaseUri = new Uri(baseUri); } catch (UriFormatException) { } } return WrapExecutable(xsltExecutable, options, parsedBaseUri); }
XsltExecutable WrapExecutable(SaxonApiXsltExecutable xsltExecutable, XsltCompileOptions options, Uri baseUri) { return(new SaxonXsltExecutable(xsltExecutable, this, baseUri ?? options.BaseUri)); }
public XsltExecutable Compile(XmlReader module, XsltCompileOptions options) { XsltCompiler compiler = CreateCompiler(options); string baseUri = module.BaseURI; try { return WrapExecutable(compiler.Compile(module), options, baseUri); } catch (Exception ex) { throw WrapCompileException(ex, compiler); } }