Exemplo n.º 1
0
        /// <summary>
        /// Helper method for instantiating the Xslt Transform options (e.g. XmlUrlResolver, XmlWriterSettings, etc.) for use
        /// during the execution of the Xslt Transform.
        /// This can be overridden by implementing classes to customize this behaviour as needed.
        /// </summary>
        /// <returns></returns>
        protected virtual XslTransformEngineOptions CreateXsltTransformEngineOptions()
        {
            var xmlUrlResolver       = new XmlUrlExtendedResolver(this.XsltFileInfo.Directory);
            var xsltTransformOptions = new XslTransformEngineOptions()
            {
                XsltDocumentResolver = xmlUrlResolver,
                XsltLoadResolver     = xmlUrlResolver
            };

            return(xsltTransformOptions);
        }
        /// <summary>
        /// Convert the current XDocument object into a Compiled Xsl Transformer with the specified XmlResovlver to use when Loading/Compiling the Xslt.
        /// Errors will be thrown if the input Xml is not valid for an Xslt.
        /// This allows increaed performance because the caller can keep a reference to the fully compiled Transformer, after all
        /// parsing/imports/includes etc., have been processed.
        /// </summary>
        /// <param name="xXsltDocument"></param>
        /// <param name="xsltOptions"></param>
        /// <returns></returns>
        public static XslTransformEngine CreateXslTransformEngine(this XDocument xXsltDocument, XslTransformEngineOptions xsltOptions = null)
        {
            XslTransformEngine transformer = new XslTransformEngine(xXsltDocument, xsltOptions);

            return(transformer);
        }