Ejemplo n.º 1
0
 public object Evaluate(XslTransformProcessor p)
 {
     if (this.select != null)
     {
         object obj = p.Evaluate(this.select);
         if (obj is XPathNodeIterator)
         {
             ArrayList         arrayList         = new ArrayList();
             XPathNodeIterator xpathNodeIterator = (XPathNodeIterator)obj;
             while (xpathNodeIterator.MoveNext())
             {
                 XPathNavigator xpathNavigator = xpathNodeIterator.Current;
                 arrayList.Add(xpathNavigator.Clone());
             }
             obj = new ListIterator(arrayList, p.XPathContext);
         }
         return(obj);
     }
     if (this.content != null)
     {
         DTMXPathDocumentWriter2 dtmxpathDocumentWriter = new DTMXPathDocumentWriter2(p.Root.NameTable, 200);
         Outputter newOutput = new GenericOutputter(dtmxpathDocumentWriter, p.Outputs, null, true);
         p.PushOutput(newOutput);
         if (p.CurrentNodeset.CurrentPosition == 0)
         {
             p.NodesetMoveNext();
         }
         this.content.Evaluate(p);
         p.PopOutput();
         return(dtmxpathDocumentWriter.CreateDocument().CreateNavigator());
     }
     return(string.Empty);
 }
Ejemplo n.º 2
0
        /// <summary>Transforms the XML data in the <see cref="T:System.Xml.XPath.XPathNavigator" /> using the specified args and outputs the result to an <see cref="T:System.Xml.XmlWriter" />.</summary>
        /// <param name="input">An <see cref="T:System.Xml.XPath.XPathNavigator" /> containing the data to be transformed. </param>
        /// <param name="args">An <see cref="T:System.Xml.Xsl.XsltArgumentList" /> containing the namespace-qualified arguments used as input to the transformation. </param>
        /// <param name="output">The <see cref="T:System.Xml.XmlWriter" /> to which you want to output. </param>
        /// <param name="resolver">The <see cref="T:System.Xml.XmlResolver" /> used to resolve the XSLT document() function. If this is null, the document() function is not resolved.The <see cref="T:System.Xml.XmlResolver" /> is not cached after the <see cref="M:System.Xml.Xsl.XslTransform.Transform(System.Xml.XPath.XPathNavigator,System.Xml.Xsl.XsltArgumentList,System.Xml.XmlWriter,System.Xml.XmlResolver)" /> method completes. </param>
        /// <exception cref="T:System.InvalidOperationException">There was an error processing the XSLT transformation. Note: This is a change in behavior from earlier versions. An <see cref="T:System.Xml.Xsl.XsltException" /> is thrown if you are using Microsoft .NET Framework version 1.1 or earlier.</exception>
        public void Transform(XPathNavigator input, XsltArgumentList args, XmlWriter output, XmlResolver resolver)
        {
            if (this.s == null)
            {
                throw new XsltException("No stylesheet was loaded.", null);
            }
            Outputter outputtter = new GenericOutputter(output, this.s.Outputs, null);

            new XslTransformProcessor(this.s, this.debugger).Process(input, outputtter, args, resolver);
            output.Flush();
        }
        private void Transform(XPathNavigator input, XsltArgumentList args, TextWriter output)
        {
            if (this.s == null)
            {
                throw new XsltException("No stylesheet was loaded.", null);
            }
            Outputter outputter = new GenericOutputter(output, this.s.Outputs, output.Encoding);

            new XslTransformProcessor(this.s, this.debugger).Process(input, outputter, args, null);
            outputter.Done();
            output.Flush();
        }
Ejemplo n.º 4
0
        void Transform(XPathNavigator input, XsltArgumentList args, TextWriter output, XmlResolver resolver)
#endif
        {
            if (s == null)
            {
                throw new XsltException("No stylesheet was loaded.", null);
            }

            Outputter outputter = new GenericOutputter(output, s.Outputs, output.Encoding);

            new XslTransformProcessor(s, debugger).Process(input, outputter, args, resolver);
            outputter.Done();
            output.Flush();
        }
Ejemplo n.º 5
0
        public object Evaluate(XslTransformProcessor p)
        {
            if (select != null)
            {
                object o = p.Evaluate(select);
                // To resolve variable references correctly, we
                // have to collect all the target nodes here.
                // (otherwise, variables might be resolved with
                // different level of variable stack in
                // XslTransformProcessor).
                if (o is XPathNodeIterator)
                {
                    ArrayList         al   = new ArrayList();
                    XPathNodeIterator iter = (XPathNodeIterator)o;
                    while (iter.MoveNext())
                    {
                        al.Add(iter.Current.Clone());
                    }
                    o = new ListIterator(al, p.XPathContext);
                }
                return(o);
            }
            else if (content != null)
            {
//				XmlNodeWriter w = new XmlNodeWriter (false);
//				DTMXPathDocumentWriter w = new DTMXPathDocumentWriter (p.CurrentNode.NameTable, 200);
                DTMXPathDocumentWriter2 w = new DTMXPathDocumentWriter2(p.CurrentNode.NameTable, 200);
                Outputter outputter       = new GenericOutputter(w, p.Outputs, null, true);
                p.PushOutput(outputter);
                content.Evaluate(p);
                p.PopOutput();
//				return w.Document.CreateNavigator ().SelectChildren (XPathNodeType.All);
//				return w.CreateDocument ().CreateNavigator ().SelectChildren (XPathNodeType.All);
//				return w.Document.CreateNavigator ();
                return(w.CreateDocument().CreateNavigator());
            }
            else
            {
                return("");
            }
        }
Ejemplo n.º 6
0
		public object Evaluate (XslTransformProcessor p)
		{
			if (select != null) {
				object o = p.Evaluate (select);
				// To resolve variable references correctly, we
				// have to collect all the target nodes here.
				// (otherwise, variables might be resolved with
				// different level of variable stack in
				// XslTransformProcessor).
				if (o is XPathNodeIterator) {
					ArrayList al = new ArrayList ();
					XPathNodeIterator iter = (XPathNodeIterator) o;
					while (iter.MoveNext ())
						al.Add (iter.Current.Clone ());
					o = new ListIterator (al, p.XPathContext);
				}
				return o;
			} else if (content != null) {
				DTMXPathDocumentWriter2 w = new DTMXPathDocumentWriter2 (p.Root.NameTable, 200);
				Outputter outputter = new GenericOutputter(w, p.Outputs, null, true);
				p.PushOutput (outputter);
				if (p.CurrentNodeset.CurrentPosition == 0)
					p.NodesetMoveNext ();
				content.Evaluate (p);
				p.PopOutput ();
				return w.CreateDocument ().CreateNavigator ();
			} else {
				return "";
			}
		}