Ejemplo n.º 1
0
        /// <summary>
        /// Add an instance document to the list of documents to be validated.
        /// </summary>
        /// <param name="source">Source document supplied as a <c>Stream</c></param>
        /// <param name="baseUri">Base URI of the source document</param>

        public void AddSource(Stream source, Uri baseUri)
        {
            JStreamSource ss = new JStreamSource(new JDotNetInputStream(source));

            ss.setSystemId(baseUri.ToString());
            sources.Add(ss);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Compile a schema supplied as a <c>Stream</c>. The resulting schema components are added
        /// to the cache.
        /// </summary>
        /// <param name="input">A stream containing the source text of the schema. This method
        /// will consume the supplied stream. It is the caller's responsibility to close the stream
        /// after use.</param>
        /// <param name="baseUri">The base URI of the schema document, for resolving any references to other
        /// schema documents</param>

        public void Compile(Stream input, Uri baseUri)
        {
            JStreamSource ss = new JStreamSource(new JDotNetInputStream(input));

            ss.setSystemId(baseUri.ToString());
            schemaManager.load(ss);
        }
Ejemplo n.º 3
0
        /// <summary>
		/// Supply the instance document to be validated in the form of a <c>Stream</c>
        /// </summary>
        /// <param name="source">A stream containing the XML document to be parsed
        /// and validated. This stream will be consumed by the validation process,
        /// but it will not be closed after use: that is the responsibility of the
        /// caller.</param>
        /// <param name="baseUri">The base URI to be used for resolving any relative
        /// references, for example a reference to an <c>xsi:schemaLocation</c></param>                  

        public void SetSource(Stream source, Uri baseUri)
        {
            JStreamSource ss = new JStreamSource(new JDotNetInputStream(source));
            ss.setSystemId(baseUri.ToString());
            this.source = ss;
            sources.Clear();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Compile a stylesheet supplied as a Stream.
        /// </summary>
        /// <example>
        /// <code>
        /// Stream source = new FileStream("input.xsl", FileMode.Open, FileAccess.Read);
        /// XsltExecutable q = compiler.Compile(source);
        /// source.Close();
        /// </code>
        /// </example>
        /// <param name="input">A stream containing the source text of the stylesheet</param>
        /// <returns>An <c>XsltExecutable</c> which represents the compiled stylesheet object.
        /// The XsltExecutable may be loaded 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>
        /// <remarks>
        /// <para>If the stylesheet contains any <c>xsl:include</c> or <c>xsl:import</c> declarations,
        /// then the <c>BaseURI</c> property must be set to allow these to be resolved.</para>
        /// <para>The stylesheet is contained in the part of the input stream between its current
        /// position and the end of the stream. It is the caller's responsibility to close the input
        /// stream after use. If the compilation succeeded, then on exit the stream will be
        /// exhausted; if compilation failed, the current position of the stream on exit is
        /// undefined.</para>
        /// </remarks>

        public XsltExecutable Compile(Stream input)
        {
            JStreamSource ss = new JStreamSource(new DotNetInputStream(input));

            if (baseUri != null)
            {
                ss.setSystemId(baseUri.ToString());
            }
            PreparedStylesheet pss = (PreparedStylesheet)factory.newTemplates(ss, info);

            return(new XsltExecutable(pss));
        }
Ejemplo n.º 5
0
        // Methods
        //
        public override object GetEntity(Uri href, string role, Type ofObjectToReturn)
        {
            XdmNode node    = null;
            String  hrefStr = href.ToString();
            //hrefStr = hrefStr.Substring(hrefStr.LastIndexOf ('/')+1);

            bool foundDoc = sourceDocs.TryGetValue(hrefStr, out node);

            if (!foundDoc)
            {
                hrefStr  = hrefStr.Substring(hrefStr.LastIndexOf('/') + 1);
                foundDoc = sourceDocs.TryGetValue(hrefStr, out node);
            }

            if (!foundDoc)
            {
                string val;
                hrefStr = href.ToString();
                //hrefStr = hrefStr.Substring(hrefStr.LastIndexOf ('/')+1);

                bool foundSecDoc = streamedSecondaryDocs.TryGetValue(hrefStr, out val);
                if (!foundSecDoc)
                {
                    hrefStr     = hrefStr.Substring(hrefStr.LastIndexOf('/') + 1);
                    foundSecDoc = streamedSecondaryDocs.TryGetValue(hrefStr, out val);
                }

                if (foundSecDoc)
                {
                    //string hrefStr = href.ToString ();
                    //hrefStr = (hrefStr.StartsWith("file://") ? hrefStr.Substring(7) : hrefStr);

                    javax.xml.transform.Source sourcei = new javax.xml.transform.stream.StreamSource(href.ToString());


                    if (!val.Equals("skip"))
                    {
                        sourcei = net.sf.saxon.lib.AugmentedSource.makeAugmentedSource((javax.xml.transform.Source)sourcei);
                        ((net.sf.saxon.lib.AugmentedSource)sourcei).setSchemaValidationMode(net.sf.saxon.lib.Validation.getCode(val));
                    }
                    sourcei.setSystemId(hrefStr);
                    return(sourcei);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(node.Implementation);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Compile a stylesheet supplied as a TextReader.
        /// </summary>
        /// <example>
        /// <code>
        /// String ss = "<![CDATA[<xsl:stylesheet version='2.0'>....</xsl:stylesheet>]]>";
        /// TextReader source = new StringReader(ss);
        /// XsltExecutable q = compiler.Compile(source);
        /// source.Close();
        /// </code>
        /// </example>
        /// <param name="input">A <c>TextReader</c> containing the source text of the stylesheet</param>
        /// <returns>An <c>XsltExecutable</c> which represents the compiled stylesheet object.
        /// The XsltExecutable may be loaded 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>
        /// <remarks>
        /// <para>If the stylesheet contains any <c>xsl:include</c> or <c>xsl:import</c> declarations,
        /// then the <c>BaseURI</c> property must be set to allow these to be resolved.</para>
        /// <para>The stylesheet is contained in the part of the input stream between its current
        /// position and the end of the stream. It is the caller's responsibility to close the 
        /// <c>TextReader</c> after use. If the compilation succeeded, then on exit the stream will be 
        /// exhausted; if compilation failed, the current position of the stream on exit is
        /// undefined.</para>
        /// </remarks>

        public XsltExecutable Compile(TextReader input)
        {
            JStreamSource ss = new JStreamSource(new DotNetReader(input));
            if (baseUri != null)
            {
                ss.setSystemId(baseUri.ToString());
            }
            PreparedStylesheet pss = (PreparedStylesheet)factory.newTemplates(ss, info);
            return new XsltExecutable(pss);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Compile a stylesheet supplied as a Stream.
        /// </summary>
        /// <example>
        /// <code>
        /// Stream source = new FileStream("input.xsl", FileMode.Open, FileAccess.Read);
        /// XsltExecutable q = compiler.Compile(source);
        /// source.Close();
        /// </code>
        /// </example>
        /// <param name="input">A stream containing the source text of the stylesheet</param>
        /// <returns>An <c>XsltExecutable</c> which represents the compiled stylesheet object.
        /// The XsltExecutable may be loaded 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>
        /// <remarks>
        /// <para>If the stylesheet contains any <c>xsl:include</c> or <c>xsl:import</c> declarations,
        /// then the <c>BaseURI</c> property must be set to allow these to be resolved.</para>
        /// <para>The stylesheet is contained in the part of the input stream between its current
        /// position and the end of the stream. It is the caller's responsibility to close the input 
        /// stream after use. If the compilation succeeded, then on exit the stream will be 
        /// exhausted; if compilation failed, the current position of the stream on exit is
        /// undefined.</para>
        /// </remarks>

        public XsltExecutable Compile(Stream input)
        {
            try
            {
                JStreamSource ss = new JStreamSource(new DotNetInputStream(input));
                if (baseUri != null)
                {
                    ss.setSystemId(baseUri.ToString());
                }
                PreparedStylesheet pss = (PreparedStylesheet)factory.newTemplates(ss, info);
                return new XsltExecutable(pss);
            }
            catch (JTransformerException err)
            {
                throw new StaticError(err);
            }
        }