예제 #1
0
파일: Schema.cs 프로젝트: orbeon/saxon-he
        /// <summary>
        /// Add an instance document to the list of documents to be validated
        /// </summary>
        /// <param name="reader">Source document supplied as an <c>XmlReader</c></param>

        public void AddSource(XmlReader reader)
        {
            JPullProvider          pp   = new JDotNetPullProvider(reader);
            JPipelineConfiguration pipe = config.makePipelineConfiguration();

            pipe.setUseXsiSchemaLocation(schemaValidator.isUseXsiSchemaLocation());
            pp.setPipelineConfiguration(pipe);
            // pp = new PullTracer(pp);  /* diagnostics */
            JPullSource psource = new JPullSource(pp);

            psource.setSystemId(reader.BaseURI);
            sources.Add(psource);
        }
예제 #2
0
        /// <summary>
        /// Supply the instance document to be validated, in the form of an XmlReader.
        /// </summary>
        /// <remarks>
        /// The XmlReader is responsible for parsing the document; this method validates it.
        /// </remarks>
        /// <param name="reader">The <c>XmlReader</c> used to read and parse the instance
        /// document being validated. This is used as supplied. For conformance, use of a
        /// plain <c>XmlTextReader</c> is discouraged, because it does not expand entity
        /// references. This may cause validation failures.
        /// </param>

        public void SetSource(XmlReader reader)
        {
            JPullProvider          pp   = new JDotNetPullProvider(reader);
            JPipelineConfiguration pipe = config.makePipelineConfiguration();

            pipe.setUseXsiSchemaLocation(useXsiSchemaLocation);
            pp.setPipelineConfiguration(pipe);
            // pp = new PullTracer(pp);  /* diagnostics */
            JPullSource psource = new JPullSource(pp);

            psource.setSystemId(reader.BaseURI);
            this.source = psource;
            sources.Clear();
        }
예제 #3
0
        /// <summary>
        /// Return a Receiver. Saxon calls this method to obtain a Receiver, to which it then sends
        /// a sequence of events representing the content of an XML document.
        /// </summary>
        /// <returns>The receiver to which events are to be sent</returns>
        /// <param name="pipe">Pipe. The Saxon configuration. This is supplied so that the destination can
        /// use information from the configuration (for example, a reference to the name pool)
        /// to construct or configure the returned Receiver.</param>

        public override JReceiver GetReceiver(JPipelineConfiguration pipe)
        {
            builder = (treeModel == TreeModel.TinyTree ? (JBuilder) new JTinyBuilder(pipe) : (JBuilder) new JLinkedTreeBuilder(pipe));
            if (baseUri != null)
            {
                builder.setBaseURI(baseUri.ToString());
            }

            TreeProtector            protector = new TreeProtector(builder);
            JComplexContentOutputter cco       = new JComplexContentOutputter(pipe);
            JNamespaceReducer        reducer   = new JNamespaceReducer(protector);

            cco.setReceiver(reducer);
            return(cco);
        }
예제 #4
0
        /// <summary inherit="yes"/>

        internal JResult GetResult(JPipelineConfiguration pipe)
        {
            if (outputStream != null)
            {
                return(new JStreamResult(outputStream));
            }
            else if (writer != null)
            {
                return(new JStreamResult(writer));
            }
            else
            {
                return(new JStreamResult(new JDotNetWriter(Console.Out)));
            }
        }
예제 #5
0
파일: XQuery.cs 프로젝트: orbeon/saxon-he
        internal JReceiver GetReceiver(Serializer serializer)
        {
            net.sf.saxon.expr.instruct.Executable executable = exp.getExecutable();
            JConfiguration         config = executable.getConfiguration();
            JPipelineConfiguration pipe   = config.makePipelineConfiguration();

            pipe.setHostLanguage(executable.getHostLanguage());
            JProperties baseProps = new JProperties(executable.getDefaultOutputProperties());

            JCharacterMapIndex charMapIndex = executable.getCharacterMapIndex();
            JCharacterMapIndex characterMap = serializer.GetCharacterMap();

            if (charMapIndex.isEmpty())
            {
                charMapIndex = characterMap;
            }
            else if (characterMap != null && !characterMap.isEmpty() && charMapIndex != characterMap)
            {
                // Merge the character maps
                java.util.Iterator mapIter = characterMap.iterator();
                while (mapIter.hasNext())
                {
                    net.sf.saxon.serialize.CharacterMap map = (net.sf.saxon.serialize.CharacterMap)mapIter.next();
                    charMapIndex.putCharacterMap(map.getName(), map);
                }
            }

            JProperties properties = serializer.GetOutputProperties();

            object [] propSet = properties.entrySet().toArray();

            for (int i = 0; i < properties.size(); i++)
            {
                java.util.Map.Entry             entry = (java.util.Map.Entry)propSet[i];
                net.sf.saxon.om.StructuredQName name  = net.sf.saxon.om.StructuredQName.fromClarkName((String)entry.getKey());
                net.sf.saxon.expr.instruct.ResultDocument.setSerializationProperty(
                    baseProps, name.getURI(), name.getLocalPart(), (String)entry.getValue(), null, true, config);
            }
            serializer.SetDefaultOutputProperties(baseProps);
            serializer.SetCharacterMap(charMapIndex);

            JReceiver target = serializer.GetReceiver(pipe);

            return(target);
        }
예제 #6
0
        /// <summary>
        /// Run the validation of the supplied source document, optionally
        /// writing the validated document to the supplied destination.
        /// </summary>

        public void Run()
        {
            JAugmentedSource aug = JAugmentedSource.makeAugmentedSource(source);

            aug.setSchemaValidationMode(lax ? JValidation.LAX : JValidation.STRICT);
            JReceiver receiver;
            JPipelineConfiguration pipe = config.makePipelineConfiguration();

            if (destination == null)
            {
                receiver = new JSink(pipe);
            }
            else if (destination is Serializer)
            {
                receiver = ((Serializer)destination).GetReceiver(config);
            }
            else
            {
                Result result = destination.GetReceiver(pipe);
                if (result is JReceiver)
                {
                    receiver = (JReceiver)result;
                }
                else
                {
                    throw new ArgumentException("Unknown type of destination");
                }
            }
            pipe.setUseXsiSchemaLocation(useXsiSchemaLocation);
            receiver.setPipelineConfiguration(pipe);
            JParseOptions parseOptions = null;

            if (errorList != null)
            {
                invalidityHandler = new net.sf.saxon.lib.InvalidityHandlerWrappingErrorListener(new ErrorGatherer(errorList));
            }
            parseOptions = new JParseOptions();
            parseOptions.setInvalidityHandler(invalidityHandler);

            JSender.send(aug, receiver, parseOptions);
        }
예제 #7
0
        /// <summary>
        /// Copy an XdmValue to an XmlDestination
        /// </summary>
        /// <remarks>
        /// This method can be used to copy any kind of <c>XdmValue</c> to any kind
        /// of <c>XdmDestination</c>. The supplied <c>XdmValue</c> is first converted
        /// to an XML document according to the rules of the XSLT/XQuery serialization
        /// specification (for example, if the <c>XdmValue</c> is a sequence of atomic
        /// values, they will be turned in a text node in which the values are converted
        /// to strings and separated by single spaces). The resulting document is then
        /// written to the supplied <c>XmlDestination</c>.</remarks>
        /// <param name="sequence">The value to be written</param>
        /// <param name="destination">The destination to which the value should be written</param>
        ///

        public void WriteXdmValue(XdmValue sequence, XmlDestination destination)
        {
            try
            {
                JPipelineConfiguration pipe = config.makePipelineConfiguration();
                JResult   result            = destination.GetResult(pipe);
                JReceiver r = config.getSerializerFactory().getReceiver(result,
                                                                        pipe, destination.GetOutputProperties());
                r = new JNamespaceReducer(r);
                JTreeReceiver tree = new JTreeReceiver(r);
                tree.open();
                tree.startDocument(0);
                foreach (XdmItem it in sequence)
                {
                    tree.append((Item)it.Unwrap(), 0, JNodeInfo.__Fields.ALL_NAMESPACES);
                }
                tree.endDocument();
                tree.close();
            } catch (JXPathException err) {
                throw new DynamicError(err);
            }
        }
예제 #8
0
        /// <summary>
        /// Get a <c>Result</c> to which the XML document can be sent as a series
        /// of events. This method is intended primarily for internal use.
        /// </summary>
        /// <remarks>
        /// The returned value must be an implementation of the JAXP <c>Result</c> interface that is
        /// recognized by Saxon.
        /// </remarks>
        /// <param name="pipe">Configuration information for use by the implementation</param>

        public abstract JReceiver GetReceiver(JPipelineConfiguration pipe);
예제 #9
0
 /// <summary>
 /// Gets the receiver.
 /// </summary>
 /// <returns>The receiver.</returns>
 /// <param name="pipe">Pipe. The PipelineConfiguration</param>
 public override JReceiver GetReceiver(JPipelineConfiguration pipe)
 {
     return(new JSink(pipe));
 }
예제 #10
0
        /// <summary>
        /// Return a Receiver. Saxon calls this method to obtain a Receiver, to which it then sends
        /// a sequence of events representing the content of an XML document.
        /// </summary>
        /// <param name="pipe">Pipe. The Saxon pipeline configuration. This is supplied so that the destination can
        /// use information from the <code>PipelineConfiguration</code> (for example, a reference to the name pool)
        /// to construct or configure the returned Receiver.</param>
        /// <returns>The receiver.</returns>

        public override JReceiver GetReceiver(JPipelineConfiguration pipe)
        {
            builder.setPipelineConfiguration(pipe);
            return(builder);
        }
예제 #11
0
 public override JReceiver GetReceiver(JPipelineConfiguration pipe)
 {
     return(GetReceiver(pipe.getConfiguration()));
 }
예제 #12
0
파일: Xslt.cs 프로젝트: nuxleus/saxonica
 public MessageListenerProxy(JPipelineConfiguration pipe, IMessageListener ml) : base(pipe)
 {
     listener = ml;
 }
예제 #13
0
파일: Xslt.cs 프로젝트: nuxleus/saxonica
 public ResultDocumentHandlerWrapper(IResultDocumentHandler handler, JPipelineConfiguration pipe)
 {
     this.handler = handler;
     this.pipe = pipe;
 }
예제 #14
0
 /// <summary>
 /// Return a <c>Receiver</c>. Saxon calls this method to obtain a Java <c>Receiver</c>, to which it then sends
 /// a sequence of events representing the content of an XML document. The method is intended
 /// primarily for internal use, and may give poor diagnostics if used incorrectly.
 /// </summary>
 /// <returns>The receiver</returns>
 /// <param name="pipe">The Saxon configuration as a <c>JPipelineConfiguration</c>.
 /// This is supplied so that the destination can
 /// use information from the configuration (for example, a reference to the name pool)
 /// to construct or configure the returned <c>Receiver</c>.</param>
 /// <param name="value2">Serialization parameters known to the caller of the method; typically, output
 ///  properties defined in a stylesheet or query. These will mainly be of interest if the destination is performing serialization, but
 ///  soem properties (such as <c>item-separator</c>) are also used in other situations.</param>
 public override JReceiver getReceiver(JPipelineConfiguration pipe, JSerializationProperties value2)
 {
     return(GetReceiver(pipe, value2));
 }