public CustomReader(Stream stream) { XmlReaderSettings rs = new XmlReaderSettings(); rs.DtdProcessing = DtdProcessing.Ignore; _tr = ReaderHelper.Create(stream, rs, (string)null); }
public int w02() { ManagedNodeWriter mn = new ManagedNodeWriter(); mn.PutPattern("XEA"); mn.PutAttribute("xml:space", "preserve"); mn.PutPattern("/PWPWE/WCCCCPPPee"); CError.WriteLineIgnore(mn.GetNodes()); XmlReaderSettings rs = new XmlReaderSettings(); XmlReader reader = null; rs.IgnoreWhitespace = true; reader = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null); CheckIgnores(reader, true, false, false); if (_wsCount != 3) { CError.WriteLineIgnore("Ws = " + _wsCount); return(TEST_FAIL); } rs.IgnoreWhitespace = false; reader = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null); CheckIgnores(reader, false, false, false); if (_wsCount != 3) { CError.WriteLineIgnore("Ws = " + _wsCount); return(TEST_FAIL); } return(TEST_PASS); }
public static bool Create(TextReader input, XmlReaderSettings settings) { XmlReader reader = null; try { reader = ReaderHelper.Create(input, settings); while (reader.Read()) { ; } return(true); } catch (ArgumentNullException ane) { CError.WriteLineIgnore(ane.ToString()); return(false); } finally { if (reader != null) { reader.Dispose(); } } }
public CustomReader(string filename) { XmlReaderSettings rs = new XmlReaderSettings(); rs.DtdProcessing = DtdProcessing.Ignore; _tr = ReaderHelper.Create(filename, rs); }
public int w03() { ManagedNodeWriter mn = new ManagedNodeWriter(); mn.PutPattern("WXEAA/M"); CError.WriteLineIgnore(mn.GetNodes()); XmlReaderSettings rs = new XmlReaderSettings(); XmlReader reader = null; rs.IgnoreComments = true; reader = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null); bool thrown = false; try { CheckIgnores(reader, true, false, false); } catch (XmlException xe) { CError.WriteLineIgnore(xe.Message); thrown = true; } if (!thrown) { return(TEST_FAIL); } return(TEST_PASS); }
//[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<!DOCTYPE ROOT [<!ENTITY a '&a;'>]><ROOT att='&a;'/>", 10 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&a;</a>'>]><test>&a;</test>", 25 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&</a>'>]><test>&a;<test>", 26 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<q = 'a'/>", 5 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { string.Format("<!-- http://www.w3.org is bound to n1 and n2 -->{0}<x xmlns:n1=\"http://www.w3.org\"{0} xmlns:n2=\"http://www.w3.org\" >{0} <bad n1:a=\"1\" n2:a=\"2\" /></x>", Environment.NewLine), 35 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<root><!--comment \uD812><!--comment \uD812>-->--></root>", 18 })] public int v270() { string xml = CurVariation.Params[0] as string; int val = (int)CurVariation.Params[1]; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 1; rs.MaxCharactersInDocument = val; try { using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) { ; } } } catch (XmlException) { CError.Compare((int)rs.MaxCharactersFromEntities, 1, "Error"); CError.Compare((int)rs.MaxCharactersInDocument, val, "Error"); return(TEST_PASS); } return(TEST_FAIL); }
public int w01() { ManagedNodeWriter mn = new ManagedNodeWriter(); mn.PutPattern("XWEAWA/PWWPWWE/WWCCCCPPPee"); CError.WriteLineIgnore(mn.GetNodes()); XmlReaderSettings rs = new XmlReaderSettings(); XmlReader reader = null; rs.IgnoreWhitespace = true; reader = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null); if (!CheckIgnores(reader, false, false, true)) { return(TEST_FAIL); } rs.IgnoreWhitespace = false; reader = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null); if (!CheckIgnores(reader, false, false, false)) { return(TEST_FAIL); } return(TEST_PASS); }
public int v3() { string xml = "<a/>"; XmlReaderSettings rs = new XmlReaderSettings(); try { rs.MaxCharactersFromEntities = -1; return(TEST_FAIL); } catch (ArgumentOutOfRangeException) { } try { rs.MaxCharactersInDocument = -1; return(TEST_FAIL); } catch (ArgumentOutOfRangeException) { } CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error"); rs.MaxCharactersFromEntities = 10; rs.MaxCharactersInDocument = 10; using (XmlReader r = ReaderHelper.Create(new StringReader(xml), rs)) { while (r.Read()) { ; } CError.Compare((int)r.Settings.MaxCharactersFromEntities, 10, "Error"); CError.Compare((int)r.Settings.MaxCharactersInDocument, 10, "Error"); } return(TEST_PASS); }
//[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<!DOCTYPE ROOT [<!ENTITY a '&a;'>]><ROOT att='&a;'/>" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&a;</a>'>]><test>&a;</test>" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&</a>'>]><test>&a;<test>" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<q = 'a'/>" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { string.Format("<!-- http://www.w3.org is bound to n1 and n2 -->{0}<x xmlns:n1=\"http://www.w3.org\"{0} xmlns:n2=\"http://www.w3.org\" >{0} <bad n1:a=\"1\" n2:a=\"2\" /></x>", Environment.NewLine) })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<root><!--comment \uD812><!--comment \uD812>-->--></root>" })] public int v260() { string xml = CurVariation.Params[0] as string; XmlReaderSettings rs = new XmlReaderSettings(); rs.DtdProcessing = DtdProcessing.Ignore; rs.MaxCharactersFromEntities = _bigVal; rs.MaxCharactersInDocument = _bigVal; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { try { while (reader.Read()) { ; } } catch (XmlException) { CError.Compare(reader.Settings.MaxCharactersFromEntities, _bigVal, "Error"); CError.Compare(reader.Settings.MaxCharactersInDocument, _bigVal, "Error"); return(TEST_PASS); } } return(TEST_FAIL); }
//[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A />"})] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root>񘍁<Elem>󏹄</Elem>𘀢</Root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE doc [ <!ELEMENT doc ANY> <!ENTITY book 'a&a'>]><doc>&book;</doc>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE doc [ <!ELEMENT doc ANY> <!ENTITY book 'a%a'>]><doc>&book;</doc> " })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&a;</a>'>]><test>&a;</test>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE ROOT [<!ENTITY a '&a;'>]><ROOT att='&a;'/>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE root [<!ELEMENT root ANY><!ENTITY e '\uD812\uDD12'>]><root>&e;</root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&x;</root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<root>va</root>lue</root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root a='&' b='&#65;' c='&#x43;' />" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root a='b"c' />" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root a=' 	
' />" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root foo='& < > " ' A'/>" })] public int v20() { string xml = CurVariation.Params[0] as string; int val = xml.Length - 1; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 1; rs.MaxCharactersInDocument = val; try { XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs); if (AsyncUtil.IsAsyncEnabled) { reader.Read(); } } catch (XmlException) { CError.Compare((int)rs.MaxCharactersFromEntities, 1, "Error"); CError.Compare((int)rs.MaxCharactersInDocument, val, "Error"); return(TEST_PASS); } return(TEST_FAIL); }
public int v2() { XmlReader r = null; Stream s = GetStream(); r = ReaderHelper.Create(s); while (r.Read()) { ; } r.Dispose(); r = ReaderHelper.Create(GetUrl()); while (r.Read()) { ; } r.Dispose(); r = ReaderHelper.Create(GetTextReader()); while (r.Read()) { ; } r.Dispose(); return(TEST_PASS); }
public override XmlReader Create(MyDict <string, object> options) { string tcDesc = (string)options[ReaderFactory.HT_CURDESC]; string tcVar = (string)options[ReaderFactory.HT_CURVAR]; CError.Compare(tcDesc == "factoryreader", "Invalid testcase"); XmlReaderSettings rs = (XmlReaderSettings)options[ReaderFactory.HT_READERSETTINGS]; Stream stream = (Stream)options[ReaderFactory.HT_STREAM]; string filename = (string)options[ReaderFactory.HT_FILENAME]; object readerType = options[ReaderFactory.HT_READERTYPE]; object vt = options[ReaderFactory.HT_VALIDATIONTYPE]; string fragment = (string)options[ReaderFactory.HT_FRAGMENT]; StringReader sr = (StringReader)options[ReaderFactory.HT_STRINGREADER]; if (rs == null) { rs = new XmlReaderSettings(); } rs.DtdProcessing = DtdProcessing.Ignore; if (sr != null) { CError.WriteLine("StringReader"); XmlReader reader = ReaderHelper.Create(sr, rs, string.Empty); return(reader); } if (stream != null) { CError.WriteLine("Stream"); XmlReader reader = ReaderHelper.Create(stream, rs, filename); return(reader); } if (fragment != null) { CError.WriteLine("Fragment"); rs.ConformanceLevel = ConformanceLevel.Fragment; StringReader tr = new StringReader(fragment); XmlReader reader = ReaderHelper.Create(tr, rs, (string)null); return(reader); } if (filename != null) { CError.WriteLine("Filename"); XmlReader reader = ReaderHelper.Create(filename, rs); return(reader); } throw new CTestFailedException("Factory Reader not created"); }
public XmlCustomReader(TextReader textReader, XmlReaderSettings settings, string baseUri) { XmlReader w = ReaderHelper.Create(textReader, settings, baseUri); XmlReaderSettings wsettings = new XmlReaderSettings(); wsettings.CheckCharacters = true; wsettings.DtdProcessing = DtdProcessing.Ignore; wsettings.ConformanceLevel = ConformanceLevel.Auto; _wrappedreader = ReaderHelper.Create(w, wsettings); }
public XmlCustomReader(string filename, XmlReaderSettings settings) { XmlReader w = ReaderHelper.Create(filename, settings); XmlReaderSettings wsettings = new XmlReaderSettings(); wsettings.CheckCharacters = true; wsettings.DtdProcessing = DtdProcessing.Ignore; wsettings.ConformanceLevel = ConformanceLevel.Auto; _wrappedreader = ReaderHelper.Create(w, wsettings); }
/// <summary> /// This method calls the Create Method on the XmlReader and puts the state in CreateSuccess or TestPass. /// It goes in PASS also if the reader threw an expected error. In all other cases it should throw /// TestFailedException. /// </summary> /// <param name="readThru">This param determines which overload to call. /// In future on multiple overloads we can make this param /// an enum which can be set using the spec file data</param> protected void CreateReader(ReadThru readThru) { // Assumption is that the Create method doesn't throw NullReferenceException and // it is not the goal of this framework to test if they are thrown anywhere. // but if they are thrown that's a problem and they shouldn't be caught but exposed. try { switch (readThru) { case ReadThru.TextReader: _factoryReader = ReaderHelper.Create(_textReader, _settings, _baseUri); break; case ReadThru.XmlReader: _factoryReader = ReaderHelper.Create(_underlyingReader, _settings); break; case ReadThru.Stream: _factoryReader = ReaderHelper.Create(_stream, _settings); break; default: throw new CTestFailedException("Unknown ReadThru type: " + readThru); } pstate = TestState.CreateSuccess; } catch (ArgumentNullException ane) { Log(ane.Message); Log(ane.StackTrace); if (!IsVariationValid) { if (!CheckException(ane)) { pstate = TestState.Error; DumpVariationInfo(); throw new CTestFailedException( "Argument Null Exception Thrown in CreateMethod, is your variation data correct?"); } else { //This means that the Exception was checked and everything is fine. pstate = TestState.Pass; } } else { pstate = TestState.Error; DumpVariationInfo(); throw new CTestFailedException( "Argument Null Exception Thrown in CreateMethod, is your variation data correct?"); } } }
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 int TestLinePos45() { XmlReader DataReader = ReaderHelper.Create(new StringReader("<root></root>")); DataReader.Read(); CError.Compare((DataReader as IXmlLineInfo).HasLineInfo(), "DataReader HasLineInfo"); XmlReaderSettings rs = new XmlReaderSettings(); XmlReader vr = ReaderHelper.Create(DataReader, rs); vr.Read(); CError.Compare((vr as IXmlLineInfo).HasLineInfo(), "DataReader HasLineInfo"); return(TEST_PASS); }
public int v1() { XmlReaderSettings rs = new XmlReaderSettings(); CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error"); using (XmlReader r = ReaderHelper.Create(new StringReader("<foo/>"))) { CError.Compare(r.Settings.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(r.Settings.MaxCharactersInDocument, _defaultCharsDoc, "Error"); } return(TEST_PASS); }
public CustomReader(string url, bool isFragment) { XmlReaderSettings settings = new XmlReaderSettings(); if (!isFragment) { _tr = ReaderHelper.Create(url, settings); } else { settings.ConformanceLevel = ConformanceLevel.Fragment; _tr = ReaderHelper.Create(url, settings, null); } }
public CustomReader(string url, bool isFragment) { XmlReaderSettings settings = new XmlReaderSettings(); settings.DtdProcessing = DtdProcessing.Ignore; if (!isFragment) { _tr = ReaderHelper.Create(url, settings); } else { settings.ConformanceLevel = ConformanceLevel.Fragment; _tr = ReaderHelper.Create(url, settings); } }
public int CDocument() { XmlReaderSettings rs = new XmlReaderSettings(); rs.ConformanceLevel = ConformanceLevel.Document; object[] xml = GetAllPri0ConformanceTestXmlStrings(); if (xml.Length > s_pri0ExpectedDocument.Length) { CError.WriteLine("Invalid Compare attempted"); return(TEST_FAIL); } bool failed = false; for (int i = 0; i < xml.Length; i++) { XmlReader reader = ReaderHelper.Create(new StringReader((string)xml[i]), rs, (string)null); bool actual = false; try { while (reader.Read()) { ; } } catch (XmlException xe) { CError.Write("Case : " + (i + 1)); CError.WriteLine(xe.Message); actual = true; } if (actual != s_pri0ExpectedDocument[i]) { CError.WriteLine("ConformanceLevel = Document"); CError.WriteLine("Test Failed for Case" + (i + 1)); CError.WriteLine("|" + (string)xml[i] + "|"); failed = true; } } if (failed) { return(TEST_FAIL); } return(TEST_PASS); }
public void auto_10(XmlWriterUtils utils) { XmlWriter w = utils.CreateWriter(ConformanceLevel.Auto); string strxml = "<Root>text</Root>"; XmlReader xr = ReaderHelper.Create(new StringReader(strxml)); CError.Compare(w.Settings.ConformanceLevel, ConformanceLevel.Auto, "Error"); xr.Read(); xr.Read(); CError.Compare(xr.NodeType.ToString(), "Text", "Error"); w.WriteNode(xr, false); CError.Compare(w.Settings.ConformanceLevel, ConformanceLevel.Fragment, "Error"); w.Dispose(); xr.Dispose(); return; }
public int pi03() { ManagedNodeWriter mn = new ManagedNodeWriter(); mn.PutPattern("XEEAA/MTe"); CError.WriteLineIgnore(mn.GetNodes()); XmlReaderSettings rs = new XmlReaderSettings(); XmlReader reader = null; rs.IgnoreProcessingInstructions = true; reader = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null); reader.Read(); CError.Compare(reader.NodeType, XmlNodeType.XmlDeclaration, "XmlDecl should not be ignored"); return(TEST_PASS); }
//[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Auto", "Auto", "<root/>", "true" })] //[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Auto", "Auto", "<root/><root/>", "true" })] //[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Fragment", "Auto", "<root/><root/>", "true" })] //[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Document", "Auto", "<root/>", "true" })] //[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Auto", "Fragment", "<root/>", "false" })] //[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Fragment", "Fragment", "<root/>", "true" })] //[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Fragment", "Fragment", "<root/><root/>", "true" })] //[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Document", "Fragment", "<root/>", "false" })] //[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Auto", "Document", "<root/>", "false" })] //[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Fragment", "Document", "<root/><root/>", "false" })] //[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Document", "Document", "<root/>", "true" })] public int wrappingTests() { string underlyingReaderLevel = this.CurVariation.Params[0].ToString(); string wrappingReaderLevel = this.CurVariation.Params[1].ToString(); string conformanceXml = this.CurVariation.Params[2].ToString(); bool valid = this.CurVariation.Params[3].ToString() == "true"; CError.WriteLine(underlyingReaderLevel); CError.WriteLine(wrappingReaderLevel); CError.WriteLine(conformanceXml); CError.WriteLine("IsValid = " + valid); try { XmlReaderSettings rsU = new XmlReaderSettings(); rsU.ConformanceLevel = (ConformanceLevel)Enum.Parse(typeof(ConformanceLevel), underlyingReaderLevel); XmlReader rU = ReaderHelper.Create(new StringReader(conformanceXml), rsU, (string)null); XmlReaderSettings rsW = new XmlReaderSettings(); rsW.ConformanceLevel = (ConformanceLevel)Enum.Parse(typeof(ConformanceLevel), wrappingReaderLevel); XmlReader rW = ReaderHelper.Create(rU, rsW); CError.Compare(rW.ReadState, ReadState.Initial, "ReadState not initial"); } catch (InvalidOperationException ioe) { CError.WriteLineIgnore(ioe.ToString()); if (valid) { throw new CTestFailedException("Valid case throws InvalidOperation"); } else { return(TEST_PASS); } } if (!valid) { throw new CTestFailedException("Invalid case doesnt throw InvalidOperation"); } else { return(TEST_PASS); } }
//[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root>񘍁<Elem>󏹄</Elem>𘀢</Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&x;</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<root>va</root>lue</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root a='&' b='&#65;' c='&#x43;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root a='b"c' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root a=' 	
' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root foo='& < > " ' A'/>" })] public int v60() { string xml = CurVariation.Params[0] as string; XmlReaderSettings rs = new XmlReaderSettings(); rs.DtdProcessing = DtdProcessing.Ignore; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) { ; } CError.Compare((long)reader.Settings.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare((long)reader.Settings.MaxCharactersInDocument, _defaultCharsDoc, "Error"); } return(TEST_PASS); }
public XmlReader CreateReader(TextReader sr) { XmlReader xr = null; XmlReaderSettings readerSettings = new XmlReaderSettings(); readerSettings.CloseInput = true; switch (readerType) { case ReaderType.CoreReader: xr = ReaderHelper.Create(sr, readerSettings, (String)null); break; default: CError.Compare(false, "Unknown reader type: " + readerType); break; } return(xr); }
public void auto_8(XmlWriterUtils utils) { XmlWriter w = utils.CreateWriter(ConformanceLevel.Auto); string strxml = "<!DOCTYPE test [<!ENTITY e 'abc'>]><Root />"; XmlReaderSettings rSettings = new XmlReaderSettings(); rSettings.CloseInput = true; rSettings.DtdProcessing = DtdProcessing.Parse; XmlReader xr = ReaderHelper.Create(new StringReader(strxml), rSettings, (string)null); CError.Compare(w.Settings.ConformanceLevel, ConformanceLevel.Auto, "Error"); xr.Read(); CError.Compare(xr.NodeType.ToString(), "DocumentType", "Error"); w.WriteNode(xr, false); CError.Compare(w.Settings.ConformanceLevel, ConformanceLevel.Document, "Error"); w.Dispose(); xr.Dispose(); return; }
public XmlReader CreateReaderIgnoreWS(TextReader sr) { XmlReader xr = null; XmlReaderSettings readerSettings = new XmlReaderSettings(); readerSettings.DtdProcessing = DtdProcessing.Parse; readerSettings.CloseInput = true; readerSettings.IgnoreWhitespace = true; switch (readerType) { case ReaderType.CoreReader: xr = ReaderHelper.Create(sr, readerSettings, (string)null /*baseUri*/); break; default: CError.Compare(false, "Unknown reader type: " + readerType); break; } return(xr); }
public int LineNumberAndLinePositionAreCorrect() { XmlReaderSettings rs = new XmlReaderSettings(); Stream fs = FilePathUtil.getStream(TestData + "Common\\Bug297091.xsl"); { XmlReader DataReader = ReaderHelper.Create(fs, rs, TestData + "Common\\Bug297091.xsl"); DataReader.Read(); if (DataReader.NodeType != XmlNodeType.Element || ((IXmlLineInfo)DataReader).LineNumber != 1 || ((IXmlLineInfo)DataReader).LinePosition != 2) { CError.Compare(false, "Failed"); } DataReader.Read(); if (DataReader.NodeType != XmlNodeType.Whitespace || ((IXmlLineInfo)DataReader).LineNumber != 4 || ((IXmlLineInfo)DataReader).LinePosition != 2) { CError.Compare(false, "Failed"); } DataReader.Read(); if (DataReader.NodeType != XmlNodeType.Element || ((IXmlLineInfo)DataReader).LineNumber != 5 || ((IXmlLineInfo)DataReader).LinePosition != 3) { CError.Compare(false, "Failed"); } DataReader.Read(); if (DataReader.NodeType != XmlNodeType.Whitespace || ((IXmlLineInfo)DataReader).LineNumber != 5 || ((IXmlLineInfo)DataReader).LinePosition != 28) { CError.Compare(false, "Failed"); } DataReader.Read(); if (DataReader.NodeType != XmlNodeType.EndElement || ((IXmlLineInfo)DataReader).LineNumber != 6 || ((IXmlLineInfo)DataReader).LinePosition != 3) { CError.Compare(false, "Failed"); } } return(TEST_PASS); }
//[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root>񘍁<Elem>󏹄</Elem>𘀢</Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&x;</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<root>va</root>lue</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root a='&' b='&#65;' c='&#x43;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root a='b"c' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root a=' 	
' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root foo='& < > " ' A'/>" })] public int v40() { string xml = CurVariation.Params[0] as string; int val = xml.Length; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 1; rs.MaxCharactersInDocument = val; rs.DtdProcessing = DtdProcessing.Ignore; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) { ; } CError.Compare((int)reader.Settings.MaxCharactersFromEntities, 1, "Error"); CError.Compare((int)reader.Settings.MaxCharactersInDocument, val, "Error"); } return(TEST_PASS); }