You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(174) |
Nov
(85) |
Dec
(14) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(56) |
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
(1) |
Jul
(132) |
Aug
(5) |
Sep
|
Oct
(314) |
Nov
(133) |
Dec
(18) |
2006 |
Jan
(6) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Oleg T. <he...@us...> - 2004-10-30 09:56:40
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/Harold/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26849/v1/test/XInclude-Test-Suite/Harold/test Modified Files: docwithid.xml docwithidandtumbler.xml Log Message: Updated Test Suite and added non-streaming mode tests. Index: docwithidandtumbler.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/Harold/test/docwithidandtumbler.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- docwithidandtumbler.xml 26 Oct 2004 19:28:45 -0000 1.2 +++ docwithidandtumbler.xml 30 Oct 2004 09:56:29 -0000 1.3 @@ -1,5 +1,4 @@ <!DOCTYPE test [ - <!ELEMENT p (#PCDATA)> <!ATTLIST p id ID #REQUIRED> ]> <test> Index: docwithid.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/Harold/test/docwithid.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- docwithid.xml 26 Oct 2004 19:28:44 -0000 1.2 +++ docwithid.xml 30 Oct 2004 09:56:29 -0000 1.3 @@ -1,5 +1,4 @@ <!DOCTYPE test [ - <!ELEMENT p (#PCDATA)> <!ATTLIST p id ID #REQUIRED> ]> <test> |
From: Oleg T. <he...@us...> - 2004-10-30 09:56:40
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/Harold/result In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26849/v1/test/XInclude-Test-Suite/Harold/result Modified Files: accepthtml.xml test.xml Log Message: Updated Test Suite and added non-streaming mode tests. Index: accepthtml.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/Harold/result/accepthtml.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- accepthtml.xml 26 Oct 2004 19:28:43 -0000 1.2 +++ accepthtml.xml 30 Oct 2004 09:56:28 -0000 1.3 @@ -1,4 +1,4 @@ <?xml version="1.0"?> <root xmlns:xi="http://www.w3.org/2001/XInclude"> -<![CDATA[<html><body>content</body></html> -]]></root> \ No newline at end of file +<![CDATA[<html><body>content</body></html>]]> +</root> \ No newline at end of file Index: test.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/Harold/result/test.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- test.xml 26 Oct 2004 19:28:44 -0000 1.2 +++ test.xml 30 Oct 2004 09:56:28 -0000 1.3 @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!-- comment before root --> <!DOCTYPE test [ - <!ELEMENT test (latin1, test2)> +<!ELEMENT test (latin1 , test2)> ]> <test xmlns:xinclude="http://www.w3.org/2001/XInclude"> <latin1> |
From: Oleg T. <he...@us...> - 2004-10-30 09:56:40
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/EdUni/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26849/v1/test/XInclude-Test-Suite/EdUni/test Modified Files: book.xml chap1.xml chap2.xml extract.xml Log Message: Updated Test Suite and added non-streaming mode tests. Index: chap2.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/EdUni/test/chap2.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- chap2.xml 28 Oct 2004 13:01:53 -0000 1.2 +++ chap2.xml 30 Oct 2004 09:56:28 -0000 1.3 @@ -1,5 +1,4 @@ <!DOCTYPE chapter [ -<!ELEMENT chapter (#PCDATA)> <!ATTLIST chapter id ID #IMPLIED> ]> <chapter id="chap2"> Index: book.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/EdUni/test/book.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- book.xml 28 Oct 2004 13:01:53 -0000 1.4 +++ book.xml 30 Oct 2004 09:56:28 -0000 1.5 @@ -1,7 +1,5 @@ <!DOCTYPE book [ -<!ELEMENT intro (#PCDATA)> <!ATTLIST intro id ID #IMPLIED> -<!ELEMENT include (#PCDATA)> <!ATTLIST include xmlns CDATA #FIXED "http://www.w3.org/2001/XInclude"> ]> <book> Index: extract.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/EdUni/test/extract.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- extract.xml 28 Oct 2004 13:01:53 -0000 1.2 +++ extract.xml 30 Oct 2004 09:56:28 -0000 1.3 @@ -1,5 +1,4 @@ <!DOCTYPE extract [ -<!ELEMENT include (#PCDATA)> <!ATTLIST include xmlns CDATA #FIXED "http://www.w3.org/2001/XInclude"> ]> <extract> Index: chap1.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/EdUni/test/chap1.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- chap1.xml 28 Oct 2004 13:01:53 -0000 1.2 +++ chap1.xml 30 Oct 2004 09:56:28 -0000 1.3 @@ -1,5 +1,4 @@ <!DOCTYPE chapter [ -<!ELEMENT chapter (#PCDATA)> <!ATTLIST chapter id ID #IMPLIED> ]> <chapter id="chap1"> |
From: Oleg T. <he...@us...> - 2004-10-30 09:56:38
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/EdUni/result In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26849/v1/test/XInclude-Test-Suite/EdUni/result Modified Files: book.xml Log Message: Updated Test Suite and added non-streaming mode tests. Index: book.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/EdUni/result/book.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- book.xml 19 Oct 2004 16:24:56 -0000 1.4 +++ book.xml 30 Oct 2004 09:56:28 -0000 1.5 @@ -1,8 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE book [ -<!ATTLIST intro id ID #IMPLIED> -<!ATTLIST include xmlns CDATA #FIXED "http://www.w3.org/2001/XInclude"> -]> <book> <intro id="intro"> You will enjoy this book. |
From: Oleg T. <he...@us...> - 2004-10-30 09:56:38
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26849/v1/src Modified Files: XIncludingReader.cs Log Message: Updated Test Suite and added non-streaming mode tests. Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- XIncludingReader.cs 28 Oct 2004 18:39:23 -0000 1.19 +++ XIncludingReader.cs 30 Oct 2004 09:56:27 -0000 1.20 @@ -1457,9 +1457,24 @@ /// </summary> /// <param name="xpointer">Required XPointer pointer</param> private bool ProcessIntraDocXMLInclusion(string xpointer) - { - //TODO: So? - return false; + { + //Include current document as XML + CheckLoops(null, xpointer); + //No XML resolving for intra-doc references + //Push current reader to the stack + _readers.Push(_reader); + //For an intra-document reference (via xpointer attribute) + //the source infoset is used as the acquired infoset. + IHasXPathNavigator hxn = _reader as IHasXPathNavigator; + if (_reader != null) + { + XPathNavigator nav = hxn.GetNavigator(); + nav.MoveToRoot(); + _reader = new XPointerReader(nav, xpointer); + return Read(); + } + else + throw new InvalidOperationException("How on earth this could happen?"); } /// <summary> @@ -1471,7 +1486,7 @@ { //Include document as XML Uri includeLocation = ResolveHref(href); - CheckLoops(includeLocation); + CheckLoops(includeLocation, xpointer); if (includeLocation.Fragment != String.Empty) throw new FragmentIdentifierInHrefAttribute(); if (_xmlResolver == null) @@ -1500,8 +1515,7 @@ else _reader = CreateInMemoryReader(r); } - bool res = Read(); - return res; + return Read(); } else { @@ -1641,9 +1655,8 @@ /// <summary> /// Checks for inclusion loops. - /// </summary> - /// <param name="url"></param> - private void CheckLoops(Uri url) + /// </summary> + private void CheckLoops(Uri url, string xpointer) { //Check circular inclusion if (new Uri(_reader.BaseURI).Equals(url)) |
From: Oleg T. <he...@us...> - 2004-10-28 18:39:33
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21421/v1/src Modified Files: XIncludingReader.cs Log Message: Removed some artifact. Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- XIncludingReader.cs 28 Oct 2004 18:27:05 -0000 1.18 +++ XIncludingReader.cs 28 Oct 2004 18:39:23 -0000 1.19 @@ -1128,9 +1128,7 @@ httpReq.Accept += ","+accept; } if (acceptLanguage != null) - { - //TODO: WTF??? - httpReq.Headers.Add("Accept-Language", "ru"); + { if (httpReq.Headers["Accept-Language"] == null) httpReq.Headers.Add("Accept-Language", acceptLanguage); else |
From: Oleg T. <he...@us...> - 2004-10-28 18:27:18
|
Update of /cvsroot/mvp-xml/XInclude/v1/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17915/v1/test Modified Files: EntryPoint.cs XIncludeReaderTests.cs XIncludeSyntaxTests.cs XIncludeTest.csproj Log Message: Fixing bugs. Implemented non-streaming mode for text inclusion. Index: XIncludeTest.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeTest.csproj,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- XIncludeTest.csproj 28 Oct 2004 13:01:53 -0000 1.7 +++ XIncludeTest.csproj 28 Oct 2004 18:27:06 -0000 1.8 @@ -87,7 +87,7 @@ /> <Reference Name = "System.XML" - AssemblyName = "System.XML" + AssemblyName = "System.Xml" HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> </References> @@ -159,6 +159,10 @@ BuildAction = "Content" /> <File + RelPath = "results\includesitself-nohref-text.xml" + BuildAction = "Content" + /> + <File RelPath = "results\nonxmlchar.xml" BuildAction = "Content" /> @@ -215,6 +219,10 @@ BuildAction = "Content" /> <File + RelPath = "tests\includesitself-nohref-text.xml" + BuildAction = "Content" + /> + <File RelPath = "tests\nohref.xml" BuildAction = "Content" /> Index: EntryPoint.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/EntryPoint.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- EntryPoint.cs 28 Oct 2004 13:01:52 -0000 1.8 +++ EntryPoint.cs 28 Oct 2004 18:27:05 -0000 1.9 @@ -9,14 +9,15 @@ { public static void Main() { - //XIncludeReaderTests rt = new XIncludeReaderTests(); - LTG_Edinburgh_UnivTests rt = new LTG_Edinburgh_UnivTests(); + XIncludeReaderTests rt = new XIncludeReaderTests(); + //LTG_Edinburgh_UnivTests rt = new LTG_Edinburgh_UnivTests(); //NistTests rt = new NistTests(); //Elliotte_Rusty_HaroldTests rt = new Elliotte_Rusty_HaroldTests(); //FourThoughtTests rt = new FourThoughtTests(); + //XIncludeSyntaxTests rt = new XIncludeSyntaxTests(); try { - rt.eduni_2(); + rt.IncludesItselfNoHrefText_NonStreaming(); } catch (Exception e) { Index: XIncludeReaderTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeReaderTests.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- XIncludeReaderTests.cs 28 Oct 2004 13:01:52 -0000 1.9 +++ XIncludeReaderTests.cs 28 Oct 2004 18:27:06 -0000 1.10 @@ -22,24 +22,39 @@ Debug.Listeners.Add(new TextWriterTraceListener(Console.Error)); } + /// <summary> + /// Utility method for running tests. + /// </summary> + public static void RunAndCompare(string source, string result, bool textAsCDATA) + { + RunAndCompare(source, result, textAsCDATA, true); + } /// <summary> /// Utility method for running tests. /// </summary> public static void RunAndCompare(string source, string result) { - RunAndCompare(source, result, false); + RunAndCompare(source, result, false, true); + } + + /// <summary> + /// Utility method for running tests. + /// </summary> + public static void RunAndCompareNS(string source, string result) + { + RunAndCompare(source, result, false, false); } /// <summary> /// Utility method for running tests. /// </summary> - public static void RunAndCompare(string source, string result, bool textAsCDATA) + public static void RunAndCompare(string source, string result, bool textAsCDATA, bool streaming) { XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; - XIncludingReader xir = new XIncludingReader(source); - xir.ExposeTextInclusionsAsCDATA = textAsCDATA; + XIncludingReader xir = new XIncludingReader(source, streaming); + xir.ExposeTextInclusionsAsCDATA = textAsCDATA; try { doc.Load(xir); @@ -170,6 +185,15 @@ } /// <summary> + /// General test - it should work actually - non streaming. + /// </summary> + [Test] + public void ItWorksAtLeast_NonStreaming() + { + RunAndCompareNS("../../tests/document.xml", "../../results/document.xml"); + } + + /// <summary> /// Non XML character in the included document. /// </summary> [Test] @@ -180,6 +204,16 @@ } /// <summary> + /// Non XML character in the included document - non streaming. + /// </summary> + [Test] + [ExpectedException(typeof(NonXmlCharacterException))] + public void NonXMLChar_NonStreaming() + { + RunAndCompareNS("../../tests/nonxmlchar.xml", "../../results/nonxmlchar.xml"); + } + + /// <summary> /// File not found and no fallback. /// </summary> [Test] @@ -190,16 +224,52 @@ } /// <summary> - /// Circular inclusion. + /// File not found and no fallback - non streaming. /// </summary> [Test] - [ExpectedException(typeof(CircularInclusionException))] - public void IncludesItself() + [ExpectedException(typeof(FatalResourceException))] + public void FileNotFound_NonStreaming() + { + RunAndCompareNS("../../tests/filenotfound.xml", "../../results/filenotfound.xml"); + } + + /// <summary> + /// Includes itself by url. + /// </summary> + [Test] + public void IncludesItselfByUrl() { RunAndCompare("../../tests/includesitself.xml", "../../results/includesitself.xml"); } /// <summary> + /// Includes itself by url - non steraming. + /// </summary> + [Test] + public void IncludesItselfByUrl_NonStreaming() + { + RunAndCompareNS("../../tests/includesitself.xml", "../../results/includesitself.xml"); + } + + /// <summary> + /// Includes itself by url - no href - as text. + /// </summary> + [Test] + public void IncludesItselfNoHrefText() + { + RunAndCompare("../../tests/includesitself-nohref-text.xml", "../../results/includesitself-nohref-text.xml"); + } + + /// <summary> + /// Includes itself by url - no href - as text - non streaming. + /// </summary> + [Test] + public void IncludesItselfNoHrefText_NonStreaming() + { + RunAndCompareNS("../../tests/includesitself-nohref-text.xml", "../../results/includesitself-nohref-text.xml"); + } + + /// <summary> /// Text inclusion. /// </summary> [Test] @@ -209,6 +279,15 @@ } /// <summary> + /// Text inclusion - non streaming. + /// </summary> + [Test] + public void TextInclusion_NonStreaming() + { + RunAndCompareNS("../../tests/working_example.xml", "../../results/working_example.xml"); + } + + /// <summary> /// Text inclusion. /// </summary> [Test] @@ -218,6 +297,15 @@ } /// <summary> + /// Text inclusion - non streaming. + /// </summary> + [Test] + public void TextInclusion2_NonStreaming() + { + RunAndCompareNS("../../tests/working_example2.xml", "../../results/working_example2.xml"); + } + + /// <summary> /// Fallback. /// </summary> [Test] @@ -227,6 +315,16 @@ } /// <summary> + /// Fallback - non streaming. + /// </summary> + [Test] + public void Fallback_NonStreaming() + { + RunAndCompareNS("../../tests/fallback.xml", "../../results/fallback.xml"); + } + + + /// <summary> /// XPointer. /// </summary> [Test] @@ -236,6 +334,15 @@ } /// <summary> + /// XPointer - non streaming. + /// </summary> + [Test] + public void XPointer_NonStreaming() + { + RunAndCompareNS("../../tests/xpointer.xml", "../../results/xpointer.xml"); + } + + /// <summary> /// ReadOuterXml() test. /// </summary> [Test] @@ -255,6 +362,25 @@ } /// <summary> + /// ReadOuterXml() test - non streaming. + /// </summary> + [Test] + public void OuterXmlTest_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/document.xml", false); + xir.MoveToContent(); + string outerXml = xir.ReadOuterXml(); + xir.Close(); + xir = new XIncludingReader("../../tests/document.xml", false); + xir.MoveToContent(); + XmlDocument doc = new XmlDocument(); + doc.PreserveWhitespace = true; + doc.Load(xir); + string outerXml2 = doc.DocumentElement.OuterXml; + Assert.AreEqual(outerXml, outerXml2); + } + + /// <summary> /// ReadInnerXml() test. /// </summary> [Test] @@ -274,17 +400,58 @@ } /// <summary> + /// ReadInnerXml() test - non streaming. + /// </summary> + [Test] + public void InnerXmlTest_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/document.xml", false); + xir.MoveToContent(); + string innerXml = xir.ReadInnerXml(); + xir.Close(); + xir = new XIncludingReader("../../tests/document.xml", false); + xir.MoveToContent(); + XmlDocument doc = new XmlDocument(); + doc.PreserveWhitespace = true; + doc.Load(xir); + string innerXml2 = doc.DocumentElement.InnerXml; + Assert.AreEqual(innerXml, innerXml2); + } + + /// <summary> /// Depth test. /// </summary> [Test] public void DepthTest() { XIncludingReader xir = new XIncludingReader("../../tests/document.xml"); + StringBuilder sb = new StringBuilder(); + while (xir.Read()) + { + Console.WriteLine("{0} | {1} | {2} | {3}", + xir.NodeType, xir.Name, xir.Value, xir.Depth); + sb.Append(xir.Depth); + } + string expected = "00011211111111223221100"; + Assert.AreEqual(sb.ToString(), expected); + } + + /// <summary> + /// Depth test - non streaming. + /// </summary> + [Test] + public void DepthTest_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/document.xml", false); + StringBuilder sb = new StringBuilder(); while (xir.Read()) { Console.WriteLine("{0} | {1} | {2} | {3}", xir.NodeType, xir.Name, xir.Value, xir.Depth); + sb.Append(xir.Depth); } + string expected = "00011211111111223221100"; + Assert.AreEqual(sb.ToString(), expected); } // /// <summary> Index: XIncludeSyntaxTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeSyntaxTests.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XIncludeSyntaxTests.cs 16 Oct 2004 21:01:37 -0000 1.2 +++ XIncludeSyntaxTests.cs 28 Oct 2004 18:27:06 -0000 1.3 @@ -31,6 +31,18 @@ } /// <summary> + /// No href and no xpointer attribute - non streaming. + /// </summary> + [Test] + [ExpectedException(typeof(MissingHrefAndXpointerException))] + public void NoHrefAndNoXPointerAttributes_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/nohref.xml", false); + while (xir.Read()); + xir.Close(); + } + + /// <summary> /// xi:include child of xi:include. /// </summary> [Test] @@ -40,7 +52,19 @@ XIncludingReader xir = new XIncludingReader("../../tests/includechildofinclude.xml"); while (xir.Read()); xir.Close(); - } + } + + /// <summary> + /// xi:include child of xi:include - non streaming. + /// </summary> + [Test] + [ExpectedException(typeof(XIncludeSyntaxError))] + public void IncludeChildOfInclude_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/includechildofinclude.xml", false); + while (xir.Read()); + xir.Close(); + } /// <summary> /// xi:fallback not child of xi:include. @@ -55,6 +79,18 @@ } /// <summary> + /// xi:fallback not child of xi:include - non streaming. + /// </summary> + [Test] + [ExpectedException(typeof(XIncludeSyntaxError))] + public void FallbackNotChildOfInclude_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/fallbacknotchildinclude.xml", false); + while (xir.Read()); + xir.Close(); + } + + /// <summary> /// Unknown value of parse attribute. /// </summary> [Test] @@ -67,6 +103,18 @@ } /// <summary> + /// Unknown value of parse attribute - non streaming. + /// </summary> + [Test] + [ExpectedException(typeof(UnknownParseAttributeValueException))] + public void UnknownParseAttribute_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/unknownparseattr.xml", false); + while (xir.Read()); + xir.Close(); + } + + /// <summary> /// Two xi:fallback. /// </summary> [Test] @@ -77,5 +125,18 @@ while (xir.Read()); xir.Close(); } + + /// <summary> + /// Two xi:fallback - non streaming. + /// </summary> + [Test] + [ExpectedException(typeof(XIncludeSyntaxError))] + public void TwoFallbacks_NonStreaming() + { + XIncludingReader xir = new XIncludingReader("../../tests/twofallbacks.xml", false); + while (xir.Read()); + xir.Close(); + } + } } |
From: Oleg T. <he...@us...> - 2004-10-28 18:27:17
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/results In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17915/v1/test/results Modified Files: includesitself.xml Added Files: includesitself-nohref-text.xml Log Message: Fixing bugs. Implemented non-streaming mode for text inclusion. --- NEW FILE: includesitself-nohref-text.xml --- (This appears to be a binary file; contents omitted.) Index: includesitself.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/results/includesitself.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- includesitself.xml 17 Oct 2004 21:01:14 -0000 1.1 +++ includesitself.xml 28 Oct 2004 18:27:06 -0000 1.2 @@ -1,6 +1,12 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="utf-8"?> <document xmlns:xi="http://www.w3.org/2003/XInclude"> <p>120 Mz is adequate for an average home user.</p> - <foo></foo> + <?xml version="1.0"?> +<document xmlns:xi="http://www.w3.org/2003/XInclude"> + <p>120 Mz is adequate for an average home user.</p> + <xi:include href="includesitself.xml" parse="text"><foo></foo></xi:include> foo -</document> +</document> + +foo +</document> \ No newline at end of file |
From: Oleg T. <he...@us...> - 2004-10-28 18:27:16
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17915/v1/test/tests Added Files: includesitself-nohref-text.xml Log Message: Fixing bugs. Implemented non-streaming mode for text inclusion. --- NEW FILE: includesitself-nohref-text.xml --- (This appears to be a binary file; contents omitted.) |
From: Oleg T. <he...@us...> - 2004-10-28 18:27:16
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17915/v1/src Modified Files: SR.resx TextIncludingReader.cs XInclude.csproj XIncludingReader.cs Log Message: Fixing bugs. Implemented non-streaming mode for text inclusion. Index: XInclude.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XInclude.csproj,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- XInclude.csproj 28 Oct 2004 13:01:51 -0000 1.7 +++ XInclude.csproj 28 Oct 2004 18:27:05 -0000 1.8 @@ -211,6 +211,12 @@ BuildAction = "Compile" /> <File + RelPath = "Common\XPath\IHasXPathNavigator.cs" + Link = "..\..\..\Common\v1\src\XPath\IHasXPathNavigator.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Common\XPath\IndexingXPathNavigator.cs" Link = "..\..\..\Common\v1\src\XPath\IndexingXPathNavigator.cs" SubType = "Code" Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- XIncludingReader.cs 28 Oct 2004 13:01:51 -0000 1.17 +++ XIncludingReader.cs 28 Oct 2004 18:27:05 -0000 1.18 @@ -3,6 +3,7 @@ using System; using System.Xml; using System.Xml.Schema; +using System.Xml.XPath; using System.IO; using System.Net; using System.Text; @@ -10,6 +11,7 @@ using System.Collections; using Mvp.Xml.Common; +using Mvp.Xml.Common.XPath; using Mvp.Xml.XPointer; #endregion @@ -68,7 +70,9 @@ //XmlResolver to resolve URIs XmlResolver _xmlResolver; //Expose text inclusions as CDATA - private bool _exposeTextAsCDATA; + private bool _exposeTextAsCDATA; + //Work in streaming mode (no support for intra-document references) + private bool _streamingMode = true; #endregion #region Constructors @@ -76,9 +80,12 @@ /// Creates new instance of <c>XIncludingReader</c> class with /// specified underlying <c>XmlReader</c> reader. /// </summary> - /// <param name="reader">Underlying reader to read from.</param> - public XIncludingReader(XmlReader reader) + /// <param name="reader">Underlying reader to read from</param> + /// <param name="streamingMode">Work in streaming mode</param> + /// <remarks>Note: intra-document references are not supported in streaming mode.</remarks> + public XIncludingReader(XmlReader reader, bool streamingMode) { + _streamingMode = streamingMode; XmlTextReader xtr = reader as XmlTextReader; if (xtr != null) { @@ -89,10 +96,26 @@ ValidationCallback); _normalization = xtr.Normalization; _whiteSpaceHandling = xtr.WhitespaceHandling; - _reader = vr; + + if (_streamingMode) + _reader = vr; + else + { + //In-memory mode + _reader = CreateInMemoryReader(vr); + } } - else - _reader = reader; + else + { + if (_streamingMode) + _reader = reader; + else + { + //In-memory mode + _reader = CreateInMemoryReader(reader); + } + } + _nameTable = reader.NameTable; Init(); } @@ -102,8 +125,125 @@ /// specified URL. /// </summary> /// <param name="url">Document location.</param> + /// <param name="streamingMode">Work in streaming mode</param> + /// <remarks>Note: intra-document references are not supported in streaming mode.</remarks> + public XIncludingReader(string url, bool streamingMode) + : this(new XmlBaseAwareXmlTextReader(url), streamingMode) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified URL and nametable. + /// </summary> + /// <param name="url">Document location.</param> + /// <param name="nt">Name table.</param> + /// <param name="streamingMode">Work in streaming mode</param> + /// <remarks>Note: intra-document references are not supported in streaming mode.</remarks> + public XIncludingReader(string url, XmlNameTable nt, bool streamingMode) : + this(new XmlBaseAwareXmlTextReader(url, nt), streamingMode) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified <c>TextReader</c> reader. + /// </summary> + /// <param name="reader"><c>TextReader</c>.</param> + /// <param name="streamingMode">Work in streaming mode</param> + /// <remarks>Note: intra-document references are not supported in streaming mode.</remarks> + public XIncludingReader(TextReader reader, bool streamingMode) + : this(new XmlBaseAwareXmlTextReader(reader), streamingMode) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified URL and <c>TextReader</c> reader. + /// </summary> + /// <param name="reader"><c>TextReader</c>.</param> + /// <param name="url">Source document's URL</param> + /// <param name="streamingMode">Work in streaming mode</param> + /// <remarks>Note: intra-document references are not supported in streaming mode.</remarks> + public XIncludingReader(string url, TextReader reader, bool streamingMode) + : this(new XmlBaseAwareXmlTextReader(url, reader), streamingMode) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified <c>TextReader</c> reader and nametable. + /// </summary> + /// <param name="reader"><c>TextReader</c>.</param> + /// <param name="nt">Nametable.</param> + /// <param name="streamingMode">Work in streaming mode</param> + /// <remarks>Note: intra-document references are not supported in streaming mode.</remarks> + public XIncludingReader(TextReader reader, XmlNameTable nt, bool streamingMode) : + this(new XmlBaseAwareXmlTextReader(reader, nt), streamingMode) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified URL, <c>TextReader</c> reader and nametable. + /// </summary> + /// <param name="reader"><c>TextReader</c>.</param> + /// <param name="nt">Nametable.</param> + /// <param name="url">Source document's URI</param> + /// <param name="streamingMode">Work in streaming mode</param> + /// <remarks>Note: intra-document references are not supported in streaming mode.</remarks> + public XIncludingReader(string url, TextReader reader, XmlNameTable nt, bool streamingMode) : + this(new XmlBaseAwareXmlTextReader(url, reader, nt), streamingMode) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified <c>Stream</c>. + /// </summary> + /// <param name="input"><c>Stream</c>.</param> + /// <param name="streamingMode">Work in streaming mode</param> + /// <remarks>Note: intra-document references are not supported in streaming mode.</remarks> + public XIncludingReader(Stream input, bool streamingMode) + : this(new XmlBaseAwareXmlTextReader(input), streamingMode) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified URL and <c>Stream</c>. + /// </summary> + /// <param name="input"><c>Stream</c>.</param> + /// <param name="url">Source document's URL</param> + /// <param name="streamingMode">Work in streaming mode</param> + /// <remarks>Note: intra-document references are not supported in streaming mode.</remarks> + public XIncludingReader(string url, Stream input, bool streamingMode) + : this(new XmlBaseAwareXmlTextReader(url, input), streamingMode) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified <c>Stream</c> and nametable. + /// </summary> + /// <param name="input"><c>Stream</c>.</param> + /// <param name="nt">Nametable</param> + /// <param name="streamingMode">Work in streaming mode</param> + /// <remarks>Note: intra-document references are not supported in streaming mode.</remarks> + public XIncludingReader(Stream input, XmlNameTable nt, bool streamingMode) : + this(new XmlBaseAwareXmlTextReader(input, nt), streamingMode) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified URL, <c>Stream</c> and nametable. + /// </summary> + /// <param name="input"><c>Stream</c>.</param> + /// <param name="nt">Nametable</param> + /// <param name="url">Source document's URL</param> + /// <param name="streamingMode">Work in streaming mode</param> + /// <remarks>Note: intra-document references are not supported in streaming mode.</remarks> + public XIncludingReader(string url, Stream input, XmlNameTable nt, bool streamingMode) : + this(new XmlBaseAwareXmlTextReader(url, input, nt), streamingMode) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified underlying <c>XmlReader</c> reader. + /// </summary> + /// <param name="reader">Underlying reader to read from.</param> + public XIncludingReader(XmlReader reader) + : this(reader, true) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified URL. + /// </summary> + /// <param name="url">Document location.</param> public XIncludingReader(string url) - : this(new XmlBaseAwareXmlTextReader(url)) {} + : this(new XmlBaseAwareXmlTextReader(url), true) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -112,7 +252,7 @@ /// <param name="url">Document location.</param> /// <param name="nt">Name table.</param> public XIncludingReader(string url, XmlNameTable nt) : - this(new XmlBaseAwareXmlTextReader(url, nt)) {} + this(new XmlBaseAwareXmlTextReader(url, nt), true) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -120,7 +260,7 @@ /// </summary> /// <param name="reader"><c>TextReader</c>.</param> public XIncludingReader(TextReader reader) - : this(new XmlBaseAwareXmlTextReader(reader)) {} + : this(new XmlBaseAwareXmlTextReader(reader), true) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -129,7 +269,7 @@ /// <param name="reader"><c>TextReader</c>.</param> /// <param name="url">Source document's URL</param> public XIncludingReader(string url, TextReader reader) - : this(new XmlBaseAwareXmlTextReader(url, reader)) {} + : this(new XmlBaseAwareXmlTextReader(url, reader), true) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -138,7 +278,7 @@ /// <param name="reader"><c>TextReader</c>.</param> /// <param name="nt">Nametable.</param> public XIncludingReader(TextReader reader, XmlNameTable nt) : - this(new XmlBaseAwareXmlTextReader(reader, nt)) {} + this(new XmlBaseAwareXmlTextReader(reader, nt), true) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -148,7 +288,7 @@ /// <param name="nt">Nametable.</param> /// <param name="url">Source document's URI</param> public XIncludingReader(string url, TextReader reader, XmlNameTable nt) : - this(new XmlBaseAwareXmlTextReader(url, reader, nt)) {} + this(new XmlBaseAwareXmlTextReader(url, reader, nt), true) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -156,7 +296,7 @@ /// </summary> /// <param name="input"><c>Stream</c>.</param> public XIncludingReader(Stream input) - : this(new XmlBaseAwareXmlTextReader(input)) {} + : this(new XmlBaseAwareXmlTextReader(input), true) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -165,7 +305,7 @@ /// <param name="input"><c>Stream</c>.</param> /// <param name="url">Source document's URL</param> public XIncludingReader(string url, Stream input) - : this(new XmlBaseAwareXmlTextReader(url, input)) {} + : this(new XmlBaseAwareXmlTextReader(url, input), true) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -174,7 +314,7 @@ /// <param name="input"><c>Stream</c>.</param> /// <param name="nt">Nametable</param> public XIncludingReader(Stream input, XmlNameTable nt) : - this(new XmlBaseAwareXmlTextReader(input, nt)) {} + this(new XmlBaseAwareXmlTextReader(input, nt), true) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -184,7 +324,7 @@ /// <param name="nt">Nametable</param> /// <param name="url">Source document's URL</param> public XIncludingReader(string url, Stream input, XmlNameTable nt) : - this(new XmlBaseAwareXmlTextReader(url, input, nt)) {} + this(new XmlBaseAwareXmlTextReader(url, input, nt), true) {} #endregion @@ -845,12 +985,19 @@ #endregion #region Public members + + /// <summary> + /// See <see cref="XmlTextReader.Normalization"/>. + /// </summary> public bool Normalization { get { return _normalization; } set { _normalization = value; } } + /// <summary> + /// See <see cref="XmlTextReader.WhitespaceHandling"/>. + /// </summary> public WhitespaceHandling WhitespaceHandling { get { return _whiteSpaceHandling; } @@ -885,6 +1032,14 @@ set { _exposeTextAsCDATA = value; } } + /// <summary> + /// Streaming or in-memory mode (streaming by default). + /// </summary> + public bool StreamingMode + { + get { return _streamingMode; } + } + #endregion @@ -1000,132 +1155,62 @@ { string href = _reader.GetAttribute(_keywords.Href); string xpointer = _reader.GetAttribute(_keywords.Xpointer); + string parse = _reader.GetAttribute(_keywords.Parse); + if (href == null || href == String.Empty) { - if (xpointer == null) - { - //Both href and xpointer attributes are absent, critical error - IXmlLineInfo li = _reader as IXmlLineInfo; - if (li != null && li.HasLineInfo()) - { - throw new MissingHrefAndXpointerException( - SR.GetString("MissingHrefAndXpointerExceptionLong", - _reader.BaseURI.ToString(), - li.LineNumber, li.LinePosition)); - } - else - throw new MissingHrefAndXpointerException( - SR.GetString("MissingHrefAndXpointerException", - _reader.BaseURI.ToString())); - } - else + //Intra-document inclusion + if (parse == null || parse.Equals(_keywords.Xml)) { - //No href - intra-document reference - throw new NotImplementedException(SR.IntradocumentReferencesNotSupported); - } - } - string parse = _reader.GetAttribute(_keywords.Parse); - if (parse == null || parse.Equals(_keywords.Xml)) - { - //Include document as XML - Uri includeLocation = ResolveHref(href); - if (includeLocation.Fragment != String.Empty) - throw new FragmentIdentifierInHrefAttribute(); - if (_xmlResolver == null) - { - //No custom resolver - WebResponse wRes; - Stream stream = GetResource(href, includeLocation, - _reader.GetAttribute(_keywords.Accept), - _reader.GetAttribute(_keywords.AcceptLanguage), out wRes); - //Push current reader to the stack - _readers.Push(_reader); - if (xpointer != null) + if (xpointer == null) { - //Well, XPointers should be resolved against the acquired infoset, - //not the source infoset - //TODO: Try to stream this stuff - string uri = wRes.ResponseUri.AbsoluteUri; - XIncludingReader xir = new XIncludingReader(uri, stream, _nameTable); - StringWriter sw = new StringWriter(); - XmlTextWriter w = new XmlTextWriter(sw); - while (xir.Read()) - w.WriteNode(xir, false); - xir.Close(); - w.Close(); - _reader = new XPointerReader(new XmlTextReader( - uri, new StringReader(sw.ToString())), xpointer); + //Both href and xpointer attributes are absent in xml mode, + // => critical error + IXmlLineInfo li = _reader as IXmlLineInfo; + if (li != null && li.HasLineInfo()) + { + throw new MissingHrefAndXpointerException( + SR.GetString("MissingHrefAndXpointerExceptionLong", + _reader.BaseURI.ToString(), + li.LineNumber, li.LinePosition)); + } + else + throw new MissingHrefAndXpointerException( + SR.GetString("MissingHrefAndXpointerException", + _reader.BaseURI.ToString())); } - else - { - _reader = new XmlBaseAwareXmlTextReader(wRes.ResponseUri.AbsoluteUri, stream, _nameTable); - ((XmlTextReader)_reader).Normalization = _normalization; - ((XmlTextReader)_reader).WhitespaceHandling = _whiteSpaceHandling; - } - bool res = Read(); - return res; - } - else + //No support for intra-document refs in streaming mode + if (_streamingMode) + throw new InvalidOperationException(SR.IntradocumentReferencesNotSupported); + return ProcessIntraDocXMLInclusion(xpointer); + } + else if (parse.Equals(_keywords.Text)) { - //Custom resolver provided, let's ask him - object resource; - try - { - resource = _xmlResolver.GetEntity(includeLocation, null, null); - } - catch (Exception e) - { - throw new ResourceException(SR.CustomXmlResolverError, e); - } - if (resource == null) - throw new ResourceException(SR.CustomXmlResolverReturnedNull); - //Ok, we accept Stream and XmlReader only - XmlReader r; - if (resource is Stream) - r = new XmlBaseAwareXmlTextReader(includeLocation.AbsoluteUri, (Stream)resource, _nameTable); - else if (resource is XmlReader) - r = (XmlReader)resource; - else - //Unsupported type - throw new ResourceException(SR.GetString( - "CustomXmlResolverReturnedUnsupportedType", - resource.GetType().ToString())); - //Push current reader to the stack - _readers.Push(_reader); - if (xpointer != null) - _reader = new XPointerReader(r, xpointer); - else - _reader = r; - bool res = Read(); - return res; + //No support for intra-document refs in streaming mode + if (_streamingMode) + throw new InvalidOperationException(SR.IntradocumentReferencesNotSupported); + return ProcessIntraDocTextInclusion(); } - } - else if (parse.Equals(_keywords.Text)) - { - //Include document as text - string encoding = GetAttribute(_keywords.Encoding); - Uri includeLocation = ResolveHref(href); - //Push current reader to the stack - _readers.Push(_reader); - _reader = new TextIncludingReader(includeLocation, encoding, - _reader.GetAttribute(_keywords.Accept), - _reader.GetAttribute(_keywords.AcceptLanguage), - _exposeTextAsCDATA); - return Read(); - } + } else { - //Unknown "parse" attribute value, critical error - IXmlLineInfo li = _reader as IXmlLineInfo; - if (li != null && li.HasLineInfo()) - { - throw new UnknownParseAttributeValueException(parse, - _reader.BaseURI.ToString(), - li.LineNumber, li.LinePosition); - } - else - throw new UnknownParseAttributeValueException(parse); - } + //Inter-document inclusion + if (parse == null || parse.Equals(_keywords.Xml)) + return ProcessInterDocXMLInclusion(href, xpointer); + else if (parse.Equals(_keywords.Text)) + return ProcessInterDocTextInclusion(href); + } + + //Unknown "parse" attribute value, critical error + IXmlLineInfo li2 = _reader as IXmlLineInfo; + if (li2 != null && li2.HasLineInfo()) + { + throw new UnknownParseAttributeValueException(parse, + _reader.BaseURI.ToString(), + li2.LineNumber, li2.LinePosition); + } + else + throw new UnknownParseAttributeValueException(parse); } /// <summary> @@ -1150,15 +1235,7 @@ catch (Exception e) { throw new ResourceException(SR.GetString("UnresolvableURI", href), e); - } - //Check circular inclusion - if (new Uri(_reader.BaseURI).Equals(includeLocation)) - ThrowCircularInclusionError(_reader, includeLocation); - foreach (XmlReader r in _readers) - { - if (new Uri(r.BaseURI).Equals(includeLocation)) - ThrowCircularInclusionError(_reader, includeLocation); - } + } return includeLocation; } @@ -1341,7 +1418,245 @@ return lang1 == lang2; } - #endregion - + /// <summary> + /// Creates a XmlReader over acquired infoset. + /// </summary> + /// <param name="uri">Resource URI</param> + /// <param name="stream">Stream to load from</param> + private XmlReader CreateAcquiredInfoset(string uri, Stream stream) + { + //TODO: Try to stream out this stuff + XIncludingReader xir = new XIncludingReader(uri, stream, _nameTable); + StringWriter sw = new StringWriter(); + XmlTextWriter w = new XmlTextWriter(sw); + while (xir.Read()) + w.WriteNode(xir, false); + xir.Close(); + w.Close(); + return new XmlTextReader(uri, new StringReader(sw.ToString())); + } + + /// <summary> + /// Creates a XmlReader over acquired infoset. + /// </summary> + /// <param name="reader">Source reader</param> + private XmlReader CreateAcquiredInfoset(XmlReader reader) + { + string uri = reader.BaseURI; + //TODO: Try to stream out this stuff + XIncludingReader xir = new XIncludingReader(reader); + StringWriter sw = new StringWriter(); + XmlTextWriter w = new XmlTextWriter(sw); + while (xir.Read()) + w.WriteNode(xir, false); + xir.Close(); + w.Close(); + return new XmlTextReader(uri, new StringReader(sw.ToString())); + } + + /// <summary> + /// Processes intra-document inclusion (no href attribute). + /// </summary> + /// <param name="xpointer">Required XPointer pointer</param> + private bool ProcessIntraDocXMLInclusion(string xpointer) + { + //TODO: So? + return false; + } + + /// <summary> + /// Processes inter-document inclusion (xml mode). + /// </summary> + /// <param name="href">'href' attr value</param> + /// <param name="xpointer">'xpointer attr value'</param> + private bool ProcessInterDocXMLInclusion(string href, string xpointer) + { + //Include document as XML + Uri includeLocation = ResolveHref(href); + CheckLoops(includeLocation); + if (includeLocation.Fragment != String.Empty) + throw new FragmentIdentifierInHrefAttribute(); + if (_xmlResolver == null) + { + //No custom resolver + WebResponse wRes; + Stream stream = GetResource(href, includeLocation, + _reader.GetAttribute(_keywords.Accept), + _reader.GetAttribute(_keywords.AcceptLanguage), out wRes); + //Push current reader to the stack + _readers.Push(_reader); + if (xpointer != null) + { + //XPointers should be resolved against the acquired infoset, + //not the source infoset + _reader = new XPointerReader( + CreateAcquiredInfoset(wRes.ResponseUri.AbsoluteUri, stream), xpointer); + } + else + { + XmlTextReader r = new XmlBaseAwareXmlTextReader(wRes.ResponseUri.AbsoluteUri, stream, _nameTable); + r.Normalization = _normalization; + r.WhitespaceHandling = _whiteSpaceHandling; + if (_streamingMode) + _reader = r; + else + _reader = CreateInMemoryReader(r); + } + bool res = Read(); + return res; + } + else + { + //Custom resolver provided, let's ask him + object resource; + try + { + resource = _xmlResolver.GetEntity(includeLocation, null, null); + } + catch (Exception e) + { + throw new ResourceException(SR.CustomXmlResolverError, e); + } + if (resource == null) + throw new ResourceException(SR.CustomXmlResolverReturnedNull); + + //Push current reader to the stack + _readers.Push(_reader); + + //Ok, we accept Stream and XmlReader only + if (xpointer != null) + { + if (resource is Stream) + { + //XPointers should be resolved against the acquired infoset, + //not the source infoset + _reader = new XPointerReader( + CreateAcquiredInfoset(includeLocation.AbsoluteUri, (Stream)resource), + xpointer); + } + else if (resource is XmlReader) + { + _reader = new XPointerReader( + CreateAcquiredInfoset((XmlReader)resource), xpointer); + } + else + { + //Unsupported type + throw new ResourceException(SR.GetString( + "CustomXmlResolverReturnedUnsupportedType", + resource.GetType().ToString())); + } + } + else + { + //No XPointer + if (resource is Stream) + { + XmlTextReader r = new XmlBaseAwareXmlTextReader(includeLocation.AbsoluteUri, (Stream)resource, _nameTable); + if (_streamingMode) + _reader = r; + else + _reader = CreateInMemoryReader(r); + } + else if (resource is XmlReader) + { + if (_streamingMode) + _reader = (XmlReader)resource; + else + _reader = CreateInMemoryReader((XmlReader)resource); + } + else + { + //Unsupported type + throw new ResourceException(SR.GetString( + "CustomXmlResolverReturnedUnsupportedType", + resource.GetType().ToString())); + } + } + + return Read(); + } + } + + /// <summary> + /// Process inter-document inclusion as text. + /// </summary> + /// <param name="href">'href' attr value</param> + private bool ProcessInterDocTextInclusion(string href) + { + //Include document as text + string encoding = GetAttribute(_keywords.Encoding); + Uri includeLocation = ResolveHref(href); + //No need to check loops when including as text + //Push current reader to the stack + _readers.Push(_reader); + _reader = new TextIncludingReader(includeLocation, encoding, + _reader.GetAttribute(_keywords.Accept), + _reader.GetAttribute(_keywords.AcceptLanguage), + _exposeTextAsCDATA); + return Read(); + } + + /// <summary> + /// Process intra-document inclusion as text. + /// </summary> + private bool ProcessIntraDocTextInclusion() + { + //Ok, in non-streaming mode _reader must implement IHasXPathNavigator + if (_reader is IHasXPathNavigator) + { + XPathNavigator nav = ((IHasXPathNavigator)_reader).GetNavigator(); + nav.MoveToRoot(); + XPathNavigatorReader r= new XPathNavigatorReader(nav); + r.Read(); + //Push current reader to the stack + _readers.Push(_reader); + _reader = new TextIncludingReader(r.ReadOuterXml(), _exposeTextAsCDATA); + r.Close(); + return Read(); + } + else + throw new InvalidOperationException("How this could happen?"); + } + + /// <summary> + /// Creates XmlReader for non-streaming mode. + /// </summary> + /// <param name="reader">Source reader</param> + private XmlReader CreateInMemoryReader(XmlReader reader) + { + XmlReader r = null; + if (reader is XmlTextReader) + { + XmlValidatingReader vr = new XmlValidatingReader(reader); + vr.ValidationType = ValidationType.None; + vr.EntityHandling = EntityHandling.ExpandEntities; + vr.ValidationEventHandler += new ValidationEventHandler( + ValidationCallback); + r = vr; + } + else + r = reader; + XPathDocument doc = new XPathDocument(r, XmlSpace.Preserve); + return new XPathNavigatorReader(doc.CreateNavigator()); + } + + /// <summary> + /// Checks for inclusion loops. + /// </summary> + /// <param name="url"></param> + private void CheckLoops(Uri url) + { + //Check circular inclusion + if (new Uri(_reader.BaseURI).Equals(url)) + ThrowCircularInclusionError(_reader, url); + foreach (XmlReader r in _readers) + { + if (new Uri(r.BaseURI).Equals(url)) + ThrowCircularInclusionError(_reader, url); + } + } + + #endregion } } Index: SR.resx =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/SR.resx,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- SR.resx 26 Oct 2004 19:28:41 -0000 1.4 +++ SR.resx 28 Oct 2004 18:27:05 -0000 1.5 @@ -91,7 +91,7 @@ <value>'href' or 'xpointer' attributes can't both be omitted on xi:include element. Location: {0}, Line {1}, Position {2}.</value> </data> <data name="IntradocumentReferencesNotSupported" type="System.String" mimetype="System.String"> - <value>Intra-document references are not supported yet.</value> + <value>Intra-document references are not supported in the streaming mode.</value> </data> <data name="CustomXmlResolverError" type="System.String" mimetype="System.String"> <value>An exception has occured during GetEntity call to custom XmlResolver.</value> Index: TextIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/TextIncludingReader.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- TextIncludingReader.cs 26 Oct 2004 19:28:41 -0000 1.5 +++ TextIncludingReader.cs 28 Oct 2004 18:27:05 -0000 1.6 @@ -45,6 +45,13 @@ _exposeCDATA = exposeCDATA; } + public TextIncludingReader(string value, bool exposeCDATA) + { + _state = ReadState.Initial; + _exposeCDATA = exposeCDATA; + _value = value; + } + #endregion #region XmlReader overrides @@ -197,57 +204,72 @@ public override void ResolveEntity() {} public override bool Read() { - switch (_state) { + switch (_state) { case ReadState.Initial: - WebResponse wRes; - Stream stream = XIncludingReader.GetResource(_includeLocation.AbsoluteUri, - _includeLocation, _accept, _acceptLanguage, out wRes); - StreamReader reader; - /* According to the spec, encoding should be determined as follows: - * external encoding information, if available, otherwise - * if the media type of the resource is text/xml, application/xml, - or matches the conventions text/*+xml or application/*+xml as - described in XML Media Types [IETF RFC 3023], the encoding is - recognized as specified in XML 1.0, otherwise - * the value of the encoding attribute if one exists, otherwise - * UTF-8. - */ - try { - //TODO: try to get "content-encoding" from wRes.Headers collection? - //If mime type is xml-aware, get resource encoding as per XML 1.0 - string contentType = wRes.ContentType.ToLower(); - if (contentType == "text/xml" || - contentType == "application/xml" || - contentType.StartsWith("text/") && contentType.EndsWith("+xml") || - contentType.StartsWith("application/") && contentType.EndsWith("+xml")) { - //Yes, that's xml, let's read encoding from the xml declaration - reader = new StreamReader(stream, GetEncodingFromXMLDecl(_href)); - } else if (_encoding != null) { - //Try to use user-specified encoding - Encoding enc; - try { - enc = Encoding.GetEncoding(_encoding); - } - catch (Exception e) { - throw new ResourceException(SR.GetString("NotSupportedEncoding", - _encoding), e); - } - reader = new StreamReader(stream, enc); - } - else - //Fallback to UTF-8 - reader = new StreamReader(stream, Encoding.UTF8); - _value = reader.ReadToEnd(); - TextUtils.CheckForNonXmlChars(_value); - } catch (ResourceException re) { - throw re; - } catch (OutOfMemoryException oome) { - //Crazy include - memory is out - //TODO: what about reading by chunks? - throw new ResourceException(SR.GetString("OutOfMemoryWhileFetchingResource", _href), oome); - } catch (IOException ioe) { - throw new ResourceException(SR.GetString("IOErrorWhileFetchingResource", _href), ioe); - } + if (_value == null) + { + WebResponse wRes; + Stream stream = XIncludingReader.GetResource(_includeLocation.AbsoluteUri, + _includeLocation, _accept, _acceptLanguage, out wRes); + StreamReader reader; + /* According to the spec, encoding should be determined as follows: + * external encoding information, if available, otherwise + * if the media type of the resource is text/xml, application/xml, + or matches the conventions text/*+xml or application/*+xml as + described in XML Media Types [IETF RFC 3023], the encoding is + recognized as specified in XML 1.0, otherwise + * the value of the encoding attribute if one exists, otherwise + * UTF-8. + */ + try + { + //TODO: try to get "content-encoding" from wRes.Headers collection? + //If mime type is xml-aware, get resource encoding as per XML 1.0 + string contentType = wRes.ContentType.ToLower(); + if (contentType == "text/xml" || + contentType == "application/xml" || + contentType.StartsWith("text/") && contentType.EndsWith("+xml") || + contentType.StartsWith("application/") && contentType.EndsWith("+xml")) + { + //Yes, that's xml, let's read encoding from the xml declaration + reader = new StreamReader(stream, GetEncodingFromXMLDecl(_href)); + } + else if (_encoding != null) + { + //Try to use user-specified encoding + Encoding enc; + try + { + enc = Encoding.GetEncoding(_encoding); + } + catch (Exception e) + { + throw new ResourceException(SR.GetString("NotSupportedEncoding", + _encoding), e); + } + reader = new StreamReader(stream, enc); + } + else + //Fallback to UTF-8 + reader = new StreamReader(stream, Encoding.UTF8); + _value = reader.ReadToEnd(); + TextUtils.CheckForNonXmlChars(_value); + } + catch (ResourceException re) + { + throw re; + } + catch (OutOfMemoryException oome) + { + //Crazy include - memory is out + //TODO: what about reading by chunks? + throw new ResourceException(SR.GetString("OutOfMemoryWhileFetchingResource", _href), oome); + } + catch (IOException ioe) + { + throw new ResourceException(SR.GetString("IOErrorWhileFetchingResource", _href), ioe); + } + } _state = ReadState.Interactive; return true; case ReadState.Interactive: |
From: Oleg T. <he...@us...> - 2004-10-28 18:21:34
|
Update of /cvsroot/mvp-xml/XPointer/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16475/v1/src Modified Files: XPointer.csproj XPointerReader.cs Log Message: XPointerReader implements IHasXPathNavigator. Index: XPointer.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/XPointer.csproj,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- XPointer.csproj 28 Oct 2004 12:55:01 -0000 1.5 +++ XPointer.csproj 28 Oct 2004 18:21:23 -0000 1.6 @@ -76,7 +76,7 @@ /> <Reference Name = "System.XML" - AssemblyName = "System.XML" + AssemblyName = "System.Xml" HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> </References> @@ -248,6 +248,12 @@ BuildAction = "Compile" /> <File + RelPath = "Common\XPath\IHasXPathNavigator.cs" + Link = "..\..\..\Common\v1\src\XPath\IHasXPathNavigator.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Common\XPath\IndexingXPathNavigator.cs" Link = "..\..\..\Common\v1\src\XPath\IndexingXPathNavigator.cs" SubType = "Code" Index: XPointerReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/XPointerReader.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- XPointerReader.cs 28 Oct 2004 12:55:01 -0000 1.5 +++ XPointerReader.cs 28 Oct 2004 18:21:23 -0000 1.6 @@ -17,7 +17,7 @@ /// XPointer-aware XmlReader. /// </summary> /// <author>Oleg Tkachenko, ol...@tk...</author> - public class XPointerReader : XmlReader + public class XPointerReader : XmlReader, IHasXPathNavigator { #region private members @@ -323,5 +323,18 @@ } #endregion + + #region IHasXPathNavigator Members + + /// <summary> + /// Returns the XPathNavigator for the current context or position. + /// </summary> + /// <returns></returns> + public XPathNavigator GetNavigator() + { + return _pointedNodes.Current.Clone(); + } + + #endregion } } |
From: Oleg T. <he...@us...> - 2004-10-28 18:20:33
|
Update of /cvsroot/mvp-xml/Common/v1/src/XPath In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16245/v1/src/XPath Modified Files: XPathNavigatorReader.cs Added Files: IHasXPathNavigator.cs Log Message: Added IHasXPathNavigator interface and its impl for XPathNavigatorReader to be able to extract underlying XPathNavigator out of XPathNavigatorReader. --- NEW FILE: IHasXPathNavigator.cs --- #region usage using System.Xml.XPath; #endregion namespace Mvp.Xml.Common.XPath { /// <summary> /// Enables a class to return an XPathNavigator from the current context or position. /// </summary> interface IHasXPathNavigator { /// <summary> /// Returns the XPathNavigator for the current context or position. /// </summary> XPathNavigator GetNavigator(); } } Index: XPathNavigatorReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v1/src/XPath/XPathNavigatorReader.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XPathNavigatorReader.cs 19 Oct 2004 07:15:11 -0000 1.2 +++ XPathNavigatorReader.cs 28 Oct 2004 18:20:19 -0000 1.3 @@ -28,7 +28,7 @@ /// See: http://weblogs.asp.net/cazzu/archive/2004/04/19/115966.aspx and /// http://weblogs.asp.net/cazzu/archive/2004/05/10/129101.aspx. /// </remarks> - public class XPathNavigatorReader : XmlTextReader, IXmlSerializable + public class XPathNavigatorReader : XmlTextReader, IXmlSerializable, IHasXPathNavigator { #region Fields @@ -735,5 +735,17 @@ } #endregion - } + + #region IHasXPathNavigator Members + + /// <summary> + /// Returns the XPathNavigator for the current position. + /// </summary> + public XPathNavigator GetNavigator() + { + return _navigator.Clone(); + } + + #endregion + } } |
From: Oleg T. <he...@us...> - 2004-10-28 18:20:33
|
Update of /cvsroot/mvp-xml/Common/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16245/v1/src Modified Files: Common.csproj Log Message: Added IHasXPathNavigator interface and its impl for XPathNavigatorReader to be able to extract underlying XPathNavigator out of XPathNavigatorReader. Index: Common.csproj =================================================================== RCS file: /cvsroot/mvp-xml/Common/v1/src/Common.csproj,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Common.csproj 25 Oct 2004 18:18:05 -0000 1.2 +++ Common.csproj 28 Oct 2004 18:20:19 -0000 1.3 @@ -158,6 +158,11 @@ BuildAction = "Compile" /> <File + RelPath = "XPath\IHasXPathNavigator.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "XPath\IndexingXPathNavigator.cs" SubType = "Code" BuildAction = "Compile" |
From: Oleg T. <he...@us...> - 2004-10-28 13:02:05
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/EdUni/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2444/v1/test/XInclude-Test-Suite/EdUni/test Modified Files: book.xml chap1.xml chap2.xml extract.xml Log Message: Working on bugs. Index: extract.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/EdUni/test/extract.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- extract.xml 29 Sep 2004 07:46:15 -0000 1.1 +++ extract.xml 28 Oct 2004 13:01:53 -0000 1.2 @@ -1,4 +1,5 @@ <!DOCTYPE extract [ +<!ELEMENT include (#PCDATA)> <!ATTLIST include xmlns CDATA #FIXED "http://www.w3.org/2001/XInclude"> ]> <extract> Index: chap1.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/EdUni/test/chap1.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- chap1.xml 29 Sep 2004 07:46:15 -0000 1.1 +++ chap1.xml 28 Oct 2004 13:01:53 -0000 1.2 @@ -1,4 +1,5 @@ <!DOCTYPE chapter [ +<!ELEMENT chapter (#PCDATA)> <!ATTLIST chapter id ID #IMPLIED> ]> <chapter id="chap1"> Index: chap2.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/EdUni/test/chap2.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- chap2.xml 29 Sep 2004 07:46:15 -0000 1.1 +++ chap2.xml 28 Oct 2004 13:01:53 -0000 1.2 @@ -1,4 +1,5 @@ <!DOCTYPE chapter [ +<!ELEMENT chapter (#PCDATA)> <!ATTLIST chapter id ID #IMPLIED> ]> <chapter id="chap2"> Index: book.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/EdUni/test/book.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- book.xml 19 Oct 2004 16:24:56 -0000 1.3 +++ book.xml 28 Oct 2004 13:01:53 -0000 1.4 @@ -1,5 +1,7 @@ <!DOCTYPE book [ +<!ELEMENT intro (#PCDATA)> <!ATTLIST intro id ID #IMPLIED> +<!ELEMENT include (#PCDATA)> <!ATTLIST include xmlns CDATA #FIXED "http://www.w3.org/2001/XInclude"> ]> <book> |
From: Oleg T. <he...@us...> - 2004-10-28 13:02:05
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2444/v1/src Modified Files: XInclude.csproj XIncludingReader.cs Log Message: Working on bugs. Index: XInclude.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XInclude.csproj,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- XInclude.csproj 25 Oct 2004 19:32:39 -0000 1.6 +++ XInclude.csproj 28 Oct 2004 13:01:51 -0000 1.7 @@ -77,7 +77,7 @@ <Reference Name = "System.XML" AssemblyName = "System.Xml" - HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" + HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> </References> </Build> @@ -235,12 +235,6 @@ BuildAction = "Compile" /> <File - RelPath = "Common\XPath\XPathIteratorReader.cs" - Link = "..\..\..\Common\v1\src\XPath\XPathIteratorReader.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "Common\XPath\XPathNavigatorIterator.cs" Link = "..\..\..\Common\v1\src\XPath\XPathNavigatorIterator.cs" SubType = "Code" Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- XIncludingReader.cs 26 Oct 2004 19:28:41 -0000 1.16 +++ XIncludingReader.cs 28 Oct 2004 13:01:51 -0000 1.17 @@ -68,7 +68,7 @@ //XmlResolver to resolve URIs XmlResolver _xmlResolver; //Expose text inclusions as CDATA - private bool _exposeTextAsCDATA; + private bool _exposeTextAsCDATA; #endregion #region Constructors @@ -121,6 +121,15 @@ /// <param name="reader"><c>TextReader</c>.</param> public XIncludingReader(TextReader reader) : this(new XmlBaseAwareXmlTextReader(reader)) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified URL and <c>TextReader</c> reader. + /// </summary> + /// <param name="reader"><c>TextReader</c>.</param> + /// <param name="url">Source document's URL</param> + public XIncludingReader(string url, TextReader reader) + : this(new XmlBaseAwareXmlTextReader(url, reader)) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -130,6 +139,16 @@ /// <param name="nt">Nametable.</param> public XIncludingReader(TextReader reader, XmlNameTable nt) : this(new XmlBaseAwareXmlTextReader(reader, nt)) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified URL, <c>TextReader</c> reader and nametable. + /// </summary> + /// <param name="reader"><c>TextReader</c>.</param> + /// <param name="nt">Nametable.</param> + /// <param name="url">Source document's URI</param> + public XIncludingReader(string url, TextReader reader, XmlNameTable nt) : + this(new XmlBaseAwareXmlTextReader(url, reader, nt)) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -138,6 +157,15 @@ /// <param name="input"><c>Stream</c>.</param> public XIncludingReader(Stream input) : this(new XmlBaseAwareXmlTextReader(input)) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified URL and <c>Stream</c>. + /// </summary> + /// <param name="input"><c>Stream</c>.</param> + /// <param name="url">Source document's URL</param> + public XIncludingReader(string url, Stream input) + : this(new XmlBaseAwareXmlTextReader(url, input)) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -147,6 +175,16 @@ /// <param name="nt">Nametable</param> public XIncludingReader(Stream input, XmlNameTable nt) : this(new XmlBaseAwareXmlTextReader(input, nt)) {} + + /// <summary> + /// Creates new instance of <c>XIncludingReader</c> class with + /// specified URL, <c>Stream</c> and nametable. + /// </summary> + /// <param name="input"><c>Stream</c>.</param> + /// <param name="nt">Nametable</param> + /// <param name="url">Source document's URL</param> + public XIncludingReader(string url, Stream input, XmlNameTable nt) : + this(new XmlBaseAwareXmlTextReader(url, input, nt)) {} #endregion @@ -714,7 +752,8 @@ case XmlNodeType.Document: case XmlNodeType.DocumentType: case XmlNodeType.DocumentFragment: - //This stuff should not be included + //This stuff should not be included into resulting infoset, + //but should be inclused into acquired infoset return _readers.Count>0? Read() : baseRead; case XmlNodeType.Element: //Check for xi:include @@ -1004,8 +1043,18 @@ if (xpointer != null) { //Well, XPointers should be resolved against the acquired infoset, - //not the source infoset - _reader = new XPointerReader(wRes.ResponseUri, stream, _nameTable, xpointer); + //not the source infoset + //TODO: Try to stream this stuff + string uri = wRes.ResponseUri.AbsoluteUri; + XIncludingReader xir = new XIncludingReader(uri, stream, _nameTable); + StringWriter sw = new StringWriter(); + XmlTextWriter w = new XmlTextWriter(sw); + while (xir.Read()) + w.WriteNode(xir, false); + xir.Close(); + w.Close(); + _reader = new XPointerReader(new XmlTextReader( + uri, new StringReader(sw.ToString())), xpointer); } else { @@ -1293,5 +1342,6 @@ } #endregion + } } |
From: Oleg T. <he...@us...> - 2004-10-28 13:02:05
|
Update of /cvsroot/mvp-xml/XInclude/v1/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2444/v1/test Modified Files: EntryPoint.cs XIncludeReaderTests.cs XIncludeTest.csproj Log Message: Working on bugs. Index: XIncludeTest.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeTest.csproj,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- XIncludeTest.csproj 19 Oct 2004 16:24:56 -0000 1.6 +++ XIncludeTest.csproj 28 Oct 2004 13:01:53 -0000 1.7 @@ -75,11 +75,6 @@ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" /> <Reference - Name = "System.XML" - AssemblyName = "System.Xml" - HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" - /> - <Reference Name = "nunit.framework" AssemblyName = "nunit.framework" HintPath = "..\..\..\..\..\Program Files\NUnit 2.2\bin\nunit.framework.dll" @@ -90,6 +85,11 @@ Project = "{3750FAB1-FD0E-425A-9DAA-87543A556319}" Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" /> + <Reference + Name = "System.XML" + AssemblyName = "System.XML" + HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" + /> </References> </Build> <Files> Index: EntryPoint.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/EntryPoint.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- EntryPoint.cs 26 Oct 2004 19:28:43 -0000 1.7 +++ EntryPoint.cs 28 Oct 2004 13:01:52 -0000 1.8 @@ -10,12 +10,13 @@ public static void Main() { //XIncludeReaderTests rt = new XIncludeReaderTests(); - //EdUniTests rt = new EdUniTests(); + LTG_Edinburgh_UnivTests rt = new LTG_Edinburgh_UnivTests(); //NistTests rt = new NistTests(); - Elliotte_Rusty_HaroldTests rt = new Elliotte_Rusty_HaroldTests(); + //Elliotte_Rusty_HaroldTests rt = new Elliotte_Rusty_HaroldTests(); + //FourThoughtTests rt = new FourThoughtTests(); try { - rt.harold_90(); + rt.eduni_2(); } catch (Exception e) { Index: XIncludeReaderTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeReaderTests.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- XIncludeReaderTests.cs 26 Oct 2004 19:28:43 -0000 1.8 +++ XIncludeReaderTests.cs 28 Oct 2004 13:01:52 -0000 1.9 @@ -85,7 +85,8 @@ case XmlNodeType.DocumentType: Assert.AreEqual(r2.NodeType, XmlNodeType.DocumentType); Assert.AreEqual(r1.Name, r2.Name); - Assert.AreEqual(r1.Value, r2.Value); + //Ok, don't compare DTD content + //Assert.AreEqual(r1.Value, r2.Value); break; case XmlNodeType.Element: Assert.AreEqual(r2.NodeType, XmlNodeType.Element); @@ -123,7 +124,7 @@ break; case XmlNodeType.Text: Assert.IsTrue(r2.NodeType == XmlNodeType.CDATA || r2.NodeType == XmlNodeType.Text); - Assert.AreEqual(r1.Value, r2.Value); + Assert.AreEqual(r1.Value.Replace("\r\n", "\n").Trim(), r2.Value.Replace("\r\n", "\n").Trim()); break; default: break; |
From: Oleg T. <he...@us...> - 2004-10-28 12:55:17
|
Update of /cvsroot/mvp-xml/XPointer/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv798/v1/src Modified Files: SR.cs SR.resx SchemaBasedPointer.cs ShorthandPointer.cs XPointer.csproj XPointerParser.cs XPointerReader.cs Log Message: Working on bugs. Index: XPointerParser.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/XPointerParser.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- XPointerParser.cs 26 Oct 2004 19:26:51 -0000 1.3 +++ XPointerParser.cs 28 Oct 2004 12:55:01 -0000 1.4 @@ -120,7 +120,7 @@ else throw new XPointerSyntaxException(SR.InvalidToken); } - return new SchemaBasedPointer(parts); + return new SchemaBasedPointer(parts, xpointer); } } Index: SchemaBasedPointer.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/SchemaBasedPointer.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SchemaBasedPointer.cs 9 Oct 2004 19:52:19 -0000 1.3 +++ SchemaBasedPointer.cs 28 Oct 2004 12:55:01 -0000 1.4 @@ -17,7 +17,8 @@ #region private members - private ArrayList _parts; + private ArrayList _parts; + private string _xpointer; #endregion @@ -27,9 +28,12 @@ /// Creates scheme based XPointer given list of pointer parts. /// </summary> /// <param name="parts">List of pointer parts</param> - public SchemaBasedPointer(ArrayList parts) + /// <param name="xpointer">String representation of the XPointer + /// (for error diagnostics)</param> + public SchemaBasedPointer(ArrayList parts, string xpointer) { - _parts = parts; + _parts = parts; + _xpointer = xpointer; } #endregion @@ -67,7 +71,7 @@ if (result != null && result.MoveNext()) return result; } - throw new NoSubresourcesIdentifiedException(SR.NoSubresourcesIdentifiedException); + throw new NoSubresourcesIdentifiedException(SR.GetString("NoSubresourcesIdentifiedException", _xpointer)); } #endregion Index: ShorthandPointer.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/ShorthandPointer.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ShorthandPointer.cs 9 Oct 2004 19:52:19 -0000 1.3 +++ ShorthandPointer.cs 28 Oct 2004 12:55:01 -0000 1.4 @@ -62,7 +62,7 @@ return result; } else - throw new NoSubresourcesIdentifiedException(SR.NoSubresourcesIdentifiedException); + throw new NoSubresourcesIdentifiedException(SR.GetString("NoSubresourcesIdentifiedException", _NCName)); } #endregion } Index: XPointerReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/XPointerReader.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- XPointerReader.cs 19 Oct 2004 16:27:39 -0000 1.4 +++ XPointerReader.cs 28 Oct 2004 12:55:01 -0000 1.5 @@ -97,7 +97,7 @@ /// Additionally sets a flag whether to support schema-determined IDs. /// </summary> public XPointerReader(XmlReader reader, string xpointer, bool supportSchemaDeterminedIDs) - { + { XmlValidatingReader vr = null; if (supportSchemaDeterminedIDs) { @@ -110,8 +110,8 @@ vr.ValidationType = ValidationType.None; } vr.EntityHandling = EntityHandling.ExpandEntities; - vr.ValidationEventHandler += new System.Xml.Schema.ValidationEventHandler(ValidationCallback); - XPathDocument doc = new XPathDocument(vr, XmlSpace.Preserve); + vr.ValidationEventHandler += new System.Xml.Schema.ValidationEventHandler(ValidationCallback); + XPathDocument doc = new XPathDocument(vr, XmlSpace.Preserve); vr.Close(); Init(doc, xpointer); } Index: SR.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/SR.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SR.cs 4 Oct 2004 19:05:55 -0000 1.1 +++ SR.cs 28 Oct 2004 12:55:01 -0000 1.2 @@ -82,16 +82,7 @@ { return SR.GetString("EmptyElementSchemeXPointer"); } - } - - /// <summary></summary> - public static string NoSubresourcesIdentifiedException - { - get - { - return SR.GetString("NoSubresourcesIdentifiedException"); - } - } + } /// <summary></summary> public static string InvalidTokenInXmlnsSchemeWhileNCNameExpected Index: SR.resx =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/SR.resx,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SR.resx 19 Oct 2004 16:27:38 -0000 1.3 +++ SR.resx 28 Oct 2004 12:55:01 -0000 1.4 @@ -52,7 +52,7 @@ <value>Syntax error in element() scheme data: empty XPointer.</value> </data> <data name="NoSubresourcesIdentifiedException" type="System.String" mimetype="System.String"> - <value>XPointer doesn't identify any subresources.</value> + <value>XPointer '{0}' doesn't identify any subresources.</value> </data> <data name="InvalidTokenInXmlnsSchemeWhileNCNameExpected" type="System.String" mimetype="System.String"> <value>Syntax error in xmlns() scheme data: Invalid token in XmlnsSchemaData, NCName was expected.</value> Index: XPointer.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/XPointer.csproj,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- XPointer.csproj 11 Oct 2004 20:56:47 -0000 1.4 +++ XPointer.csproj 28 Oct 2004 12:55:01 -0000 1.5 @@ -76,8 +76,8 @@ /> <Reference Name = "System.XML" - AssemblyName = "System.Xml" - HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" + AssemblyName = "System.XML" + HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> </References> </Build> @@ -242,12 +242,6 @@ BuildAction = "Compile" /> <File - RelPath = "Common\XmlTransformingReader.cs" - Link = "..\..\..\Common\v1\src\XmlTransformingReader.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "Common\XPath\DynamicContext.cs" Link = "..\..\..\Common\v1\src\XPath\DynamicContext.cs" SubType = "Code" |
From: Oleg T. <he...@us...> - 2004-10-26 19:29:32
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11487/v1/src Modified Files: SR.cs SR.resx TextIncludingReader.cs TextUtils.cs XIncludeException.cs XIncludingReader.cs Log Message: Working on bugs. Index: TextUtils.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/TextUtils.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- TextUtils.cs 29 Sep 2004 21:26:28 -0000 1.2 +++ TextUtils.cs 26 Oct 2004 19:28:41 -0000 1.3 @@ -46,6 +46,19 @@ } } + /// <summary> + /// Checks value of the 'accept' attribute for validity. + /// Characters must be in #x20 through #x7E range. + /// </summary> + public static void CheckAcceptValue(string accept) + { + foreach (char c in accept) + { + if (c < 0x0020 || c > 0x007E) + throw new InvalidAcceptHTTPHeaderValue(c); + } + } + #endregion } } Index: XIncludeException.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludeException.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- XIncludeException.cs 18 Oct 2004 18:19:21 -0000 1.5 +++ XIncludeException.cs 26 Oct 2004 19:28:41 -0000 1.6 @@ -103,4 +103,23 @@ { public MalformedXInclusionResultError(string message) : base(message) {} } + + /// <summary> + /// Value of the "accept" attribute contains an invalid for + /// HTTP header character (outside #x20 through #x7E range). + /// </summary> + public class InvalidAcceptHTTPHeaderValue : FatalException + { + public InvalidAcceptHTTPHeaderValue(char c) : + base(SR.GetString("InvalidCharForAccept", ((int)c).ToString("X2"))) {} + } + + /// <summary> + /// Fragment identifiers must not be used. + /// </summary> + public class FragmentIdentifierInHrefAttribute : FatalException + { + public FragmentIdentifierInHrefAttribute() : base(SR.FragmentIDInHref) {} + } + } Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- XIncludingReader.cs 25 Oct 2004 19:32:39 -0000 1.15 +++ XIncludingReader.cs 26 Oct 2004 19:28:41 -0000 1.16 @@ -67,6 +67,8 @@ private FallbackState _prevFallbackState; //XmlResolver to resolve URIs XmlResolver _xmlResolver; + //Expose text inclusions as CDATA + private bool _exposeTextAsCDATA; #endregion #region Constructors @@ -689,10 +691,7 @@ //Read internal reader bool baseRead = _reader.Read(); if (baseRead) - { - //No provision to preserve whitespace outside document element - if (_reader.Depth == 0 && _reader.NodeType == XmlNodeType.Whitespace) - return Read(); + { //If we are including and including reader is at 0 depth - //we are in top level included item _topLevel = (_readers.Count>0 && _reader.Depth == 0)? true : false; @@ -831,11 +830,23 @@ /// Flag indicating whether to emit xml:base as relative URI. /// Note, it's true by default /// </summary> - public bool RelativeBaseUri + public bool MakeRelativeBaseUri { get { return _relativeBaseUri; } set { _relativeBaseUri = value; } } + + /// <summary> + /// Flag indicating whether expose text inclusions + /// as CDATA or as Text. By default it's Text. + /// </summary> + public bool ExposeTextInclusionsAsCDATA + { + get { return _exposeTextAsCDATA; } + set { _exposeTextAsCDATA = value; } + } + + #endregion #region Private methods @@ -915,7 +926,8 @@ if (httpReq != null) { if (accept != null) - { + { + TextUtils.CheckAcceptValue(accept); if (httpReq.Accept == null || httpReq.Accept == String.Empty) httpReq.Accept = accept; else @@ -949,7 +961,7 @@ { string href = _reader.GetAttribute(_keywords.Href); string xpointer = _reader.GetAttribute(_keywords.Xpointer); - if (href == null) + if (href == null || href == String.Empty) { if (xpointer == null) { @@ -978,6 +990,8 @@ { //Include document as XML Uri includeLocation = ResolveHref(href); + if (includeLocation.Fragment != String.Empty) + throw new FragmentIdentifierInHrefAttribute(); if (_xmlResolver == null) { //No custom resolver @@ -987,10 +1001,12 @@ _reader.GetAttribute(_keywords.AcceptLanguage), out wRes); //Push current reader to the stack _readers.Push(_reader); - if (xpointer != null) - _reader = new XPointerReader(wRes.ResponseUri, stream, _nameTable, xpointer); - else if (includeLocation.Fragment != String.Empty) - _reader = new XPointerReader(wRes.ResponseUri, stream, _nameTable, includeLocation.Fragment.Substring(1)); + if (xpointer != null) + { + //Well, XPointers should be resolved against the acquired infoset, + //not the source infoset + _reader = new XPointerReader(wRes.ResponseUri, stream, _nameTable, xpointer); + } else { _reader = new XmlBaseAwareXmlTextReader(wRes.ResponseUri.AbsoluteUri, stream, _nameTable); @@ -1044,7 +1060,8 @@ _readers.Push(_reader); _reader = new TextIncludingReader(includeLocation, encoding, _reader.GetAttribute(_keywords.Accept), - _reader.GetAttribute(_keywords.AcceptLanguage)); + _reader.GetAttribute(_keywords.AcceptLanguage), + _exposeTextAsCDATA); return Read(); } else @@ -1073,7 +1090,7 @@ try { if (_xmlResolver == null) - includeLocation = new Uri(new Uri(_reader.BaseURI), href); + includeLocation = new Uri(new Uri(_reader.BaseURI), href, false); else includeLocation = _xmlResolver.ResolveUri(new Uri(_reader.BaseURI), href); } @@ -1211,9 +1228,9 @@ } else throw new XIncludeSyntaxError(SR.GetString("IncludeChildOfInclude", - _reader.BaseURI.ToString())); + _reader.BaseURI.ToString())); } - if (IsFallbackElement(_reader)) + else if (IsFallbackElement(_reader)) { //Found xi:fallback if (fallbackElem) @@ -1235,6 +1252,11 @@ SkipContent(); } } + //Check anything else in XInclude namespace + else if(XIncludeKeywords.Equals(_reader.NamespaceURI, _keywords.XIncludeNamespace)) + { + throw new XIncludeSyntaxError(SR.GetString("UnknownXIncludeElement", _reader.Name)); + } else //Ignore everything else SkipContent(); Index: SR.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/SR.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SR.cs 18 Oct 2004 18:19:21 -0000 1.3 +++ SR.cs 26 Oct 2004 19:28:41 -0000 1.4 @@ -92,6 +92,16 @@ return SR.GetString("MalformedXInclusionResult"); } } + + + /// <summary></summary> + public static string FragmentIDInHref + { + get + { + return SR.GetString("FragmentIDInHref"); + } + } } } Index: SR.resx =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/SR.resx,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SR.resx 18 Oct 2004 18:19:21 -0000 1.3 +++ SR.resx 26 Oct 2004 19:28:41 -0000 1.4 @@ -123,4 +123,13 @@ <data name="MalformedXInclusionResult" type="System.String" mimetype="System.String"> <value>Malformed XInclusion result - xi:include element at the top level can't include more than one element.</value> </data> + <data name="InvalidCharForAccept" type="System.String" mimetype="System.String"> + <value>'accept' attribute contains a character not allowed in HTTP header: 0x{0}.</value> + </data> + <data name="FragmentIDInHref" type="System.String" mimetype="System.String"> + <value>Fragment identifiers must not be used in 'href' attribute.</value> + </data> + <data name="UnknownXIncludeElement" type="System.String" mimetype="System.String"> + <value>Unknown element in the XInclude namespace has been detected: {0}.</value> + </data> </root> \ No newline at end of file Index: TextIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/TextIncludingReader.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- TextIncludingReader.cs 14 Oct 2004 14:17:55 -0000 1.4 +++ TextIncludingReader.cs 26 Oct 2004 19:28:41 -0000 1.5 @@ -28,19 +28,21 @@ private Uri _includeLocation; private string _accept, _acceptLanguage; private string _href; + private bool _exposeCDATA; - #endregion + #endregion #region constructors - internal TextIncludingReader(Uri includeLocation, string encoding, - string accept, string acceptLanguage) { + public TextIncludingReader(Uri includeLocation, string encoding, + string accept, string acceptLanguage, bool exposeCDATA) { _includeLocation = includeLocation; _href = includeLocation.AbsoluteUri; _encoding = encoding; _state = ReadState.Initial; _accept = accept; _acceptLanguage = acceptLanguage; + _exposeCDATA = exposeCDATA; } #endregion @@ -105,7 +107,9 @@ } public override XmlNodeType NodeType { - get { return _state==ReadState.Interactive? XmlNodeType.Text : XmlNodeType.None; } + get { return _state==ReadState.Interactive? + _exposeCDATA? XmlNodeType.CDATA : XmlNodeType.Text + : XmlNodeType.None; } } public override string Prefix { |
From: Oleg T. <he...@us...> - 2004-10-26 19:29:30
|
Update of /cvsroot/mvp-xml/XInclude/v1/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11487/v1/test Modified Files: Elliotte_Rusty_HaroldTests.cs EntryPoint.cs XIncludeReaderTests.cs Log Message: Working on bugs. Index: EntryPoint.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/EntryPoint.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- EntryPoint.cs 25 Oct 2004 19:32:39 -0000 1.6 +++ EntryPoint.cs 26 Oct 2004 19:28:43 -0000 1.7 @@ -9,13 +9,13 @@ { public static void Main() { - XIncludeReaderTests rt = new XIncludeReaderTests(); + //XIncludeReaderTests rt = new XIncludeReaderTests(); //EdUniTests rt = new EdUniTests(); //NistTests rt = new NistTests(); - //Elliotte_Rusty_HaroldTests rt = new Elliotte_Rusty_HaroldTests(); + Elliotte_Rusty_HaroldTests rt = new Elliotte_Rusty_HaroldTests(); try { - rt.OuterXmlTest(); + rt.harold_90(); } catch (Exception e) { Index: XIncludeReaderTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeReaderTests.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- XIncludeReaderTests.cs 25 Oct 2004 19:32:39 -0000 1.7 +++ XIncludeReaderTests.cs 26 Oct 2004 19:28:43 -0000 1.8 @@ -22,15 +22,24 @@ Debug.Listeners.Add(new TextWriterTraceListener(Console.Error)); } - + /// <summary> /// Utility method for running tests. /// </summary> public static void RunAndCompare(string source, string result) + { + RunAndCompare(source, result, false); + } + + /// <summary> + /// Utility method for running tests. + /// </summary> + public static void RunAndCompare(string source, string result, bool textAsCDATA) { XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; XIncludingReader xir = new XIncludingReader(source); + xir.ExposeTextInclusionsAsCDATA = textAsCDATA; try { doc.Load(xir); @@ -66,7 +75,7 @@ Assert.AreEqual(r1.Value, r2.Value); break; case XmlNodeType.CDATA: - Assert.AreEqual(r2.NodeType, XmlNodeType.CDATA); + Assert.IsTrue(r2.NodeType == XmlNodeType.CDATA || r2.NodeType == XmlNodeType.Text); Assert.AreEqual(r1.Value, r2.Value); break; case XmlNodeType.Comment: @@ -113,7 +122,7 @@ Assert.AreEqual(r1.Value, r2.Value); break; case XmlNodeType.Text: - Assert.AreEqual(r2.NodeType, XmlNodeType.Text); + Assert.IsTrue(r2.NodeType == XmlNodeType.CDATA || r2.NodeType == XmlNodeType.Text); Assert.AreEqual(r1.Value, r2.Value); break; default: Index: Elliotte_Rusty_HaroldTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/Elliotte_Rusty_HaroldTests.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Elliotte_Rusty_HaroldTests.cs 19 Oct 2004 16:24:56 -0000 1.1 +++ Elliotte_Rusty_HaroldTests.cs 26 Oct 2004 19:28:43 -0000 1.2 @@ -25,9 +25,17 @@ /// </summary> public static void RunAndCompare(string source, string result) { + RunAndCompare(source, result, false); + } + + /// <summary> + /// Utility method for running tests. + /// </summary> + public static void RunAndCompare(string source, string result, bool textAsCDATA) + { XIncludeReaderTests.RunAndCompare( "../../XInclude-Test-Suite/Harold/test/" + source, - "../../XInclude-Test-Suite/Harold/test/" + result); + "../../XInclude-Test-Suite/Harold/test/" + result, textAsCDATA); } @@ -177,8 +185,15 @@ /// <summary> /// Syntactically incorrect IRI is a fatal error (Eitehr I'm missing something or the spec needs to state this prinicple more clearly.) /// </summary> + /// <remarks> + /// As per spec: + /// "A value that results in a syntactically invalid URI or IRI should be + /// reported as a fatal error, but some implementations may find it + /// impractical to distinguish this case from a resource error." + /// We do treat it as a resource error. + /// </remarks> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(DirectoryNotFoundException))] public void harold_13() { RunAndCompare("badiri.xml", ""); @@ -189,8 +204,15 @@ /// <summary> /// Syntactically incorrect IRI with an unrecognized scheme is a fatal error /// </summary> + /// <remarks> + /// As per spec: + /// "A value that results in a syntactically invalid URI or IRI should be + /// reported as a fatal error, but some implementations may find it + /// impractical to distinguish this case from a resource error." + /// We do treat it as a resource error. + /// </remarks> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(DirectoryNotFoundException))] public void harold_14() { RunAndCompare("badiri2.xml", ""); @@ -213,7 +235,7 @@ /// accept attribute contains carriage-return/linefeed pair /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(InvalidAcceptHTTPHeaderValue))] public void harold_16() { RunAndCompare("badaccept1.xml", ""); @@ -225,7 +247,7 @@ /// accept attribute contains Latin-1 character (non-breaking space) /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(InvalidAcceptHTTPHeaderValue))] public void harold_17() { RunAndCompare("badaccept2.xml", ""); @@ -283,7 +305,7 @@ [Test] public void harold_22() { - RunAndCompare("metafallbacktest2.xml", "../result/metafallbacktest2.xml"); + RunAndCompare("metafallbacktest2.xml", "../result/metafallbacktest2.xml", true); } @@ -292,7 +314,7 @@ /// A fallback element in an included document contains an include element with a parse attribute with an illegal value. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(UnknownParseAttributeValueException))] public void harold_23() { RunAndCompare("metafallbacktest3.xml", ""); @@ -304,7 +326,7 @@ /// A fallback element in an included document contains an include element with neither an xpointer nor an href attribute. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(MissingHrefAndXpointerException))] public void harold_24() { RunAndCompare("metafallbacktest4.xml", ""); @@ -317,7 +339,7 @@ /// A fallback element in an included document contains an include element whose href attribute has a fragment ID. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] public void harold_25() { RunAndCompare("metafallbacktestwithfragmentid.xml", ""); @@ -329,7 +351,7 @@ /// The XPointer does not select anything in the acquired infoset, but does select something in the source infoset. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_26() { RunAndCompare("metafallbacktest5.xml", ""); @@ -377,7 +399,7 @@ /// then fails to find a resource, which is a fatal error if there's no fallback. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_30() { RunAndCompare("metamissingfallbacktestwithxpointer.xml", ""); @@ -390,7 +412,7 @@ /// then fails to find a resource, but it has a fallback, which itself has an include child, which then throws a fatal error. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_31() { RunAndCompare("metafallbackwithbadxpointertest.xml", ""); @@ -412,8 +434,8 @@ /// <summary> /// An include element points to a document that includes it, using an xpointer to select part of that document. /// </summary> - [Test] - [ExpectedException(typeof(Exception))] + [Test] + [ExpectedException(typeof(CircularInclusionException))] public void harold_33() { RunAndCompare("legalcircle.xml", ""); @@ -458,7 +480,7 @@ /// Detect an inclusion loop when an include element refers to itself /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(CircularInclusionException))] public void harold_37() { RunAndCompare("internalcircular.xml", ""); @@ -471,7 +493,7 @@ /// in the same document /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(CircularInclusionException))] public void harold_38() { RunAndCompare("internalcircularviaancestor.xml", ""); @@ -528,7 +550,7 @@ /// testIncludeElementsCannotHaveIncludeChildren /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_43() { RunAndCompare("nestedxinclude.xml", ""); @@ -540,7 +562,7 @@ /// Include elements cannot have children from the xinclude namespace except for fallback. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_44() { RunAndCompare("nestedxincludenamespace.xml", ""); @@ -552,7 +574,7 @@ /// Fallback can only be a child of xinclude element /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_45() { RunAndCompare("nakedfallback.xml", ""); @@ -564,7 +586,7 @@ /// A fallback element cannot have a fallback child element. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_46() { RunAndCompare("fallbackcontainsfallback.xml", ""); @@ -578,7 +600,7 @@ /// In this test the fallback is activated. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_47() { RunAndCompare("multiplefallbacks.xml", ""); @@ -592,7 +614,7 @@ /// In this test the fallback is not activated. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_48() { RunAndCompare("multiplefallbacks2.xml", ""); @@ -604,7 +626,7 @@ /// A document cannot include itself /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(CircularInclusionException))] public void harold_49() { RunAndCompare("circle1.xml", ""); @@ -616,7 +638,7 @@ /// Document A includes document B which includes document A /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(CircularInclusionException))] public void harold_50() { RunAndCompare("circle2a.xml", ""); @@ -628,7 +650,7 @@ /// Include element is missing an href and xpointer attribute /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(MissingHrefAndXpointerException))] public void harold_51() { RunAndCompare("missinghref.xml", ""); @@ -640,7 +662,7 @@ /// parse attribute must have value xml or text /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(UnknownParseAttributeValueException))] public void harold_52() { RunAndCompare("badparseattribute.xml", ""); @@ -652,7 +674,7 @@ /// Missing resource is fatal when there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_53() { RunAndCompare("missingfile.xml", ""); @@ -708,7 +730,7 @@ /// XPointer that selects nothing is a resource error, and fatal because there's no fallback. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_58() { RunAndCompare("xptridtest2.xml", ""); @@ -743,7 +765,7 @@ /// the second XPointer part is still a fatal error. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_61() { RunAndCompare("laterfailure.xml", ""); @@ -756,7 +778,7 @@ /// the second XPointer part is still a fatal error. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_62() { RunAndCompare("laterfailure2.xml", ""); @@ -843,7 +865,7 @@ /// An XPointer that doesn't point to anything is a resource error; and fatal because there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_69() { RunAndCompare("xptrtumblertest2.xml", ""); @@ -855,7 +877,7 @@ /// Syntax error in an XPointer is a resource error; and fatal because there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_70() { RunAndCompare("badxptr.xml", ""); @@ -867,7 +889,7 @@ /// Syntax error in an XPointer is a resource error; and fatal because there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] public void harold_71() { RunAndCompare("badxptr2.xml", ""); @@ -967,7 +989,7 @@ /// Syntax error in an XPointer is a resource error; and fatal becaue there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_80() { RunAndCompare("badxptr3.xml", ""); @@ -979,7 +1001,7 @@ /// Syntax error in an XPointer is a resource error; and fatal becaue there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_81() { RunAndCompare("badxptr4.xml", ""); @@ -991,7 +1013,7 @@ /// Circular references via xpointer are fatal /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(CircularInclusionException))] public void harold_82() { RunAndCompare("circlepointer1.xml", ""); @@ -1003,7 +1025,7 @@ /// href attribute with fragment ID is a fatal error even when there's an xpointer attribute /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] public void harold_83() { RunAndCompare("xpointeroverridesfragmentid.xml", ""); @@ -1015,7 +1037,7 @@ /// href attribute with fragment ID is a fatal error /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] public void harold_84() { RunAndCompare("ignoresfragmentid.xml", ""); @@ -1039,7 +1061,7 @@ /// syntax of fragment IDs from RFC 2396. /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] public void harold_86() { RunAndCompare("meaninglessfragmentid.xml", ""); @@ -1098,7 +1120,7 @@ [Test] public void harold_90() { - RunAndCompare("accepthtml.xml", "../result/accepthtml.xml"); + RunAndCompare("accepthtml.xml", "../result/accepthtml.xml", true); } @@ -1107,7 +1129,7 @@ /// Unrecognized scheme in XPointer is a fatal error if there's no fallback /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(FatalResourceException))] public void harold_91() { RunAndCompare("unrecognizedscheme.xml", ""); @@ -1141,7 +1163,7 @@ /// Included document has an include element with neither href nor xpointer attribute /// </summary> [Test] - [ExpectedException(typeof(Exception))] + [ExpectedException(typeof(MissingHrefAndXpointerException))] public void harold_94() { RunAndCompare("toplevel.xml", ""); |
From: Oleg T. <he...@us...> - 2004-10-26 19:29:08
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/Harold/result In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11487/v1/test/XInclude-Test-Suite/Harold/result Modified Files: accepthtml.xml test.xml Log Message: Working on bugs. Index: accepthtml.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/Harold/result/accepthtml.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- accepthtml.xml 19 Oct 2004 16:25:01 -0000 1.1 +++ accepthtml.xml 26 Oct 2004 19:28:43 -0000 1.2 @@ -1,4 +1,4 @@ <?xml version="1.0"?> <root xmlns:xi="http://www.w3.org/2001/XInclude"> -<![CDATA[<html><body>content</body></html>]]> -</root> \ No newline at end of file +<![CDATA[<html><body>content</body></html> +]]></root> \ No newline at end of file Index: test.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/Harold/result/test.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- test.xml 19 Oct 2004 16:25:03 -0000 1.1 +++ test.xml 26 Oct 2004 19:28:44 -0000 1.2 @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!-- comment before root --> <!DOCTYPE test [ -<!ELEMENT test (latin1 , test2)> + <!ELEMENT test (latin1, test2)> ]> <test xmlns:xinclude="http://www.w3.org/2001/XInclude"> <latin1> |
From: Oleg T. <he...@us...> - 2004-10-26 19:29:08
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/Harold/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11487/v1/test/XInclude-Test-Suite/Harold/test Modified Files: docwithid.xml docwithidandtumbler.xml Log Message: Working on bugs. Index: docwithidandtumbler.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/Harold/test/docwithidandtumbler.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- docwithidandtumbler.xml 19 Oct 2004 16:25:05 -0000 1.1 +++ docwithidandtumbler.xml 26 Oct 2004 19:28:45 -0000 1.2 @@ -1,4 +1,5 @@ <!DOCTYPE test [ + <!ELEMENT p (#PCDATA)> <!ATTLIST p id ID #REQUIRED> ]> <test> Index: docwithid.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XInclude-Test-Suite/Harold/test/docwithid.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- docwithid.xml 19 Oct 2004 16:25:05 -0000 1.1 +++ docwithid.xml 26 Oct 2004 19:28:44 -0000 1.2 @@ -1,4 +1,5 @@ <!DOCTYPE test [ + <!ELEMENT p (#PCDATA)> <!ATTLIST p id ID #REQUIRED> ]> <test> |
From: Oleg T. <he...@us...> - 2004-10-26 19:27:18
|
Update of /cvsroot/mvp-xml/XPointer/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11154/v1/src Modified Files: ElementSchemaPointerPart.cs XPath1SchemaPointerPart.cs XPointerParser.cs XPointerSchemaPointerPart.cs XmlnsSchemaPointerPart.cs Log Message: Syntax error should lead to an exception. Index: ElementSchemaPointerPart.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/ElementSchemaPointerPart.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ElementSchemaPointerPart.cs 4 Oct 2004 19:04:34 -0000 1.2 +++ ElementSchemaPointerPart.cs 26 Oct 2004 19:26:50 -0000 1.3 @@ -117,9 +117,8 @@ lexer.NextLexeme(); } if (lexer.Kind != XPointerLexer.LexKind.RRBracket) - { - Debug.WriteLine(SR.InvalidTokenInElementSchemeWhileClosingRoundBracketExpected); - return null; + { + throw new XPointerSyntaxException(SR.InvalidTokenInElementSchemeWhileClosingRoundBracketExpected); } if (part.NCName==null && part.ChildSequence.Count==0) { Index: XPointerParser.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/XPointerParser.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XPointerParser.cs 4 Oct 2004 19:04:35 -0000 1.2 +++ XPointerParser.cs 26 Oct 2004 19:26:51 -0000 1.3 @@ -39,7 +39,8 @@ } } if (schemaNSURI == null) - throw new XPointerSyntaxException(SR.GetString("UndeclaredPrefix", lexer.Prefix)); + //No binding for the prefix - ignore pointer part + return XPointerSchema.SchemaType.Unknown; } else schemaNSURI = String.Empty; Index: XPointerSchemaPointerPart.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/XPointerSchemaPointerPart.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XPointerSchemaPointerPart.cs 4 Oct 2004 19:04:35 -0000 1.2 +++ XPointerSchemaPointerPart.cs 26 Oct 2004 19:26:52 -0000 1.3 @@ -66,8 +66,7 @@ } catch (Exception e) { - Debug.WriteLine(SR.GetString("SyntaxErrorInXPointerSchemeData", e.Message)); - return null; + throw new XPointerSyntaxException(SR.GetString("SyntaxErrorInXPointerSchemeData", e.Message)); } return part; } Index: XmlnsSchemaPointerPart.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/XmlnsSchemaPointerPart.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XmlnsSchemaPointerPart.cs 4 Oct 2004 19:04:35 -0000 1.2 +++ XmlnsSchemaPointerPart.cs 26 Oct 2004 19:26:52 -0000 1.3 @@ -103,8 +103,7 @@ } catch (Exception e) { - Debug.WriteLine(SR.GetString("SyntaxErrorInXmlnsSchemeData", e.Message)); - return null; + throw new XPointerSyntaxException(SR.GetString("SyntaxErrorInXmlnsSchemeData", e.Message)); } return new XmlnsSchemaPointerPart(prefix, nsURI); } Index: XPath1SchemaPointerPart.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/XPath1SchemaPointerPart.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XPath1SchemaPointerPart.cs 4 Oct 2004 19:04:35 -0000 1.2 +++ XPath1SchemaPointerPart.cs 26 Oct 2004 19:26:51 -0000 1.3 @@ -65,9 +65,8 @@ } catch (Exception e) { - Debug.WriteLine(SR.GetString("SyntaxErrorInXPath1SchemeData", - e.Message)); - return null; + throw new XPointerSyntaxException(SR.GetString("SyntaxErrorInXPath1SchemeData", + e.Message)); } return part; } |
From: Oleg T. <he...@us...> - 2004-10-25 19:32:50
|
Update of /cvsroot/mvp-xml/XInclude/v1/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8014/v1/test Modified Files: EntryPoint.cs XIncludeReaderTests.cs Log Message: Integrated XmlBaseAwareXmltextReader. Index: EntryPoint.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/EntryPoint.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- EntryPoint.cs 22 Oct 2004 14:56:42 -0000 1.5 +++ EntryPoint.cs 25 Oct 2004 19:32:39 -0000 1.6 @@ -12,9 +12,10 @@ XIncludeReaderTests rt = new XIncludeReaderTests(); //EdUniTests rt = new EdUniTests(); //NistTests rt = new NistTests(); + //Elliotte_Rusty_HaroldTests rt = new Elliotte_Rusty_HaroldTests(); try { - rt.InnerXmlTest(); + rt.OuterXmlTest(); } catch (Exception e) { Index: XIncludeReaderTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeReaderTests.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- XIncludeReaderTests.cs 22 Oct 2004 14:56:42 -0000 1.6 +++ XIncludeReaderTests.cs 25 Oct 2004 19:32:39 -0000 1.7 @@ -5,6 +5,7 @@ using System.Text; using Mvp.Xml.XInclude; +using Mvp.Xml.Common; using NUnit.Framework; namespace Mvp.Xml.XInclude.Test @@ -28,20 +29,18 @@ public static void RunAndCompare(string source, string result) { XmlDocument doc = new XmlDocument(); - doc.PreserveWhitespace = true; - XmlValidatingReader vr = new XmlValidatingReader(new XmlTextReader(source)); - vr.ValidationType = ValidationType.None; - vr.EntityHandling = EntityHandling.ExpandEntities; + doc.PreserveWhitespace = true; + XIncludingReader xir = new XIncludingReader(source); try { - doc.Load(new XIncludingReader(vr)); + doc.Load(xir); } catch (Exception e) { - vr.Close(); + xir.Close(); throw e; } - vr.Close(); + xir.Close(); XmlTextReader r1 = new XmlTextReader(new StringReader(doc.OuterXml)); r1.WhitespaceHandling = WhitespaceHandling.Significant; XmlTextReader r2 = new XmlTextReader(result); |
From: Oleg T. <he...@us...> - 2004-10-25 19:32:49
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8014/v1/src Modified Files: XInclude.csproj XIncludingReader.cs Log Message: Integrated XmlBaseAwareXmltextReader. Index: XInclude.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XInclude.csproj,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- XInclude.csproj 14 Oct 2004 07:26:13 -0000 1.5 +++ XInclude.csproj 25 Oct 2004 19:32:39 -0000 1.6 @@ -145,6 +145,12 @@ BuildAction = "EmbeddedResource" /> <File + RelPath = "Common\XmlBaseAwareXmlTextReader.cs" + Link = "..\..\..\Common\v1\src\XmlBaseAwareXmlTextReader.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Common\XmlFirstLowerWriter.cs" Link = "..\..\..\Common\v1\src\XmlFirstLowerWriter.cs" SubType = "Code" Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- XIncludingReader.cs 22 Oct 2004 14:56:42 -0000 1.14 +++ XIncludingReader.cs 25 Oct 2004 19:32:39 -0000 1.15 @@ -2,12 +2,14 @@ using System; using System.Xml; +using System.Xml.Schema; using System.IO; using System.Net; using System.Text; using System.Security; using System.Collections; +using Mvp.Xml.Common; using Mvp.Xml.XPointer; #endregion @@ -78,10 +80,17 @@ XmlTextReader xtr = reader as XmlTextReader; if (xtr != null) { + XmlValidatingReader vr = new XmlValidatingReader(reader); + vr.ValidationType = ValidationType.None; + vr.EntityHandling = EntityHandling.ExpandEntities; + vr.ValidationEventHandler += new ValidationEventHandler( + ValidationCallback); _normalization = xtr.Normalization; _whiteSpaceHandling = xtr.WhitespaceHandling; + _reader = vr; } - _reader = reader; + else + _reader = reader; _nameTable = reader.NameTable; Init(); } @@ -91,7 +100,8 @@ /// specified URL. /// </summary> /// <param name="url">Document location.</param> - public XIncludingReader(string url) : this(new XmlTextReader(url)) {} + public XIncludingReader(string url) + : this(new XmlBaseAwareXmlTextReader(url)) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -100,14 +110,15 @@ /// <param name="url">Document location.</param> /// <param name="nt">Name table.</param> public XIncludingReader(string url, XmlNameTable nt) : - this(new XmlTextReader(url, nt)) {} + this(new XmlBaseAwareXmlTextReader(url, nt)) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with /// specified <c>TextReader</c> reader. /// </summary> /// <param name="reader"><c>TextReader</c>.</param> - public XIncludingReader(TextReader reader) : this(new XmlTextReader(reader)) {} + public XIncludingReader(TextReader reader) + : this(new XmlBaseAwareXmlTextReader(reader)) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -116,14 +127,15 @@ /// <param name="reader"><c>TextReader</c>.</param> /// <param name="nt">Nametable.</param> public XIncludingReader(TextReader reader, XmlNameTable nt) : - this(new XmlTextReader(reader, nt)) {} + this(new XmlBaseAwareXmlTextReader(reader, nt)) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with /// specified <c>Stream</c>. /// </summary> /// <param name="input"><c>Stream</c>.</param> - public XIncludingReader(Stream input) : this(new XmlTextReader(input)) {} + public XIncludingReader(Stream input) + : this(new XmlBaseAwareXmlTextReader(input)) {} /// <summary> /// Creates new instance of <c>XIncludingReader</c> class with @@ -132,7 +144,7 @@ /// <param name="input"><c>Stream</c>.</param> /// <param name="nt">Nametable</param> public XIncludingReader(Stream input, XmlNameTable nt) : - this(new XmlTextReader(input, nt)) {} + this(new XmlBaseAwareXmlTextReader(input, nt)) {} #endregion @@ -677,7 +689,10 @@ //Read internal reader bool baseRead = _reader.Read(); if (baseRead) - { + { + //No provision to preserve whitespace outside document element + if (_reader.Depth == 0 && _reader.NodeType == XmlNodeType.Whitespace) + return Read(); //If we are including and including reader is at 0 depth - //we are in top level included item _topLevel = (_readers.Count>0 && _reader.Depth == 0)? true : false; @@ -825,6 +840,12 @@ #region Private methods + //Dummy validation even handler + private static void ValidationCallback(object sender, ValidationEventArgs args) + { + //do nothing + } + /// <summary> /// Internal initializer. /// </summary> @@ -972,7 +993,7 @@ _reader = new XPointerReader(wRes.ResponseUri, stream, _nameTable, includeLocation.Fragment.Substring(1)); else { - _reader = new XmlTextReader(wRes.ResponseUri.AbsoluteUri, stream, _nameTable); + _reader = new XmlBaseAwareXmlTextReader(wRes.ResponseUri.AbsoluteUri, stream, _nameTable); ((XmlTextReader)_reader).Normalization = _normalization; ((XmlTextReader)_reader).WhitespaceHandling = _whiteSpaceHandling; } @@ -996,7 +1017,7 @@ //Ok, we accept Stream and XmlReader only XmlReader r; if (resource is Stream) - r = new XmlTextReader(includeLocation.AbsoluteUri, (Stream)resource, _nameTable); + r = new XmlBaseAwareXmlTextReader(includeLocation.AbsoluteUri, (Stream)resource, _nameTable); else if (resource is XmlReader) r = (XmlReader)resource; else |
From: Oleg T. <he...@us...> - 2004-10-25 18:18:16
|
Update of /cvsroot/mvp-xml/Common/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23399/v1/src Modified Files: Common.csproj Added Files: XmlBaseAwareXmlTextReader.cs Log Message: Added XmlBaseAwareXmltextReader impl and test. --- NEW FILE: XmlBaseAwareXmlTextReader.cs --- #region using using System; using System.Xml; using System.IO; #endregion namespace Mvp.Xml.Common { /// <summary> /// XmltextReader supporting XML Base. /// </summary> public class XmlBaseAwareXmlTextReader : XmlTextReader { #region private private Uri _baseUri = null; #endregion #region constructors /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given URI. /// </summary> public XmlBaseAwareXmlTextReader(string uri) : base(uri) { _baseUri = new Uri(base.BaseURI); } /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given URI and /// name table. /// </summary> public XmlBaseAwareXmlTextReader(string uri, XmlNameTable nt) : base(uri, nt) { _baseUri = new Uri(base.BaseURI); } /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given TextReader. /// </summary> public XmlBaseAwareXmlTextReader(TextReader reader) : base(reader) {} /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given uri and /// TextReader. /// </summary> public XmlBaseAwareXmlTextReader(string uri, TextReader reader) : base(uri, reader) { _baseUri = new Uri(base.BaseURI); } /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given TextReader /// and name table. /// </summary> public XmlBaseAwareXmlTextReader(TextReader reader, XmlNameTable nt) : base(reader, nt) {} /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given uri, name table /// and TextReader. /// </summary> public XmlBaseAwareXmlTextReader(string uri, TextReader reader, XmlNameTable nt) : base(uri, reader, nt) { _baseUri = new Uri(base.BaseURI); } /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given stream. /// </summary> public XmlBaseAwareXmlTextReader(Stream stream) : base(stream) {} /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given uri and stream. /// </summary> public XmlBaseAwareXmlTextReader(string uri, Stream stream) : base(uri, stream) { _baseUri = new Uri(base.BaseURI); } /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given stream /// and name table. /// </summary> public XmlBaseAwareXmlTextReader(Stream stream, XmlNameTable nt) : base(stream, nt) {} /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given stream, /// uri and name table. /// </summary> public XmlBaseAwareXmlTextReader(string uri, Stream stream, XmlNameTable nt) : base(uri, stream, nt) { _baseUri = new Uri(base.BaseURI); } #endregion #region XmlTextReader overrides /// <summary> /// See <see cref="XmlTextReader.BaseURI"/>. /// </summary> public override string BaseURI { get { return _baseUri==null? "" : _baseUri.AbsoluteUri; } } /// <summary> /// See <see cref="XmlTextReader.Read"/>. /// </summary> public override bool Read() { bool baseRead = base.Read(); if (baseRead && base.NodeType == XmlNodeType.Element && base.HasAttributes) { string baseAttr = GetAttribute("xml:base"); if (baseAttr == null) return baseRead; if (_baseUri == null) _baseUri = new Uri(baseAttr); else _baseUri = new Uri(_baseUri, baseAttr); } return baseRead; } #endregion } } Index: Common.csproj =================================================================== RCS file: /cvsroot/mvp-xml/Common/v1/src/Common.csproj,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Common.csproj 27 Sep 2004 16:27:12 -0000 1.1 +++ Common.csproj 25 Oct 2004 18:18:05 -0000 1.2 @@ -103,6 +103,11 @@ BuildAction = "EmbeddedResource" /> <File + RelPath = "XmlBaseAwareXmlTextReader.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "XmlFirstLowerWriter.cs" SubType = "Code" BuildAction = "Compile" |