示例#1
0
 private void CompareWithStandardReader(bool multiThread, int bufSize)
 {
     XmlReader r = GetReader(Globals.NorthwindResource);
     XslCompiledTransform xslt = new XslCompiledTransform();
     xslt.Load("../../XslReaderTests/test1.xslt");
     MemoryStream ms = new MemoryStream();
     XmlWriterSettings s = new XmlWriterSettings();
     s.OmitXmlDeclaration = true;
     XmlWriter w = XmlWriter.Create(ms, s);
     xslt.Transform(r, w);
     r.Close();
     w.Close();
     byte[] buf = ms.ToArray();
     XmlReader standard = XmlReader.Create(new MemoryStream(buf));
     XslReader xslReader = new XslReader(xslt, multiThread, bufSize);
     xslReader.StartTransform(new XmlInput(GetReader(Globals.NorthwindResource)), null);
     CompareReaders(standard, xslReader);
 }
示例#2
0
 public void Test3()
 {
     string xml = @"<foo xmlns:f=""bar""/>";            
     XslCompiledTransform xslt = new XslCompiledTransform();
     xslt.Load(XmlReader.Create(new StringReader(copyTransform)));
     XslReader xslReader = new XslReader(xslt);
     xslReader.StartTransform(new XmlInput(new StringReader(xml)), null);
     while (!xslReader.EOF)
     {
         xslReader.Read();
     }
     Assert.IsFalse(xslReader.Read());
 }
示例#3
0
 public void Test6()
 {
     XmlReader r = GetReader(Globals.NorthwindResource);
     XslCompiledTransform xslt = new XslCompiledTransform();
     xslt.Load("../../XslReaderTests/test1.xslt");
     MemoryStream ms = new MemoryStream();
     XmlWriterSettings s = new XmlWriterSettings();
     s.OmitXmlDeclaration = true;
     XmlWriter w = XmlWriter.Create(ms, s);
     xslt.Transform(r, w);
     r.Close();
     w.Close();
     byte[] buf = ms.ToArray();
     XmlReader standard = XmlReader.Create(new MemoryStream(buf));
     XslReader xslReader = new XslReader(xslt, true, 16);
     xslReader.StartTransform(new XmlInput(GetReader(Globals.NorthwindResource)), null);
     xslReader.MoveToContent();
     xslReader.Read();
     //Now restart it
     xslReader.StartTransform(new XmlInput(GetReader(Globals.NorthwindResource)), null);
     CompareReaders(standard, xslReader);
 }
示例#4
0
        public void Test2()
        {
            string xml = @"<foo xmlns:f=""bar""/>";            
            XmlReader standard = XmlReader.Create(new StringReader(xml));

            XslCompiledTransform xslt = new XslCompiledTransform();
            xslt.Load(XmlReader.Create(new StringReader(copyTransform)));
            XslReader xslReader = new XslReader(xslt);
            xslReader.StartTransform(new XmlInput(new StringReader(xml)), null);

            standard.MoveToContent();
            xslReader.MoveToContent();

            Assert.IsTrue(standard.NodeType == xslReader.NodeType);
            Assert.IsTrue(standard.Name == xslReader.Name);
            string nsUri1 = standard.LookupNamespace("f");
            string nsUri2 = xslReader.LookupNamespace("f");
            Assert.IsTrue(nsUri1 == nsUri2,
                string.Format("'{0}' != '{1}'", nsUri1, nsUri2));
        }
示例#5
0
 /// <summary>
 /// Transforms given <see cref="XmlInput"/> into <see cref="XmlReader"/>.
 /// </summary>
 /// <param name="input">Default input XML document</param>
 /// <param name="arguments">An <see cref="XsltArgumentList"/> containing the namespace-qualified 
 /// arguments used as input to the transform. This value can be a null reference (Nothing in Visual Basic).</param>
 /// <param name="multiThread">Defines in which mode (multithreaded or singlethreaded)
 /// this instance of XslReader will operate</param>
 /// <param name="initialBufferSize">Initial buffer size (number of nodes, not bytes)</param>
 public XmlReader Transform(XmlInput input, XsltArgumentList arguments, bool multiThread, int initialBufferSize)
 {
     XslReader r = new XslReader(this.compiledTransform, multiThread, initialBufferSize);
     r.StartTransform(input, AddExsltExtensionObjectsSync(arguments));
     return r;
 }
示例#6
0
 /// <summary>
 /// Transforms given <see cref="XmlInput"/> into <see cref="XmlReader"/>.
 /// </summary>
 /// <param name="input">Default input XML document</param>
 /// <param name="arguments">An <see cref="XsltArgumentList"/> containing the namespace-qualified 
 /// arguments used as input to the transform. This value can be a null reference (Nothing in Visual Basic).</param>
 public XmlReader Transform(XmlInput input, XsltArgumentList arguments)
 {
     XslReader r = new XslReader(this.compiledTransform);
     r.StartTransform(input, AddExsltExtensionObjectsSync(arguments));
     return r;
 }
示例#7
0
 public void TestEmptyElement()
 {            
     XslCompiledTransform xslt = new XslCompiledTransform();
     xslt.Load("../../Common/XslReaderTests/test2.xslt");            
     XslReader xslReader = new XslReader(xslt);
     xslReader.StartTransform(new XmlInput(GetReader(Globals.NorthwindResource)), null);
     xslReader.MoveToContent();
     Assert.IsTrue(xslReader.NodeType == XmlNodeType.Element);
     Assert.IsTrue(xslReader.Name == "empty");
     Assert.IsFalse(xslReader.IsEmptyElement);
 }
示例#8
0
        public void TestWithDataSet()
        {
            string stylesheet = @"
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
          <xsl:template match='/'>                      
<BTRChart xmlns:w=""http://schemas.microsoft.com/office/word/2003/wordml""><Data><DundasChart xmlns=""urn:www.benefittech.com:Chart"">[Data]</DundasChart></Data></BTRChart></xsl:template>
        </xsl:stylesheet>
";
            XmlDocument doc = new XmlDocument();
            XslCompiledTransform xslt = new XslCompiledTransform();
            xslt.Load(XmlReader.Create(new StringReader(stylesheet)));
            XslReader reader = new XslReader(xslt);
            DataSet ds = new DataSet();
            ds.ReadXml(reader.StartTransform(new XmlInput(doc), null));  
            StringWriter writer = new StringWriter();
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = false;
            settings.OmitXmlDeclaration = true;
            XmlWriter w = XmlWriter.Create(writer, settings);
            ds.WriteXml(w);
            w.Close();
            Assert.AreEqual(@"<BTRChart><Data><DundasChart xmlns=""urn:www.benefittech.com:Chart"">[Data]</DundasChart></Data></BTRChart>", writer.ToString());
        }