public void checkChars_3(XmlWriterUtils utils, string tokenType) { char[] invalidXML = { '\u0000', '\u0008', '\u000B', '\u000C', '\u000E', '\u001F', '\uFFFE', '\uFFFF' }; XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.CheckCharacters = false; wSettings.CloseOutput = true; XmlWriter w = utils.CreateWriter(wSettings); CError.Compare(w.Settings.CheckCharacters, false, "Mismatch in CheckCharacters"); w.WriteStartElement("Root"); switch (tokenType) { case "Comment": w.WriteComment(invalidXML[2].ToString()); w.WriteEndElement(); w.Dispose(); string exp = utils.IsIndent() ? "<Root>" + Environment.NewLine + " <!--\u000B-->" + Environment.NewLine + "</Root>" : "<Root><!--\u000B--></Root>"; Assert.True(utils.CompareString(exp)); break; case "PI": w.WriteProcessingInstruction("pi", invalidXML[6].ToString()); w.WriteEndElement(); w.Dispose(); exp = utils.IsIndent() ? "<Root>" + Environment.NewLine + " <?pi \uFFFE?>" + Environment.NewLine + "</Root>" : "<Root><?pi \uFFFE?></Root>"; Assert.True(utils.CompareString(exp)); break; case "RawString": w.WriteRaw(invalidXML[4].ToString()); w.WriteEndElement(); w.Dispose(); Assert.True(utils.CompareString("<Root>\u000E</Root>")); break; case "RawChars": w.WriteRaw(invalidXML, 6, 2); w.WriteEndElement(); w.Dispose(); Assert.True(utils.CompareString("<Root>\uFFFE\uFFFF</Root>")); break; case "CData": w.WriteCData(invalidXML[1].ToString()); w.WriteEndElement(); w.Dispose(); Assert.True(utils.CompareString("<Root><![CDATA[\u0008]]></Root>")); break; default: CError.Compare(false, "Invalid param value"); Assert.True(false); break; } }
public void indent_29(XmlWriterUtils utils) { // The output should be the same for ConformanceLevel.Document/Auto int i; for (i = 0; i < 2; i++) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = false; wSettings.Indent = true; wSettings.ConformanceLevel = (i % 2) == 0 ? ConformanceLevel.Auto : ConformanceLevel.Document; CError.WriteLine("ConformanceLevel: {0}", wSettings.ConformanceLevel.ToString()); XmlWriter w = utils.CreateWriter(wSettings); Encoding encoding = w.Settings.Encoding; if (wSettings.ConformanceLevel == ConformanceLevel.Auto) { // Write the decl as PI - since WriteStartDocument would switch to Document mode w.WriteProcessingInstruction("xml", string.Format("version=\"1.0\" encoding=\"{0}\"", encoding.WebName)); } else { w.WriteStartDocument(); } w.WriteStartElement("root"); w.Dispose(); string expectedResult = string.Format("<?xml version=\"1.0\" encoding=\"{0}\"?>" + wSettings.NewLineChars + "<root />", encoding.WebName); CError.Compare(utils.CompareString(expectedResult), ""); } }
public void indent_39(XmlWriterUtils utils, ConformanceLevel conformanceLevel) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.Indent = true; wSettings.ConformanceLevel = conformanceLevel; using (XmlWriter w = utils.CreateWriter(wSettings)) { w.WriteProcessingInstruction("piname1", "pitext1"); w.WriteComment("comment1"); w.WriteProcessingInstruction("piname2", "pitext2"); w.WriteStartElement("root"); w.WriteStartElement("e1"); w.WriteStartElement("e2"); w.WriteStartElement("e3"); w.WriteStartElement("e4"); w.WriteEndElement(); w.WriteString("text1"); w.WriteProcessingInstruction("piname3", "pitext3"); w.WriteEndElement(); w.WriteComment("comment2"); w.WriteCData("cdata1"); w.WriteString("text2"); w.WriteProcessingInstruction("piname4", "pitext4"); w.WriteCData("cdata2"); w.WriteComment("comment3"); w.WriteProcessingInstruction("piname5", "pitext5"); w.WriteEndElement(); w.WriteEndElement(); } CError.Compare(utils.CompareString("<?piname1 pitext1?>" + wSettings.NewLineChars + "<!--comment1-->" + wSettings.NewLineChars + "<?piname2 pitext2?>" + wSettings.NewLineChars + "<root>" + wSettings.NewLineChars + " <e1>" + wSettings.NewLineChars + " <e2>" + wSettings.NewLineChars + " <e3>" + wSettings.NewLineChars + " <e4 />text1<?piname3 pitext3?></e3>" + wSettings.NewLineChars + " <!--comment2--><![CDATA[cdata1]]>text2<?piname4 pitext4?><![CDATA[cdata2]]><!--comment3--><?piname5 pitext5?></e2>" + wSettings.NewLineChars + " </e1>" + wSettings.NewLineChars + "</root>"), ""); return; }
public void writeNode_XmlReader28(XmlWriterUtils utils) { string strxml = "<?xml version=\"1.0\" standalone=\"yes\"?><Root />"; XmlReader xr = CreateReader(new StringReader(strxml)); xr.Read(); if (xr.NodeType != XmlNodeType.XmlDeclaration) { CError.WriteLine("Reader positioned on {0}", xr.NodeType); xr.Dispose(); return; } XmlWriterSettings ws = new XmlWriterSettings(); ws.OmitXmlDeclaration = false; XmlWriter w = utils.CreateWriter(ws); w.WriteNode(xr, false); w.WriteStartElement("Root"); w.WriteEndElement(); xr.Dispose(); w.Dispose(); strxml = utils.IsIndent() ? "<?xml version=\"1.0\" standalone=\"yes\"?>" + Environment.NewLine + "<Root />" : strxml; Assert.True(utils.CompareString(strxml)); }
public void indent_28(XmlWriterUtils utils) { // The output should be the same for ConformanceLevel.Document/Auto // and with WriteStartDocument called or not int i; for (i = 0; i < 4; i++) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.Indent = true; wSettings.ConformanceLevel = (i % 2) == 0 ? ConformanceLevel.Auto : ConformanceLevel.Document; CError.WriteLine("ConformanceLevel: {0}", wSettings.ConformanceLevel.ToString()); using (XmlWriter w = utils.CreateWriter(wSettings)) { if (i > 1) { CError.WriteLine("WriteStartDocument called."); w.WriteStartDocument(); } else { CError.WriteLine("WriteStartDocument not called."); } w.WriteStartElement("root"); } CError.Compare(utils.CompareString("<root />"), ""); } return; }
public void indent_5(XmlWriterUtils utils) { XmlWriter w = utils.CreateWriter(); w.WriteStartElement("Root"); w.WriteString(""); w.WriteFullEndElement(); w.Dispose(); Assert.True(utils.CompareString("<Root></Root>")); }
public void NewLineHandling_3(XmlWriterUtils utils) { XmlWriter w = utils.CreateWriter(); w.WriteStartElement("root"); w.WriteString("\r\n"); w.WriteEndElement(); w.Dispose(); Assert.True(utils.CompareString("<root>" + w.Settings.NewLineChars + "</root>")); }
public void attribute_6(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("Root"); w.WriteStartAttribute("attr1", "http://my.com"); w.WriteEndAttribute(); w.WriteEndElement(); } Assert.True(utils.CompareString("<Root ~a p1 a~:attr1=\"\" xmlns:~a p1 A~=\"http://my.com\" />")); }
public void element_10(XmlWriterUtils utils, bool defattr) { string xml = "<a p1:a=\"\" p2:a=\"\" p3:a=\"\" p4:a=\"\" p5:a=\"\" p6:a=\"\" p7:a=\"\" p8:a=\"\" p9:a=\"\" p10:a=\"\" p11:a=\"\" p12:a=\"\" p13:a=\"\" p14:a=\"\" p15:a=\"\" p16:a=\"\" p17:a=\"\" p18:a=\"\" p19:a=\"\" p20:a=\"\" p21:a=\"\" p22:a=\"\" p23:a=\"\" p24:a=\"\" p25:a=\"\" p26:a=\"\" p27:a=\"\" p28:a=\"\" p29:a=\"\" p30:a=\"\" p31:a=\"\" p32:a=\"\" p33:a=\"\" p34:a=\"\" p35:a=\"\" p36:a=\"\" p37:a=\"\" p38:a=\"\" p39:a=\"\" p40:a=\"\" p41:a=\"\" p42:a=\"\" p43:a=\"\" p44:a=\"\" p45:a=\"\" p46:a=\"\" p47:a=\"\" p48:a=\"\" p49:a=\"\" p50:a=\"\" p51:a=\"\" p52:a=\"\" p53:a=\"\" p54:a=\"\" p55:a=\"\" p56:a=\"\" p57:a=\"\" p58:a=\"\" p59:a=\"\" p60:a=\"\" p61:a=\"\" p62:a=\"\" p63:a=\"\" p64:a=\"\" p65:a=\"\" p66:a=\"\" p67:a=\"\" p68:a=\"\" p69:a=\"\" p70:a=\"\" p71:a=\"\" p72:a=\"\" p73:a=\"\" p74:a=\"\" p75:a=\"\" p76:a=\"\" p77:a=\"\" p78:a=\"\" p79:a=\"\" p80:a=\"\" p81:a=\"\" p82:a=\"\" p83:a=\"\" p84:a=\"\" p85:a=\"\" p86:a=\"\" p87:a=\"\" p88:a=\"\" p89:a=\"\" p90:a=\"\" p91:a=\"\" p92:a=\"\" p93:a=\"\" p94:a=\"\" p95:a=\"\" p96:a=\"\" p97:a=\"\" p98:a=\"\" p99:a=\"\" p100:a=\"\" xmlns:p100=\"b99\" xmlns:p99=\"b98\" xmlns:p98=\"b97\" xmlns:p97=\"b96\" xmlns:p96=\"b95\" xmlns:p95=\"b94\" xmlns:p94=\"b93\" xmlns:p93=\"b92\" xmlns:p92=\"b91\" xmlns:p91=\"b90\" xmlns:p90=\"b89\" xmlns:p89=\"b88\" xmlns:p88=\"b87\" xmlns:p87=\"b86\" xmlns:p86=\"b85\" xmlns:p85=\"b84\" xmlns:p84=\"b83\" xmlns:p83=\"b82\" xmlns:p82=\"b81\" xmlns:p81=\"b80\" xmlns:p80=\"b79\" xmlns:p79=\"b78\" xmlns:p78=\"b77\" xmlns:p77=\"b76\" xmlns:p76=\"b75\" xmlns:p75=\"b74\" xmlns:p74=\"b73\" xmlns:p73=\"b72\" xmlns:p72=\"b71\" xmlns:p71=\"b70\" xmlns:p70=\"b69\" xmlns:p69=\"b68\" xmlns:p68=\"b67\" xmlns:p67=\"b66\" xmlns:p66=\"b65\" xmlns:p65=\"b64\" xmlns:p64=\"b63\" xmlns:p63=\"b62\" xmlns:p62=\"b61\" xmlns:p61=\"b60\" xmlns:p60=\"b59\" xmlns:p59=\"b58\" xmlns:p58=\"b57\" xmlns:p57=\"b56\" xmlns:p56=\"b55\" xmlns:p55=\"b54\" xmlns:p54=\"b53\" xmlns:p53=\"b52\" xmlns:p52=\"b51\" xmlns:p51=\"b50\" xmlns:p50=\"b49\" xmlns:p49=\"b48\" xmlns:p48=\"b47\" xmlns:p47=\"b46\" xmlns:p46=\"b45\" xmlns:p45=\"b44\" xmlns:p44=\"b43\" xmlns:p43=\"b42\" xmlns:p42=\"b41\" xmlns:p41=\"b40\" xmlns:p40=\"b39\" xmlns:p39=\"b38\" xmlns:p38=\"b37\" xmlns:p37=\"b36\" xmlns:p36=\"b35\" xmlns:p35=\"b34\" xmlns:p34=\"b33\" xmlns:p33=\"b32\" xmlns:p32=\"b31\" xmlns:p31=\"b30\" xmlns:p30=\"b29\" xmlns:p29=\"b28\" xmlns:p28=\"b27\" xmlns:p27=\"b26\" xmlns:p26=\"b25\" xmlns:p25=\"b24\" xmlns:p24=\"b23\" xmlns:p23=\"b22\" xmlns:p22=\"b21\" xmlns:p21=\"b20\" xmlns:p20=\"b19\" xmlns:p19=\"b18\" xmlns:p18=\"b17\" xmlns:p17=\"b16\" xmlns:p16=\"b15\" xmlns:p15=\"b14\" xmlns:p14=\"b13\" xmlns:p13=\"b12\" xmlns:p12=\"b11\" xmlns:p11=\"b10\" xmlns:p10=\"b9\" xmlns:p9=\"b8\" xmlns:p8=\"b7\" xmlns:p7=\"b6\" xmlns:p6=\"b5\" xmlns:p5=\"b4\" xmlns:p4=\"b3\" xmlns:p3=\"b2\" xmlns:p2=\"b1\" xmlns:p1=\"b0\" />"; XmlReader r = ReaderHelper.Create(new StringReader(xml)); using (XmlWriter w = utils.CreateWriter()) { w.WriteNode(r, defattr); } Assert.True((utils.CompareString(xml))); }
public void indent_1(XmlWriterUtils utils) { XmlWriter w = utils.CreateWriter(); CError.Compare(w.Settings.Indent, false, "Mismatch in Indent"); w.WriteStartElement("Root"); w.WriteStartElement("child"); w.WriteEndElement(); w.WriteEndElement(); w.Dispose(); Assert.True(utils.CompareString("<Root><child /></Root>")); }
public void docType_5(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { String docName = "Root"; String docValue = "]>"; w.WriteDocType(docName, null, null, docValue); w.WriteStartElement("Root"); w.WriteEndElement(); } string exp = utils.IsIndent() ? "<!DOCTYPE Root []>]>" + Environment.NewLine + "<Root />" : "<!DOCTYPE Root []>]><Root />"; Assert.True(utils.CompareString(exp)); }
public void docType_2(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteDocType("test", null, null, "<!ENTITY e 'abc'>"); w.WriteStartElement("Root"); w.WriteEndElement(); } string exp = utils.IsIndent() ? "<!DOCTYPE test [<!ENTITY e 'abc'>]>" + Environment.NewLine + "<Root />" : "<!DOCTYPE test [<!ENTITY e 'abc'>]><Root />"; Assert.True(utils.CompareString(exp)); }
public void NewLineHandling_7(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; XmlWriter w = utils.CreateWriter(wSettings); w.WriteStartElement("root"); w.WriteAttributeString("attr", "\r"); w.Dispose(); Assert.True(utils.CompareString("<root attr=\"
\" />")); }
public void docType_1(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteDocType("ROOT", "publicid", "sysid", "<!ENTITY e 'abc'>"); w.WriteStartElement("ROOT"); w.WriteEndElement(); } string exp = utils.IsIndent() ? "<!DOCTYPE ROOT PUBLIC \"publicid\" \"sysid\"[<!ENTITY e 'abc'>]>" + Environment.NewLine + "<ROOT />" : "<!DOCTYPE ROOT PUBLIC \"publicid\" \"sysid\"[<!ENTITY e 'abc'>]><ROOT />"; Assert.True(utils.CompareString(exp)); }
public void indent_6(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.Indent = true; XmlWriter w = utils.CreateWriter(wSettings); w.WriteStartElement("Root"); w.WriteString(""); w.WriteFullEndElement(); w.Dispose(); Assert.True(utils.CompareString("<Root></Root>")); }
public void indent_2(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.Indent = true; XmlWriter w = utils.CreateWriter(wSettings); w.WriteStartElement("Root"); w.WriteStartElement("child"); w.WriteEndElement(); w.WriteEndElement(); w.Dispose(); Assert.True(utils.CompareString("<Root>" + wSettings.NewLineChars + " <child />" + wSettings.NewLineChars + "</Root>")); }
public void indent_21(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.Indent = true; XmlWriter w = utils.CreateWriter(wSettings); w.WriteStartDocument(); w.WriteComment("value"); w.WriteStartElement("root"); w.Dispose(); CError.Compare(utils.CompareString("<!--value-->" + wSettings.NewLineChars + "<root />"), ""); return; }
public void NewLineHandling_13(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.NewLineHandling = NewLineHandling.Entitize; XmlWriter w = utils.CreateWriter(wSettings); w.WriteStartElement("a"); w.WriteString("A \r\n \r \n B"); w.WriteEndElement(); w.Dispose(); Assert.True(utils.CompareString("<a>A 
\xA 
 \xA B</a>")); }
public void NewLineHandling_6(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.NewLineHandling = NewLineHandling.Entitize; XmlWriter w = utils.CreateWriter(wSettings); w.WriteStartElement("root"); w.WriteString("\r\n"); w.WriteEndElement(); w.Dispose(); Assert.True(utils.CompareString("<root>
\xA</root>")); }
public void NewLineChars_5(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.NewLineChars = "\x20"; XmlWriter w = utils.CreateWriter(wSettings); CError.Compare(w.Settings.NewLineChars, "\x20", "Mismatch in NewLineChars"); w.WriteStartElement("root"); w.WriteString("Test\r\nNewLine"); w.WriteEndElement(); w.Dispose(); Assert.True(utils.CompareString("<root>Test\x20NewLine</root>")); }
public void element_9(XmlWriterUtils utils) { string enc = (utils.WriterType == WriterType.UnicodeWriter || utils.WriterType == WriterType.UnicodeWriterIndent) ? "16" : "8"; string exp = (utils.WriterType == WriterType.UTF8WriterIndent || utils.WriterType == WriterType.UnicodeWriterIndent) ? string.Format("<?xml version=\"1.0\" encoding=\"utf-{0}\"?>" + Environment.NewLine + "<a:b xmlns:a=\"c\" />", enc) : string.Format("<?xml version=\"1.0\" encoding=\"utf-{0}\"?><a:b xmlns:a=\"c\" />", enc); XmlWriterSettings ws = new XmlWriterSettings(); ws.OmitXmlDeclaration = false; using (XmlWriter w = utils.CreateWriter(ws)) { w.WriteStartElement("a", "b", "c"); } Assert.True((utils.CompareString(exp))); }
public void indent_11(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.Indent = true; XmlWriter w = utils.CreateWriter(wSettings); w.WriteStartElement("root"); w.WriteCData("text"); w.WriteElementString("foo", ""); w.WriteEndElement(); w.Dispose(); CError.Compare(utils.CompareString("<root><![CDATA[text]]><foo /></root>"), ""); return; }
public void indent_14(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.Indent = true; XmlWriter w = utils.CreateWriter(wSettings); w.WriteStartElement("root"); w.WriteEntityRef("e"); w.WriteElementString("foo", ""); w.WriteEndElement(); w.Dispose(); CError.Compare(utils.CompareString("<root>&e;<foo /></root>"), ""); return; }
public void indent_24(XmlWriterUtils utils, ConformanceLevel conformanceLevel) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.Indent = true; wSettings.ConformanceLevel = conformanceLevel; using (XmlWriter w = utils.CreateWriter(wSettings)) { w.WriteStartElement("root"); w.WriteString("text"); w.WriteStartElement("child"); w.WriteComment("value"); } CError.Compare(utils.CompareString("<root>text<child><!--value--></child></root>"), ""); return; }
public void attribute_22(XmlWriterUtils utils) { string exp = "<test ~f p a~:a1=\"v\" xmlns:~f p A~=\"ns1\"><base ~f p b~:a2=\"v\" ~a p4 ab~:a3=\"v\" xmlns:~a p4 AB~=\"ns2\" /></test>"; using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("test"); w.WriteAttributeString("p", "a1", "ns1", "v"); w.WriteStartElement("base"); w.WriteAttributeString("a2", "ns1", "v"); w.WriteAttributeString("p", "a3", "ns2", "v"); w.WriteEndElement(); w.WriteEndElement(); } exp = utils.IsIndent() ? "<test p:a1=\"v\" xmlns:p=\"ns1\">" + Environment.NewLine + " <base p:a2=\"v\" p4:a3=\"v\" xmlns:p4=\"ns2\" />" + Environment.NewLine + "</test>" : exp; Assert.True(utils.CompareString(exp)); }
public void attribute_21(XmlWriterUtils utils) { using (XmlWriter w = utils.CreateWriter()) { w.WriteStartElement("test"); w.WriteAttributeString("xmlns", "n1", null, "http://testbasens"); w.WriteStartElement("base"); w.WriteAttributeString("id", "http://testbasens", "5"); w.WriteAttributeString("lang", "http://common", "en"); w.WriteEndElement(); w.WriteEndElement(); } string exp = utils.IsIndent() ? "<test xmlns:n1=\"http://testbasens\">" + Environment.NewLine + " <base n1:id=\"5\" p4:lang=\"en\" xmlns:p4=\"http://common\" />" + Environment.NewLine + "</test>" : "<test xmlns:~f n1 A~=\"http://testbasens\"><base ~f n1 a~:id=\"5\" ~a p4 a~:lang=\"en\" xmlns:~a p4 A~=\"http://common\" /></test>"; Assert.True(utils.CompareString(exp)); }
public void indent_19(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.Indent = true; XmlWriter w = utils.CreateWriter(wSettings); w.WriteStartElement("root"); w.WriteAttributeString("a1", "value"); w.WriteStartElement("foo"); w.WriteAttributeString("a2", "value"); w.WriteEndDocument(); w.Dispose(); CError.Compare(utils.CompareString("<root a1=\"value\">" + wSettings.NewLineChars + " <foo a2=\"value\" />" + wSettings.NewLineChars + "</root>"), ""); return; }
public void indent_15(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.OmitXmlDeclaration = true; wSettings.Indent = true; XmlWriter w = utils.CreateWriter(wSettings); w.WriteStartElement("e1"); w.WriteStartElement("e2"); w.WriteStartElement("e3"); w.WriteStartElement("e4"); w.WriteEndDocument(); w.Dispose(); CError.Compare(utils.CompareString("<e1>" + wSettings.NewLineChars + " <e2>" + wSettings.NewLineChars + " <e3>" + wSettings.NewLineChars + " <e4 />" + wSettings.NewLineChars + " </e3>" + wSettings.NewLineChars + " </e2>" + wSettings.NewLineChars + "</e1>"), ""); return; }
public void indent_36(XmlWriterUtils utils, ConformanceLevel conformanceLevel) { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.Indent = true; wSettings.ConformanceLevel = conformanceLevel; using (XmlWriter w = utils.CreateWriter(wSettings)) { w.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); w.WriteDocType("name", "publicid", "systemid", "subset"); w.WriteProcessingInstruction("piname1", "pitext1"); w.WriteProcessingInstruction("piname2", "pitext2"); w.WriteStartElement("root"); } CError.Compare(utils.CompareString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + wSettings.NewLineChars + "<!DOCTYPE name PUBLIC \"publicid\" \"systemid\"[subset]>" + wSettings.NewLineChars + "<?piname1 pitext1?>" + wSettings.NewLineChars + "<?piname2 pitext2?>" + wSettings.NewLineChars + "<root />"), ""); return; }
public void writeNode_XmlReader37(XmlWriterUtils utils, bool defattr) { string strxml = "<!DOCTYPE root PUBLIC \"\" \"#\"><root/>"; string exp = utils.IsIndent() ? "<!DOCTYPE root PUBLIC \"\" \"#\"[]>" + Environment.NewLine + "<root />" : "<!DOCTYPE root PUBLIC \"\" \"#\"[]><root />"; using (XmlReader xr = CreateReader(new StringReader(strxml))) using (XmlWriter w = utils.CreateWriter()) { while (!xr.EOF) { w.WriteNode(xr, defattr); } } Assert.True(utils.CompareString(exp)); }