public void writeNode_XmlReader16(XmlWriterUtils utils) { XmlReader xr = CreateReaderIgnoreWS("XmlReader.xml"); while (xr.Read()) { if (xr.LocalName == "DefaultAttributesTrue") { xr.Read(); break; } } using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteNode(xr, false); w.WriteEndElement(); } xr.Dispose(); if (ReaderLoosesDefaultAttrInfo()) { Assert.True(utils.CompareReader("<Root><name a='b' FIRST='KEVIN' LAST='WHITE'/></Root>")); } else { Assert.True(utils.CompareReader("<Root><name a='b' /></Root>")); } }
public void writeNode_XmlReader10(XmlWriterUtils utils) { XmlReader xr = CreateReaderIgnoreWS("XmlReader.xml"); while (xr.Read()) { if (xr.LocalName == "MixedContent") { xr.Read(); break; } } using (XmlWriter w = utils.CreateWriter()) { w.WriteNode(xr, false); } // check reader position CError.Compare(xr.NodeType, XmlNodeType.EndElement, "Error"); CError.Compare(xr.Name, "MixedContent", "Error"); xr.Dispose(); if (IsXPathDataModelReader()) { Assert.True(utils.CompareReader("<node1><?PI Instruction?><!--Comment-->Textcdata</node1>")); } Assert.True(utils.CompareReader("<node1><?PI Instruction?><!--Comment-->Text<![CDATA[cdata]]></node1>")); }
public void writeAttributes_2(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { using (XmlReader xr = CreateReader("XmlReader.xml")) { while (xr.Read()) { if (xr.LocalName == "name") { xr.MoveToFirstAttribute(); break; } } w.WriteStartElement("Root"); w.WriteAttributes(xr, false); w.WriteEndElement(); } } if (IsXPathDataModelReader()) { // always sees default attributes Assert.True(utils.CompareReader("<Root a=\"b\" FIRST=\"KEVIN\" LAST=\"WHITE\" />")); } else { Assert.True(utils.CompareReader("<Root a=\"b\" />")); } }
public void standalone_2(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.ConformanceLevel = ConformanceLevel.Document; wSettings.CloseOutput = false; XmlWriter w = utils.CreateWriter(wSettings); w.WriteStartDocument(false); w.WriteStartElement("Root"); w.WriteEndElement(); w.WriteEndDocument(); w.Dispose(); bool ret = false; if (utils.WriterType == WriterType.UnicodeWriter) { ret = utils.CompareReader("<?xml version=\"1.0\" encoding=\"unicode\" standalone=\"no\"?><Root />"); } else { ret = utils.CompareReader("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?><Root />"); } Assert.True(ret); }
public void writeNode_XmlReader2(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { using (XmlReader xr = CreateReaderIgnoreWS("XmlReader.xml")) { while (xr.Read()) { if (xr.LocalName == "defattr") { xr.Read(); xr.MoveToFirstAttribute(); break; } } if (xr.NodeType != XmlNodeType.Attribute) { CError.WriteLine("Reader positioned on {0}", xr.NodeType.ToString()); xr.Dispose(); w.Dispose(); Assert.True(false); } w.WriteStartElement("Root"); w.WriteNode(xr, false); w.WriteEndElement(); } } Assert.True(utils.CompareReader("<Root />")); }
public void writeAttributes_4(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { using (XmlReader xr = CreateReader("XmlReader.xml")) { while (xr.Read()) { if (xr.LocalName == "AttributesGeneric") { do { xr.Read(); } while (xr.LocalName != "node"); break; } } if (xr.NodeType != XmlNodeType.Element) { CError.WriteLine("Reader not positioned element"); CError.WriteLine(xr.LocalName); xr.Dispose(); w.Dispose(); Assert.True(false); } w.WriteStartElement("Root"); w.WriteAttributes(xr, false); w.WriteEndElement(); } } Assert.True(utils.CompareReader("<Root a=\"b\" c=\"d\" e=\"f\" />")); }
public void writeAttributes_11(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { using (XmlReader xr = CreateReader("XmlReader.xml")) { while (xr.Read()) { if (xr.LocalName == "QuoteChar") { do { xr.Read(); } while (xr.LocalName != "node"); do { xr.Read(); } while (xr.LocalName != "node"); xr.MoveToFirstAttribute(); break; } } w.WriteStartElement("Root"); w.WriteAttributes(xr, false); w.WriteEndElement(); } } Assert.True(utils.CompareReader("<Root a=\"b'c\" />")); }
public void writeNode_XmlReader24(XmlWriterUtils utils) { if (IsXPathDataModelReader()) { CError.WriteLine("XPath data model does not have CDATA node type, so {0} can not be positioned on CDATA", readerType); return; } XmlReader xr = CreateReaderIgnoreWS("XmlReader.xml"); while (xr.Read()) { if (xr.LocalName == "CDataNode") { xr.Read(); break; } } if (xr.NodeType != XmlNodeType.CDATA) { CError.WriteLine("Reader positioned on {0}", xr.NodeType); xr.Dispose(); Assert.True(false); } using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("root"); w.WriteNode(xr, false); w.WriteEndElement(); } xr.Dispose(); Assert.True(utils.CompareReader("<root><![CDATA[cdata content]]></root>")); }
public void writeAttributes_8(XmlWriterUtils utils) { if (IsXPathDataModelReader()) { CError.WriteLine("{0} does not support XmlDecl node", readerType); return; } using (XmlWriter w = utils.CreateWriter()) { using (XmlReader xr = CreateReader("Simple.xml")) { xr.Read(); if (xr.NodeType != XmlNodeType.XmlDeclaration) { CError.WriteLine("Reader not positioned on XmlDeclaration"); CError.WriteLine(xr.LocalName); xr.Dispose(); w.Dispose(); Assert.True(false); } w.WriteStartElement("Root"); w.WriteAttributes(xr, false); w.WriteEndElement(); } } Assert.True(utils.CompareReader("<Root version=\"1.0\" standalone=\"yes\" />")); }
public void writeAttributes_13(XmlWriterUtils utils) { string strxml = "<E a=\"><"'&\" />"; using (XmlReader xr = CreateReader(new StringReader(strxml))) { xr.Read(); xr.MoveToFirstAttribute(); if (xr.NodeType != XmlNodeType.Attribute) { CError.WriteLine("Reader positioned on {0}", xr.NodeType.ToString()); xr.Dispose(); Assert.True(false); } using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteAttributes(xr, false); w.WriteEndElement(); } } Assert.True(utils.CompareReader("<Root a=\"><"'&\" />")); }
public void writeNode_XmlReader26(XmlWriterUtils utils) { XmlReader xr = CreateReaderIgnoreWS("XmlReader.xml"); while (xr.Read()) { if (xr.LocalName == "CommentNode") { xr.Read(); break; } } if (xr.NodeType != XmlNodeType.Comment) { CError.WriteLine("Reader positioned on {0}", xr.NodeType); xr.Dispose(); Assert.True(false); } using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("root"); w.WriteNode(xr, false); w.WriteEndElement(); } xr.Dispose(); Assert.True(utils.CompareReader("<root><!--Comment--></root>")); }
public void element_3(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root", "http://my.com"); w.WriteEndElement(); } Assert.True(utils.CompareReader("<Root xmlns=\"http://my.com\" />")); }
public void element_1(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteEndElement(); } Assert.True(utils.CompareReader("<Root />")); }
public void attribute_20(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteAttributeString("a", null, "< > &"); w.WriteEndElement(); } Assert.True(utils.CompareReader("<Root a=\"< > &\" />")); }
public void attribute_15(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteAttributeString("a", null, "b\"c"); w.WriteEndElement(); } Assert.True(utils.CompareReader("<Root a=\"b"c\" />")); }
public void frag_4(XmlWriterUtils utils) { XmlWriter w = utils.CreateWriter(ConformanceLevel.Fragment); int i = 1; w.WriteValue(i); w.WriteElementString("Root", "test"); w.Dispose(); Assert.True(utils.CompareReader("1<Root>test</Root>")); }
public void frag_3(XmlWriterUtils utils) { XmlWriter w = utils.CreateWriter(ConformanceLevel.Fragment); w.WriteStartElement("Root"); w.WriteEndElement(); w.WriteString("Top level text"); w.Dispose(); Assert.True(utils.CompareReader("<Root />Top level text")); }
public void attribute_2(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteStartAttribute("attr1"); w.WriteEndElement(); } Assert.True(utils.CompareReader("<Root attr1=\"\" />")); }
public void attribute_24(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement(string.Empty, "test", "ns"); w.WriteStartAttribute("attr"); w.WriteEndAttribute(); w.WriteEndElement(); } Assert.True(utils.CompareReader("<test attr=\"\" xmlns=\"ns\" />")); }
public void attribute_19(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteAttributeString("a", null, "\x20\x9\xD\xA"); w.WriteEndElement(); } Assert.True(utils.CompareReader("<Root a=\" 	
\" />")); }
public void var_2(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteStartAttribute("attr"); w.WriteComment("This text is a comment"); w.WriteEndElement(); } Assert.True(utils.CompareReader("<Root attr=''><!--This text is a comment--></Root>")); }
public void attribute_26(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("pre", "test", "ns"); w.WriteStartAttribute(null, "attr", "ns"); w.WriteStartAttribute("attr"); w.WriteEndElement(); } Assert.True(utils.CompareReader("<pre:test pre:attr=\"\" attr=\"\" xmlns:pre=\"ns\" />")); }
public void attribute_7(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteStartAttribute("pre1", "attr1", "http://my.com"); w.WriteEndAttribute(); w.WriteEndElement(); } Assert.True(utils.CompareReader("<Root pre1:attr1=\"\" xmlns:pre1=\"http://my.com\" />")); }
public void attribute_4(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteAttributeString("attr1", "val1"); w.WriteAttributeString("attr2", "val2"); w.WriteEndElement(); } Assert.True(utils.CompareReader("<Root attr1=\"val1\" attr2=\"val2\" />")); }
public void writeNode_XmlReader3(XmlWriterUtils utils) { using (XmlReader xr = CreateReader(new StringReader("<root />"))) { using (XmlWriter w = utils.CreateWriter()) { w.WriteNode(xr, false); } } Assert.True(utils.CompareReader("<root />")); }
public void var_1(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteStartAttribute("attr"); w.WriteStartElement("child"); w.WriteEndElement(); w.WriteEndElement(); } Assert.True(utils.CompareReader("<Root attr=''><child /></Root>")); }
public void frag_6(XmlWriterUtils utils) { XmlWriter w = utils.CreateWriter(ConformanceLevel.Fragment); int i = 1; w.WriteValue(i); w.WriteValue(i); w.WriteValue(i); w.WriteValue(i); w.WriteStartElement("Root"); w.WriteEndElement(); w.WriteValue(i); w.WriteValue(i); w.WriteValue(i); w.WriteValue(i); w.Dispose(); Assert.True(utils.CompareReader("1111<Root />1111")); }
public void attribute_16(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteAttributeString("a", "&"); w.WriteAttributeString("b", "A"); w.WriteAttributeString("c", "C"); w.WriteEndElement(); } Assert.True(utils.CompareReader("<Root a=\"&\" b=\"&#65;\" c=\"&#x43;\" />")); }
public void writeNode_XmlReader21(XmlWriterUtils utils) { string strxml = "<root></root>"; XmlReader xr = CreateReader(new StringReader(strxml)); using (XmlWriter w = utils.CreateWriter()) { w.WriteNode(xr, false); } xr.Dispose(); Assert.True(utils.CompareReader("<root></root>")); }
public void attribute_27(XmlWriterUtils utils) { XmlWriterSettings s = new XmlWriterSettings(); s.NewLineHandling = NewLineHandling.Replace; using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("root"); w.WriteAttributeString("a", "|\x0D|\x0A|\x0D\x0A|"); w.WriteEndElement(); } Assert.True(utils.CompareReader("<root a=\"|
|
|
|\" />")); }