Ejemplo n.º 1
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.º 2
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.º 3
0
        /// <summary>
        /// Compile a schema, retrieving the source using a URI. The resulting schema components are added
        /// to the cache.
        /// </summary>
        /// <remarks>
        /// The document located via the URI is parsed using the <c>System.Xml</c> parser.
        /// </remarks>
        /// <param name="uri">The URI identifying the location where the schema document can be
        /// found</param>

        public void Compile(Uri uri)
        {
            JStreamSource ss = new JStreamSource(uri.ToString());
            JAugmentedSource aug = JAugmentedSource.makeAugmentedSource(ss);
            aug.setPleaseCloseAfterUse(true);
			schemaManager.load (aug);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Resolve the specified targetNamespace, baseURI and locations.
        /// </summary>
        /// <param name="targetNamespace">Target namespace.</param>
        /// <param name="baseURI">BaseURI.</param>
        /// <param name="locations">Locations.</param>
        public JSource[] resolve(String targetNamespace, String baseURI, String[] locations)
        {
            if (config.isSchemaAvailable(targetNamespace) && !(java.lang.Boolean.valueOf(((java.lang.Object)config.getConfigurationProperty(JFeatureKeys.MULTIPLE_SCHEMA_IMPORTS)).toString()).booleanValue()))
            {
                return(new JSource[0]);
            }
            Uri baseU = (baseURI == null ? null : new Uri(baseURI));

            Uri[]           modules = resolver.GetSchemaDocuments(targetNamespace, baseU, locations);
            JStreamSource[] ss      = new JStreamSource[modules.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ss[i] = new JStreamSource();
                ss[i].setSystemId(modules[i].ToString());
                Object doc = resolver.GetEntity(modules[i]);
                if (doc is Stream)
                {
                    ss[i].setInputStream(new JDotNetInputStream((Stream)doc));
                }
                else if (doc is String)
                {
                    ss[i].setReader(new JDotNetReader(new StringReader((String)doc)));
                }
                else
                {
                    throw new ArgumentException("Invalid response from GetEntity()");
                }
            }
            return(ss);
        }
Ejemplo n.º 5
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.º 6
0
        public JStreamSource[] resolve(String moduleURI, String baseURI, String[] locations)
        {
            Uri baseU = (baseURI == null ? null : new Uri(baseURI));

            Uri[]           modules = resolver.GetModules(moduleURI, baseU, locations);
            JStreamSource[] ss      = new JStreamSource[modules.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ss[i] = new JStreamSource();
                ss[i].setSystemId(modules[i].ToString());
                Object query = resolver.GetEntity(modules[i]);
                if (query is Stream)
                {
                    ss[i].setInputStream(new DotNetInputStream((Stream)query));
                }
                else if (query is String)
                {
                    ss[i].setReader(new DotNetReader(new StringReader((String)query)));
                }
                else
                {
                    throw new ArgumentException("Invalid response from GetEntity()");
                }
            }
            return(ss);
        }
Ejemplo n.º 7
0
        /// <summary>
		/// Supply the instance document to be validated in the form of a <c>Uri</c> reference
        /// </summary>
        /// <param name="uri">URI of the document to be validated</param>                  

        public void SetSource(Uri uri)
        {
            JStreamSource ss = new JStreamSource(uri.ToString());
            JAugmentedSource aug = JAugmentedSource.makeAugmentedSource(ss);
            aug.setPleaseCloseAfterUse(true);
            this.source = aug;
            sources.Clear();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Add an instance document to the list of documents to be validated
        /// </summary>
        /// <param name="uri">URI of the source document</param>

        public void AddSource(Uri uri)
        {
            JStreamSource    ss  = new JStreamSource(uri.ToString());
            JAugmentedSource aug = JAugmentedSource.makeAugmentedSource(ss);

            aug.setPleaseCloseAfterUse(true);
            sources.Add(aug);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Compile a stylesheet, retrieving the source using a URI.
        /// </summary>
        /// <remarks>
        /// The document located via the URI is parsed using the <c>System.Xml</c> parser. This
        /// URI is used as the base URI of the stylesheet: the <c>BaseUri</c> property of the
        /// <c>Compiler</c> is ignored.
        /// </remarks>
        /// <param name="uri">The URI identifying the location where the stylesheet document can be
        /// found</param>
        /// <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(Uri uri)
        {
            JStreamSource    source = new JStreamSource(uri.ToString());
            JAugmentedSource aug    = JAugmentedSource.makeAugmentedSource(source);

            aug.setPleaseCloseAfterUse(true);
            PreparedStylesheet pss = (PreparedStylesheet)factory.newTemplates(aug, info);

            return(new XsltExecutable(pss));
        }
Ejemplo n.º 10
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.º 11
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.º 12
0
        public static void GeneratePdf(string foFile, string pdfFile)
        {
            OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(new java.io.File(pdfFile)));

            try
            {
                FopFactory fopFactory = FopFactory.newInstance(new java.net.URI("."));
                Fop        fop        = fopFactory.newFop("application/pdf", outputStream);
                javax.xml.transform.TransformerFactory factory     = javax.xml.transform.TransformerFactory.newInstance();
                javax.xml.transform.Transformer        transformer = factory.newTransformer();
                javax.xml.transform.Source             source      = new javax.xml.transform.stream.StreamSource(new java.io.File(foFile));
                javax.xml.transform.Result             result      = new javax.xml.transform.sax.SAXResult(fop.getDefaultHandler());
                transformer.transform(source, result);
            }

            finally
            {
                outputStream.close();
            }
        }
        /// <summary>
        /// Compile a stylesheet, retrieving the source using a URI.
        /// </summary>
        /// <remarks>
        /// The document located via the URI is parsed using the <c>System.Xml</c> parser. This
        /// URI is used as the base URI of the stylesheet: the <c>BaseUri</c> property of the
        /// <c>Compiler</c> is ignored.
        /// </remarks>
        /// <param name="uri">The URI identifying the location where the stylesheet document can be
        /// found</param>
        /// <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(Uri uri) {
            JStreamSource source = new JStreamSource(uri.ToString());
            JAugmentedSource aug = JAugmentedSource.makeAugmentedSource(source);
            aug.setPleaseCloseAfterUse(true);
            PreparedStylesheet pss = (PreparedStylesheet)factory.newTemplates(source, info);
            return new XsltExecutable(pss);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Supply the principal input document for the transformation in the form of a stream.
        /// </summary>
        /// <remarks>
        /// <para>If this method is used, the <c>InitialContextNode</c> is ignored.</para>
        /// <para>The supplied stream will be consumed by the <c>Run()</c> method.
        /// Closing the input stream after use is the client's responsibility.</para>
        /// <para>A base URI must be supplied in all cases. It is used to resolve relative
        /// URI references appearing within the input document.</para>
        /// <para>Schema validation is applied to the input document according to the value of
        /// the <c>SchemaValidationMode</c> property.</para>
        /// <para>Whitespace stripping is applied according to the value of the
        /// <c>xsl:strip-space</c> and <c>xsl:preserve-space</c> declarations in the stylesheet.</para>
        /// </remarks>
        /// <param name="input">
        /// The stream containing the source code of the principal input document to the transformation. The document
        /// node at the root of this document will be the initial context node for the transformation.
        /// </param>
        /// <param name="baseUri">
        /// The base URI of the principal input document. This is used for example by the <c>document()</c>
        /// function if the document contains links to other documents in the form of relative URIs.</param>

        public void SetInputStream(Stream input, Uri baseUri) 
        {
            streamSource = new JStreamSource(new DotNetInputStream(input), baseUri.ToString());
        }
Ejemplo n.º 15
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.º 16
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);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Supply the principal input document for the transformation in the form of a stream.
        /// </summary>
        /// <remarks>
        /// <para>If this method is used, the <c>InitialContextNode</c> is ignored.</para>
        /// <para>The supplied stream will be consumed by the <c>Run()</c> method.
        /// Closing the input stream after use is the client's responsibility.</para>
        /// <para>A base URI must be supplied in all cases. It is used to resolve relative
        /// URI references appearing within the input document.</para>
        /// <para>Schema validation is applied to the input document according to the value of
        /// the <c>SchemaValidationMode</c> property.</para>
        /// <para>Whitespace stripping is applied according to the value of the
        /// <c>xsl:strip-space</c> and <c>xsl:preserve-space</c> declarations in the stylesheet.</para>
        /// </remarks>
        /// <param name="input">
        /// The stream containing the source code of the principal input document to the transformation. The document
        /// node at the root of this document will be the initial context node for the transformation.
        /// </param>
        /// <param name="baseUri">
        /// The base URI of the principal input document. This is used for example by the <c>document()</c>
        /// function if the document contains links to other documents in the form of relative URIs.</param>

        public void SetInputStream(Stream input, Uri baseUri)
        {
            streamSource = new JStreamSource(new DotNetInputStream(input), baseUri.ToString());
        }
Ejemplo n.º 18
0
 public JStreamSource[] resolve(String moduleURI, String baseURI, String[] locations)
 {
     Uri baseU = (baseURI == null ? null : new Uri(baseURI));
     Uri[] modules = resolver.GetModules(moduleURI, baseU, locations);
     JStreamSource[] ss = new JStreamSource[modules.Length];
     for (int i = 0; i < ss.Length; i++)
     {
         ss[i] = new JStreamSource();
         ss[i].setSystemId(modules[i].ToString());
         Object query = resolver.GetEntity(modules[i]);
         if (query is Stream)
         {
             ss[i].setInputStream(new DotNetInputStream((Stream)query));
         }
         else if (query is String)
         {
             ss[i].setReader(new DotNetReader(new StringReader((String)query)));
         }
         else
         {
             throw new ArgumentException("Invalid response from GetEntity()");
         }
     }
     return ss;
 }