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-11-07 14:50:49
|
Update of /cvsroot/mvp-xml/XPointer/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8583/v1/src Modified Files: XPointerReader.cs Log Message: Caching for XPathDocuments. Index: XPointerReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/XPointerReader.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- XPointerReader.cs 4 Nov 2004 15:49:44 -0000 1.8 +++ XPointerReader.cs 7 Nov 2004 14:50:34 -0000 1.9 @@ -27,7 +27,7 @@ //Nodes selected by xpointer private XPathNodeIterator _pointedNodes; //Document cache - private Hashtable _cache; + private static Hashtable _cache; /// <summary> @@ -41,27 +41,39 @@ //XPathNodeIterator is already at the first node _reader = new XPathNavigatorReader(_pointedNodes.Current); } + + private XPathDocument CreateAndCacheDocument(XmlReader r, bool supportSchemaDeterminedIDs) + { + string uri = r.BaseURI; + XmlValidatingReader vr = null; + if (supportSchemaDeterminedIDs) + { + vr = new IdAssuredValidatingReader(r); + vr.ValidationType = ValidationType.Auto; + } + else + { + vr = new XmlValidatingReader(r); + vr.ValidationType = ValidationType.None; + } + vr.EntityHandling = EntityHandling.ExpandEntities; + vr.ValidationEventHandler += new System.Xml.Schema.ValidationEventHandler(ValidationCallback); + XPathDocument doc = new XPathDocument(vr, XmlSpace.Preserve); + vr.Close(); + + lock(_cache) + { + if (!_cache.ContainsKey(uri)) + _cache.Add(uri, new WeakReference(doc)); + } + return doc; + } //Dummy validation even handler private static void ValidationCallback(object sender, ValidationEventArgs args) { //do nothing - } - - /// <summary> - /// - /// </summary> - /// <param name="uri"></param> - /// <returns></returns> - private XPathDocument GetCachedDocument(Uri uri) - { - WeakReference wr = (WeakReference)_cache[uri.AbsoluteUri]; - if (wr.IsAlive) - return (XPathDocument)wr.Target; - else - return null; - - } + } #endregion @@ -117,31 +129,66 @@ /// </summary> public XPointerReader(XmlReader reader, string xpointer) : this (reader, xpointer, false) {} - + /// <summary> /// Creates <c>XPointerReader</c> instance with given XmlReader and xpointer. /// Additionally sets a flag whether to support schema-determined IDs. /// </summary> public XPointerReader(XmlReader reader, string xpointer, bool supportSchemaDeterminedIDs) - { - XmlValidatingReader vr = null; - if (supportSchemaDeterminedIDs) + { + XPathDocument doc = null; + if (_cache == null) + _cache = new Hashtable(); + WeakReference wr = (WeakReference)_cache[reader.BaseURI]; + if (wr != null && wr.IsAlive) { - vr = new IdAssuredValidatingReader(reader); - vr.ValidationType = ValidationType.Auto; - } + doc = (XPathDocument)wr.Target; + reader.Close(); + } else { - vr = new XmlValidatingReader(reader); - vr.ValidationType = ValidationType.None; - } - vr.EntityHandling = EntityHandling.ExpandEntities; - vr.ValidationEventHandler += new System.Xml.Schema.ValidationEventHandler(ValidationCallback); - XPathDocument doc = new XPathDocument(vr, XmlSpace.Preserve); - vr.Close(); + //Not cached or GCollected + doc = CreateAndCacheDocument(reader, supportSchemaDeterminedIDs); + } Init(doc.CreateNavigator(), xpointer); } + /// <summary> + /// Creates <c>XPointerReader</c> instance with given + /// document's URI and content. + /// </summary> + /// <param name="uri">XML document's base URI</param> + /// <param name="content">XML document's content</param> + /// <param name="xpointer">XPointer pointer</param> + public XPointerReader(string uri, string content, string xpointer) + : this(uri, content, xpointer, false) {} + + /// <summary> + /// Creates <c>XPointerReader</c> instance with given + /// document's URI and content. + /// </summary> + /// <param name="uri">XML document's base URI</param> + /// <param name="content">XML document's content</param> + /// <param name="xpointer">XPointer pointer</param> + /// <param name="supportSchemaDeterminedIDs">A flag whether to + /// support schema-determined IDs</param> + public XPointerReader(string uri, string content, string xpointer, bool supportSchemaDeterminedIDs) + { + XPathDocument doc = null; + if (_cache == null) + _cache = new Hashtable(); + WeakReference wr = (WeakReference)_cache[uri]; + if (wr != null && wr.IsAlive) + doc = (XPathDocument)wr.Target; + else + { + //Not cached or GCollected + XmlTextReader r = new XmlTextReader(uri, new StringReader(content)); + doc = CreateAndCacheDocument(r, supportSchemaDeterminedIDs); + } + Init(doc.CreateNavigator(), xpointer); + } + #endregion #region XmlReader overrides |
From: Oleg T. <he...@us...> - 2004-11-07 14:50:09
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8371/v1/test/tests Added Files: caching.xml Log Message: Caching for the acquired infosets. --- NEW FILE: caching.xml --- (This appears to be a binary file; contents omitted.) |
From: Oleg T. <he...@us...> - 2004-11-07 14:50:09
|
Update of /cvsroot/mvp-xml/XInclude/v1/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8371/v1/test Modified Files: EntryPoint.cs XIncludeReaderTests.cs XIncludeTest.csproj Log Message: Caching for the acquired infosets. Index: XIncludeTest.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeTest.csproj,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- XIncludeTest.csproj 3 Nov 2004 14:17:37 -0000 1.15 +++ XIncludeTest.csproj 7 Nov 2004 14:49:57 -0000 1.16 @@ -143,6 +143,10 @@ BuildAction = "Compile" /> <File + RelPath = "results\caching.xml" + BuildAction = "Content" + /> + <File RelPath = "results\document.xml" BuildAction = "Content" /> @@ -195,6 +199,10 @@ BuildAction = "None" /> <File + RelPath = "tests\caching.xml" + BuildAction = "Content" + /> + <File RelPath = "tests\count.txt" BuildAction = "Content" /> Index: EntryPoint.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/EntryPoint.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- EntryPoint.cs 3 Nov 2004 14:17:37 -0000 1.15 +++ EntryPoint.cs 7 Nov 2004 14:49:57 -0000 1.16 @@ -17,7 +17,7 @@ //XIncludeSyntaxTests rt = new XIncludeSyntaxTests(); try { - rt.NoBaseURITest(); + rt.CachingTest(); } catch (Exception e) { Index: XIncludeReaderTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeReaderTests.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- XIncludeReaderTests.cs 3 Nov 2004 14:17:37 -0000 1.16 +++ XIncludeReaderTests.cs 7 Nov 2004 14:49:57 -0000 1.17 @@ -364,6 +364,15 @@ while (xir.Read()); } + /// <summary> + /// Caching test. + /// </summary> + [Test] + public void CachingTest() + { + RunAndCompare("../../tests/caching.xml", "../../results/caching.xml"); + } + } public class TestResolver : XmlUrlResolver |
From: Oleg T. <he...@us...> - 2004-11-07 14:50:06
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/results In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8371/v1/test/results Added Files: caching.xml Log Message: Caching for the acquired infosets. --- NEW FILE: caching.xml --- (This appears to be a binary file; contents omitted.) |
From: Oleg T. <he...@us...> - 2004-11-07 14:50:06
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8371/v1/src Modified Files: TextIncludingReader.cs XIncludingReader.cs Log Message: Caching for the acquired infosets. Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- XIncludingReader.cs 3 Nov 2004 14:17:36 -0000 1.27 +++ XIncludingReader.cs 7 Nov 2004 14:49:56 -0000 1.28 @@ -65,6 +65,8 @@ private bool _exposeTextAsCDATA; //Top-level included item has different xml:lang private bool _differentLang = false; + //Acquired infosets cache + private static Hashtable _cache; #endregion #region Constructors @@ -979,7 +981,7 @@ /// <summary> /// Fetches resource by URI. /// </summary> - internal static Stream GetResource(string href, Uri includeLocation, + internal static Stream GetResource(string includeLocation, string accept, string acceptLanguage, out WebResponse response) { WebRequest wReq; @@ -989,11 +991,11 @@ } catch (NotSupportedException nse) { - throw new ResourceException(SR.GetString("URISchemaNotSupported", href), nse); + throw new ResourceException(SR.GetString("URISchemaNotSupported", includeLocation), nse); } catch (SecurityException se) { - throw new ResourceException(SR.GetString("SecurityException", href), se); + throw new ResourceException(SR.GetString("SecurityException", includeLocation), se); } //Add accept headers if this is HTTP request HttpWebRequest httpReq = wReq as HttpWebRequest; @@ -1021,7 +1023,7 @@ } catch (WebException we) { - throw new ResourceException(SR.GetString("ResourceError", href), we); + throw new ResourceException(SR.GetString("ResourceError", includeLocation), we); } return response.GetResponseStream(); } @@ -1296,12 +1298,67 @@ } /// <summary> - /// Creates a XmlReader over acquired infoset. + /// Creates acquired infoset. + /// </summary> + private string CreateAcquiredInfoset(Uri includeLocation) + { + if (_cache == null) + _cache = new Hashtable(); + WeakReference wr = (WeakReference)_cache[includeLocation.AbsoluteUri]; + if (wr != null && wr.IsAlive) + { + return (string)wr.Target; + } + else + { + //Not cached or GCollected + WebResponse wRes; + Stream stream = GetResource(includeLocation.AbsoluteUri, + _reader.GetAttribute(_keywords.Accept), + _reader.GetAttribute(_keywords.AcceptLanguage), out wRes); + XIncludingReader xir = new XIncludingReader(wRes.ResponseUri.AbsoluteUri, stream, _nameTable); + xir.Normalization = _normalization; + xir.WhitespaceHandling = _whiteSpaceHandling; + StringWriter sw = new StringWriter(); + XmlTextWriter w = new XmlTextWriter(sw); + try + { + while (xir.Read()) + w.WriteNode(xir, false); + } + finally + { + if (xir != null) + xir.Close(); + if (w != null) + w.Close(); + } + string content = sw.ToString(); + lock(_cache) + { + if (!_cache.ContainsKey(includeLocation.AbsoluteUri)) + _cache.Add(includeLocation.AbsoluteUri, new WeakReference(content)); + } + return content; + } + } + + /// <summary> + /// Creates acquired infoset. /// </summary> /// <param name="reader">Source reader</param> - private XmlReader CreateAcquiredInfoset(XmlReader reader) + private string CreateAcquiredInfoset(Uri includeLocation, TextReader reader) { - string uri = reader.BaseURI; + return CreateAcquiredInfoset( + new XmlBaseAwareXmlTextReader(includeLocation.AbsoluteUri, reader, _nameTable)); + } + + /// <summary> + /// Creates acquired infoset. + /// </summary> + /// <param name="reader">Source reader</param> + private string CreateAcquiredInfoset(XmlReader reader) + { //TODO: Try to stream out this stuff XIncludingReader xir = new XIncludingReader(reader); StringWriter sw = new StringWriter(); @@ -1318,7 +1375,7 @@ if (w != null) w.Close(); } - return new XmlTextReader(uri, new StringReader(sw.ToString())); + return sw.ToString(); } /// <summary> @@ -1336,23 +1393,24 @@ 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) { + //Push current reader to the stack + _readers.Push(_reader); //XPointers should be resolved against the acquired infoset, - //not the source infoset - _reader = new XPointerReader( - CreateAcquiredInfoset( - new XIncludingReader(wRes.ResponseUri.AbsoluteUri, stream)), - xpointer); + //not the source infoset + _reader = new XPointerReader(includeLocation.AbsoluteUri, + CreateAcquiredInfoset(includeLocation), + xpointer); } else - { + { + WebResponse wRes; + Stream stream = GetResource(includeLocation.AbsoluteUri, + _reader.GetAttribute(_keywords.Accept), + _reader.GetAttribute(_keywords.AcceptLanguage), out wRes); + //Push current reader to the stack + _readers.Push(_reader); XmlTextReader r = new XmlBaseAwareXmlTextReader(wRes.ResponseUri.AbsoluteUri, stream, _nameTable); r.Normalization = _normalization; r.WhitespaceHandling = _whiteSpaceHandling; @@ -1387,15 +1445,15 @@ { //XPointers should be resolved against the acquired infoset, //not the source infoset - _reader = new XPointerReader( - CreateAcquiredInfoset( - new XIncludingReader(includeLocation.AbsoluteUri, (TextReader)resource)), - xpointer); + _reader = new XPointerReader(includeLocation.AbsoluteUri, + CreateAcquiredInfoset(includeLocation, (TextReader)resource), + xpointer); } else if (resource is XmlReader) { - _reader = new XPointerReader( - CreateAcquiredInfoset((XmlReader)resource), xpointer); + XmlReader r = (XmlReader)resource; + _reader = new XPointerReader(r.BaseURI, + CreateAcquiredInfoset(r), xpointer); } else { Index: TextIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/TextIncludingReader.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- TextIncludingReader.cs 2 Nov 2004 14:31:56 -0000 1.7 +++ TextIncludingReader.cs 7 Nov 2004 14:49:56 -0000 1.8 @@ -210,7 +210,7 @@ { WebResponse wRes; Stream stream = XIncludingReader.GetResource(_includeLocation.AbsoluteUri, - _includeLocation, _accept, _acceptLanguage, out wRes); + _accept, _acceptLanguage, out wRes); StreamReader reader; /* According to the spec, encoding should be determined as follows: * external encoding information, if available, otherwise |
From: Oleg T. <he...@us...> - 2004-11-04 15:49:54
|
Update of /cvsroot/mvp-xml/XPointer/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27385/v1/src Modified Files: XPointerException.cs XPointerReader.cs Log Message: Index: XPointerException.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/XPointerException.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XPointerException.cs 28 Sep 2004 09:10:00 -0000 1.1 +++ XPointerException.cs 4 Nov 2004 15:49:44 -0000 1.2 @@ -9,7 +9,7 @@ /// <summary> /// Generic XPointer exception. /// </summary> - public abstract class XPointerException : ApplicationException + public abstract class XPointerException : Exception { public XPointerException(string message) : base(message) {} public XPointerException(string message, Exception innerException) Index: XPointerReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v1/src/XPointerReader.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- XPointerReader.cs 31 Oct 2004 08:07:15 -0000 1.7 +++ XPointerReader.cs 4 Nov 2004 15:49:44 -0000 1.8 @@ -24,7 +24,11 @@ //Underlying reader private XmlReader _reader; + //Nodes selected by xpointer private XPathNodeIterator _pointedNodes; + //Document cache + private Hashtable _cache; + /// <summary> /// Initializes the <c>XPointerReader</c>. @@ -44,6 +48,21 @@ //do nothing } + /// <summary> + /// + /// </summary> + /// <param name="uri"></param> + /// <returns></returns> + private XPathDocument GetCachedDocument(Uri uri) + { + WeakReference wr = (WeakReference)_cache[uri.AbsoluteUri]; + if (wr.IsAlive) + return (XPathDocument)wr.Target; + else + return null; + + } + #endregion #region constructors @@ -68,7 +87,7 @@ /// Creates <c>XPointerReader</c> instance with given uri, stream, nametable and xpointer. /// </summary> public XPointerReader(Uri uri, Stream stream, XmlNameTable nt, string xpointer) - : this (new XmlTextReader(uri.AbsoluteUri, stream, nt), xpointer) {} + : this (uri, stream, nt, xpointer, false) {} /// <summary> /// Creates <c>XPointerReader</c> instance with given uri, stream, nametable and xpointer. |
From: Oleg T. <he...@us...> - 2004-11-04 15:47:37
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26907/v1/src Modified Files: XIncludeException.cs Log Message: Index: XIncludeException.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludeException.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- XIncludeException.cs 3 Nov 2004 12:55:39 -0000 1.7 +++ XIncludeException.cs 4 Nov 2004 15:47:25 -0000 1.8 @@ -9,7 +9,7 @@ /// <summary> /// Generic XInclude exception. /// </summary> - public abstract class XIncludeException : ApplicationException { + public abstract class XIncludeException : Exception { public XIncludeException(string message) : base(message) {} public XIncludeException(string message, Exception innerException) : base(message, innerException) {} |
From: Oleg T. <he...@us...> - 2004-11-03 14:17:55
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17141/v1/src Modified Files: XIncludingReader.cs Log Message: Fixed empty base URI bug. Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- XIncludingReader.cs 3 Nov 2004 12:55:41 -0000 1.26 +++ XIncludingReader.cs 3 Nov 2004 14:17:36 -0000 1.27 @@ -9,6 +9,7 @@ using System.Text; using System.Security; using System.Collections; +using System.Reflection; using Mvp.Xml.Common; using Mvp.Xml.Common.XPath; @@ -93,7 +94,13 @@ _nameTable = reader.NameTable; _keywords = new XIncludeKeywords(NameTable); - _topBaseUri = new Uri(_reader.BaseURI); + if (_reader.BaseURI != "") + _topBaseUri = new Uri(_reader.BaseURI); + else + { + _relativeBaseUri = false; + _topBaseUri = new Uri(Assembly.GetExecutingAssembly().Location); + } _readers = new Stack(); _state = XIncludingReaderState.Default; } @@ -641,10 +648,8 @@ case XIncludingReaderState.ExposingXmlBaseAttr: case XIncludingReaderState.ExposingXmlBaseAttrValue: if (_reader.BaseURI == String.Empty) - { - //No Base URI? Use previous one's. - //TODO:How come? - return ((XmlReader)_readers.Peek()).BaseURI; + { + return String.Empty; } if (_relativeBaseUri) { @@ -1095,10 +1100,11 @@ Uri includeLocation; try { - if (_xmlResolver == null) - includeLocation = new Uri(new Uri(_reader.BaseURI), href, false); + Uri baseURI = _reader.BaseURI==""? _topBaseUri : new Uri(_reader.BaseURI); + if (_xmlResolver == null) + includeLocation = new Uri(baseURI, href, false); else - includeLocation = _xmlResolver.ResolveUri(new Uri(_reader.BaseURI), href); + includeLocation = _xmlResolver.ResolveUri(baseURI, href); } catch(UriFormatException ufe) { @@ -1444,12 +1450,14 @@ /// </summary> private void CheckLoops(Uri url, string xpointer) { - //Check circular inclusion - if (new Uri(_reader.BaseURI).Equals(url)) + //Check circular inclusion + Uri baseUri = _reader.BaseURI==""? _topBaseUri : new Uri(_reader.BaseURI); + if (baseUri.Equals(url)) ThrowCircularInclusionError(_reader, url); foreach (XmlReader r in _readers) - { - if (new Uri(r.BaseURI).Equals(url)) + { + baseUri = r.BaseURI==""? _topBaseUri : new Uri(r.BaseURI); + if (baseUri.Equals(url)) ThrowCircularInclusionError(_reader, url); } } |
From: Oleg T. <he...@us...> - 2004-11-03 14:17:55
|
Update of /cvsroot/mvp-xml/XInclude/v1/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17141/v1/test Modified Files: EntryPoint.cs XIncludeReaderTests.cs XIncludeTest.csproj Log Message: Fixed empty base URI bug. Index: XIncludeTest.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeTest.csproj,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- XIncludeTest.csproj 3 Nov 2004 13:09:35 -0000 1.14 +++ XIncludeTest.csproj 3 Nov 2004 14:17:37 -0000 1.15 @@ -263,6 +263,10 @@ BuildAction = "Content" /> <File + RelPath = "tests\test-Martin.xml" + BuildAction = "Content" + /> + <File RelPath = "tests\twofallbacks.xml" BuildAction = "Content" /> Index: EntryPoint.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/EntryPoint.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- EntryPoint.cs 3 Nov 2004 12:55:46 -0000 1.14 +++ EntryPoint.cs 3 Nov 2004 14:17:37 -0000 1.15 @@ -9,15 +9,15 @@ { public static void Main() { - //XIncludeReaderTests rt = new XIncludeReaderTests(); + XIncludeReaderTests rt = new XIncludeReaderTests(); //LTG_Edinburgh_UnivTests rt = new LTG_Edinburgh_UnivTests(); - NISTTests rt = new NISTTests(); + //NISTTests rt = new NISTTests(); //Elliotte_Rusty_HaroldTests rt = new Elliotte_Rusty_HaroldTests(); //FourThoughtTests rt = new FourThoughtTests(); //XIncludeSyntaxTests rt = new XIncludeSyntaxTests(); try { - rt.Nist_include_24(); + rt.NoBaseURITest(); } catch (Exception e) { Index: XIncludeReaderTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeReaderTests.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- XIncludeReaderTests.cs 3 Nov 2004 13:09:35 -0000 1.15 +++ XIncludeReaderTests.cs 3 Nov 2004 14:17:37 -0000 1.16 @@ -349,6 +349,21 @@ RunAndCompare("../../tests/test-Martin.xml", "../../results/test-Martin.xml"); } + /// <summary> + /// Test for string as input (no base URI) + /// </summary> + [Test] + [ExpectedException(typeof(FatalResourceException))] + public void NoBaseURITest() + { + StreamReader sr = new StreamReader("../../tests/document.xml"); + string xml = sr.ReadToEnd(); + sr.Close(); + XIncludingReader xir = new XIncludingReader(new StringReader(xml)); + XmlTextWriter w = new XmlTextWriter(Console.Out); + while (xir.Read()); + } + } public class TestResolver : XmlUrlResolver |
From: Oleg T. <he...@us...> - 2004-11-03 13:09:50
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2798/v1/test/tests Added Files: table.xml test-Martin.xml Log Message: Test for some old bug. --- NEW FILE: table.xml --- <HTML> <BODY> <TABLE> <CAPTION>MyCaption</CAPTION> </TABLE> </BODY> </HTML> --- NEW FILE: test-Martin.xml --- <?xml version="1.0" encoding="UTF-8"?> <myXml xmlns:xi="http://www.w3.org/2001/XInclude">> <otherStuff> </otherStuff> <!--WORKS (found node)--> <xi:include href="table.xml" xpointer="xpointer(//HTML/BODY/TABLE[starts-with(CAPTION,'M')] )"> <xi:fallback> node not found </xi:fallback> </xi:include> <!--WORKS CORRECTLY (found node)--> <xi:include href="table.xml" xpointer="xpointer(//HTML/BODY/TABLE)"> <xi:fallback> node not found </xi:fallback> </xi:include> <!--WORKS CORRECTLY(fallback, node not found)--> <xi:include href="table.xml" xpointer="xpointer(//HTML/BODY/STUFF)"> <xi:fallback> node not found </xi:fallback> </xi:include> <!--DOES NOT WORK CORRECTLY (node does not exist, should do fallback but throws CircularReferenceException--> <xi:include href="table.xml" xpointer="xpointer(//HTML/BODY/TABLE[starts-with(STUFF,'M')] )"> <xi:fallback> node not found </xi:fallback> </xi:include> <!--DOES NOT WORK CORRECTLY (node does not exist, should do fallback but throws CircularReferenceException--> <xi:include href="table.xml" xpointer="xpointer(//HTML/BODY/STUFF[starts-with(CAPTION,'M')] )"> <xi:fallback> node not found </xi:fallback> </xi:include> <moreXML/> </myXml> |
From: Oleg T. <he...@us...> - 2004-11-03 13:09:50
|
Update of /cvsroot/mvp-xml/XInclude/v1/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2798/v1/test Modified Files: XIncludeReaderTests.cs XIncludeTest.csproj Log Message: Test for some old bug. Index: XIncludeTest.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeTest.csproj,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- XIncludeTest.csproj 3 Nov 2004 12:55:46 -0000 1.13 +++ XIncludeTest.csproj 3 Nov 2004 13:09:35 -0000 1.14 @@ -175,6 +175,10 @@ BuildAction = "Content" /> <File + RelPath = "results\test-Martin.xml" + BuildAction = "Content" + /> + <File RelPath = "results\working_example.xml" BuildAction = "Content" /> @@ -251,6 +255,10 @@ BuildAction = "Content" /> <File + RelPath = "tests\table.xml" + BuildAction = "Content" + /> + <File RelPath = "tests\test2.xml" BuildAction = "Content" /> Index: XIncludeReaderTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeReaderTests.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- XIncludeReaderTests.cs 3 Nov 2004 12:55:46 -0000 1.14 +++ XIncludeReaderTests.cs 3 Nov 2004 13:09:35 -0000 1.15 @@ -340,6 +340,15 @@ RunAndCompare("../../tests/resolver.xml", "../../results/resolver.xml", false, new TestResolver()); } + /// <summary> + /// Test for a bug discovered by Martin Wickett. + /// </summary> + [Test] + public void Test_Martin() + { + RunAndCompare("../../tests/test-Martin.xml", "../../results/test-Martin.xml"); + } + } public class TestResolver : XmlUrlResolver |
From: Oleg T. <he...@us...> - 2004-11-03 13:09:49
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/results In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2798/v1/test/results Added Files: test-Martin.xml Log Message: Test for some old bug. --- NEW FILE: test-Martin.xml --- <?xml version="1.0" encoding="utf-8"?> <myXml xmlns:xi="http://www.w3.org/2001/XInclude">> <otherStuff> </otherStuff> <!--WORKS (found node)--> <TABLE xml:base="table.xml"> <CAPTION>MyCaption</CAPTION> </TABLE> <!--WORKS CORRECTLY (found node)--> <TABLE xml:base="table.xml"> <CAPTION>MyCaption</CAPTION> </TABLE> <!--WORKS CORRECTLY(fallback, node not found)--> node not found <!--DOES NOT WORK CORRECTLY (node does not exist, should do fallback but throws CircularReferenceException--> node not found <!--DOES NOT WORK CORRECTLY (node does not exist, should do fallback but throws CircularReferenceException--> node not found <moreXML /> </myXml> |
From: Oleg T. <he...@us...> - 2004-11-03 13:00:05
|
Update of /cvsroot/mvp-xml/WebSite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv789 Modified Files: index.html upload.cmd Log Message: Fixed some mistakes. Index: index.html =================================================================== RCS file: /cvsroot/mvp-xml/WebSite/index.html,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- index.html 1 Nov 2004 17:42:03 -0000 1.6 +++ index.html 3 Nov 2004 12:59:55 -0000 1.7 @@ -27,7 +27,7 @@ <p>The Mvp.Xml project consists of several modules listed below.<br> </p> <ul> - <li><a href="Common/index.html">Common</a> module</li> + <li><a href="common/index.html">Common</a> module</li> <li><a href="xinclude/index.html">XInclude.NET</a> module<br> </li> <li><a href="xpointer/index.html">XPointer.NET</a> module</li> Index: upload.cmd =================================================================== RCS file: /cvsroot/mvp-xml/WebSite/upload.cmd,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- upload.cmd 1 Nov 2004 19:34:25 -0000 1.2 +++ upload.cmd 3 Nov 2004 12:59:55 -0000 1.3 @@ -1,8 +1,8 @@ @echo off set USER=helgy rem You need to install PSCP from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html and have it on your %path% -rem pscp index.html %USER%@shell.sourceforge.net:/home/groups/m/mv/mvp-xml/htdocs -rem pscp style.css %USER%@shell.sourceforge.net:/home/groups/m/mv/mvp-xml/htdocs +pscp index.html %USER%@shell.sourceforge.net:/home/groups/m/mv/mvp-xml/htdocs +pscp style.css %USER%@shell.sourceforge.net:/home/groups/m/mv/mvp-xml/htdocs pscp common/index.html %USER%@shell.sourceforge.net:/home/groups/m/mv/mvp-xml/htdocs/common pscp xinclude/index.html %USER%@shell.sourceforge.net:/home/groups/m/mv/mvp-xml/htdocs/xinclude pscp xpointer/index.html %USER%@shell.sourceforge.net:/home/groups/m/mv/mvp-xml/htdocs/xpointer \ No newline at end of file |
From: Oleg T. <he...@us...> - 2004-11-03 12:58:17
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/results In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv358/v1/test/results Added Files: resolver.xml Log Message: Test case for a custom resolver. --- NEW FILE: resolver.xml --- <?xml version="1.0" encoding="utf-8"?> <document xmlns:xi="http://www.w3.org/2001/XInclude"> <stream> <document xmlns:xi="http://www.w3.org/2003/XInclude" xml:base="stream://whatever/"> <p>120 Mz is adequate for an average home user.</p> <!-- comment --> <?pi foo ?> <disclaimer xml:base="disclaimer.xml"> <p>The opinions represented herein represent those of the individual and should not be interpreted as official policy endorsed by this organization.</p> </disclaimer> foo </document> </stream> <textreader> <text attr="val" xml:base="textreader://whatever/">From custom resolver (as TextReader)</text> </textreader> <xmlreader> <text attr="val" xml:base="xmlreader://whatever/">From custom resolver (as XmlReader)</text> </xmlreader> <p>Filtered:</p> From custom resolver (as TextReader)</document> |
From: Oleg T. <he...@us...> - 2004-11-03 12:56:22
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32016/v1/src Modified Files: XIncludeException.cs XIncludingReader.cs Log Message: Optimizations/Simplifications. Index: XIncludeException.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludeException.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- XIncludeException.cs 26 Oct 2004 19:28:41 -0000 1.6 +++ XIncludeException.cs 3 Nov 2004 12:55:39 -0000 1.7 @@ -36,24 +36,7 @@ public FatalException(string message) : base(message) {} public FatalException(string message, Exception innerException) : base(message, innerException) {} - } - - /// <summary> - /// Missing both "href" and "xpointer" attributes exception. - /// </summary> - public class MissingHrefAndXpointerException : FatalException { - public MissingHrefAndXpointerException(string message) : base(message) {} - } - - /// <summary> - /// Unknown "parse" attribute value exception. - /// </summary> - public class UnknownParseAttributeValueException : FatalException { - public UnknownParseAttributeValueException(string attrValue) : - base(SR.GetString("UnknownParseAttrValue", attrValue)) {} - public UnknownParseAttributeValueException(string attrValue, string uri, int line, int position) : - base(SR.GetString("UnknownParseAttrValueLong", attrValue, uri, line, position)) {} - } + } /// <summary> /// Non XML character in a document to include exception. @@ -112,14 +95,5 @@ { 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.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- XIncludingReader.cs 2 Nov 2004 16:49:39 -0000 1.25 +++ XIncludingReader.cs 3 Nov 2004 12:55:41 -0000 1.26 @@ -235,9 +235,7 @@ { if (_state == XIncludingReaderState.Default) return _reader.IsDefault; - else - //TODO: It might be wrong if xml:base or xml:lang - //are default + else return false; } } @@ -423,7 +421,7 @@ else if (XIncludeKeywords.Equals(name, _keywords.Lang) && XIncludeKeywords.Equals(namespaceURI, _keywords.XmlNamespace)) return _reader.XmlLang; - } + } return _reader.GetAttribute(name, namespaceURI); } @@ -460,7 +458,7 @@ _state = XIncludingReaderState.ExposingXmlLangAttr; return true; } - } + } return _reader.MoveToAttribute(name); } @@ -515,7 +513,8 @@ } } - return _reader.MoveToFirstAttribute(); + else + return _reader.MoveToFirstAttribute(); } /// <summary>See <see cref="XmlReader.MoveToNextAttribute"/></summary> @@ -566,7 +565,8 @@ } } - return _reader.MoveToNextAttribute(); + else + return _reader.MoveToNextAttribute(); } /// <summary>See <see cref="XmlReader.ReadAttributeValue"/></summary> @@ -642,7 +642,8 @@ case XIncludingReaderState.ExposingXmlBaseAttrValue: if (_reader.BaseURI == String.Empty) { - //No Base URI? Use previous one's. + //No Base URI? Use previous one's. + //TODO:How come? return ((XmlReader)_readers.Peek()).BaseURI; } if (_relativeBaseUri) @@ -755,8 +756,9 @@ if (baseRead) { //If we are including and including reader is at 0 depth - - //we are in top level included item + //we are at a top level included item _topLevel = (_readers.Count>0 && _reader.Depth == 0)? true : false; + //Check if included item has different language if (_topLevel) _differentLang = AreDifferentLangs(_reader.XmlLang, ((XmlReader)_readers.Peek()).XmlLang); if (_topLevel && _reader.NodeType == XmlNodeType.Attribute) @@ -1040,13 +1042,13 @@ IXmlLineInfo li = _reader as IXmlLineInfo; if (li != null && li.HasLineInfo()) { - throw new MissingHrefAndXpointerException( + throw new XIncludeSyntaxError( SR.GetString("MissingHrefAndXpointerExceptionLong", _reader.BaseURI.ToString(), li.LineNumber, li.LinePosition)); } else - throw new MissingHrefAndXpointerException( + throw new XIncludeSyntaxError( SR.GetString("MissingHrefAndXpointerException", _reader.BaseURI.ToString())); } @@ -1072,12 +1074,15 @@ IXmlLineInfo li2 = _reader as IXmlLineInfo; if (li2 != null && li2.HasLineInfo()) { - throw new UnknownParseAttributeValueException(parse, + throw new XIncludeSyntaxError( + SR.GetString("UnknownParseAttrValueLong", + parse, _reader.BaseURI.ToString(), - li2.LineNumber, li2.LinePosition); + li2.LineNumber, li2.LinePosition)); } else - throw new UnknownParseAttributeValueException(parse); + throw new XIncludeSyntaxError( + SR.GetString("UnknownParseAttrValue", parse)); } /// <summary> @@ -1282,33 +1287,7 @@ private bool AreDifferentLangs(string lang1, string lang2) { return lang1.ToLower() != lang2.ToLower(); - } - - /// <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); - try - { - while (xir.Read()) - w.WriteNode(xir, false); - } - finally - { - if (xir != null) - xir.Close(); - if (w != null) - w.Close(); - } - return new XmlTextReader(uri, new StringReader(sw.ToString())); - } + } /// <summary> /// Creates a XmlReader over acquired infoset. @@ -1347,7 +1326,7 @@ Uri includeLocation = ResolveHref(href); CheckLoops(includeLocation, xpointer); if (includeLocation.Fragment != String.Empty) - throw new FragmentIdentifierInHrefAttribute(); + throw new XIncludeSyntaxError(SR.FragmentIDInHref); if (_xmlResolver == null) { //No custom resolver @@ -1362,7 +1341,9 @@ //XPointers should be resolved against the acquired infoset, //not the source infoset _reader = new XPointerReader( - CreateAcquiredInfoset(wRes.ResponseUri.AbsoluteUri, stream), xpointer); + CreateAcquiredInfoset( + new XIncludingReader(wRes.ResponseUri.AbsoluteUri, stream)), + xpointer); } else { @@ -1391,16 +1372,19 @@ //Push current reader to the stack _readers.Push(_reader); - //Ok, we accept Stream and XmlReader only + //Ok, we accept Stream, TextReader and XmlReader only + if (resource is Stream) + resource = new StreamReader((Stream)resource); if (xpointer != null) { - if (resource is Stream) + if (resource is TextReader) { //XPointers should be resolved against the acquired infoset, //not the source infoset _reader = new XPointerReader( - CreateAcquiredInfoset(includeLocation.AbsoluteUri, (Stream)resource), - xpointer); + CreateAcquiredInfoset( + new XIncludingReader(includeLocation.AbsoluteUri, (TextReader)resource)), + xpointer); } else if (resource is XmlReader) { @@ -1418,8 +1402,8 @@ else { //No XPointer - if (resource is Stream) - _reader = new XmlBaseAwareXmlTextReader(includeLocation.AbsoluteUri, (Stream)resource, _nameTable); + if (resource is TextReader) + _reader = new XmlBaseAwareXmlTextReader(includeLocation.AbsoluteUri, (TextReader)resource, _nameTable); else if (resource is XmlReader) _reader = (XmlReader)resource; else |
Update of /cvsroot/mvp-xml/XInclude/v1/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32016/v1/test Modified Files: Elliotte_Rusty_HaroldTests.cs EntryPoint.cs NistTests.cs XIncludeReaderTests.cs XIncludeSyntaxTests.cs XIncludeTest.csproj Log Message: Optimizations/Simplifications. Index: XIncludeTest.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeTest.csproj,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- XIncludeTest.csproj 2 Nov 2004 14:31:57 -0000 1.12 +++ XIncludeTest.csproj 3 Nov 2004 12:55:46 -0000 1.13 @@ -171,6 +171,10 @@ BuildAction = "Content" /> <File + RelPath = "results\resolver.xml" + BuildAction = "Content" + /> + <File RelPath = "results\working_example.xml" BuildAction = "Content" /> Index: EntryPoint.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/EntryPoint.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- EntryPoint.cs 2 Nov 2004 14:31:57 -0000 1.13 +++ EntryPoint.cs 3 Nov 2004 12:55:46 -0000 1.14 @@ -9,15 +9,15 @@ { public static void Main() { - XIncludeReaderTests rt = new XIncludeReaderTests(); + //XIncludeReaderTests rt = new XIncludeReaderTests(); //LTG_Edinburgh_UnivTests rt = new LTG_Edinburgh_UnivTests(); - //NISTTests rt = new NISTTests(); + NISTTests rt = new NISTTests(); //Elliotte_Rusty_HaroldTests rt = new Elliotte_Rusty_HaroldTests(); //FourThoughtTests rt = new FourThoughtTests(); //XIncludeSyntaxTests rt = new XIncludeSyntaxTests(); try { - rt.XmlLangTest(); + rt.Nist_include_24(); } catch (Exception e) { Index: XIncludeSyntaxTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeSyntaxTests.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- XIncludeSyntaxTests.cs 1 Nov 2004 05:44:44 -0000 1.4 +++ XIncludeSyntaxTests.cs 3 Nov 2004 12:55:46 -0000 1.5 @@ -22,7 +22,7 @@ /// No href and no xpointer attribute. /// </summary> [Test] - [ExpectedException(typeof(MissingHrefAndXpointerException))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void NoHrefAndNoXPointerAttributes() { XIncludingReader xir = new XIncludingReader("../../tests/nohref.xml"); @@ -58,7 +58,7 @@ /// Unknown value of parse attribute. /// </summary> [Test] - [ExpectedException(typeof(UnknownParseAttributeValueException))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void UnknownParseAttribute() { XIncludingReader xir = new XIncludingReader("../../tests/unknownparseattr.xml"); Index: Elliotte_Rusty_HaroldTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/Elliotte_Rusty_HaroldTests.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Elliotte_Rusty_HaroldTests.cs 2 Nov 2004 14:31:57 -0000 1.7 +++ Elliotte_Rusty_HaroldTests.cs 3 Nov 2004 12:55:42 -0000 1.8 @@ -306,7 +306,7 @@ /// A fallback element in an included document contains an include element with a parse attribute with an illegal value. /// </summary> [Test] - [ExpectedException(typeof(UnknownParseAttributeValueException))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_23() { RunAndCompare("metafallbacktest3.xml", ""); @@ -318,7 +318,7 @@ /// A fallback element in an included document contains an include element with neither an xpointer nor an href attribute. /// </summary> [Test] - [ExpectedException(typeof(MissingHrefAndXpointerException))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_24() { RunAndCompare("metafallbacktest4.xml", ""); @@ -331,7 +331,7 @@ /// A fallback element in an included document contains an include element whose href attribute has a fragment ID. /// </summary> [Test] - [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_25() { RunAndCompare("metafallbacktestwithfragmentid.xml", ""); @@ -644,7 +644,7 @@ /// Include element is missing an href and xpointer attribute /// </summary> [Test] - [ExpectedException(typeof(MissingHrefAndXpointerException))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_51() { RunAndCompare("missinghref.xml", ""); @@ -656,7 +656,7 @@ /// parse attribute must have value xml or text /// </summary> [Test] - [ExpectedException(typeof(UnknownParseAttributeValueException))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_52() { RunAndCompare("badparseattribute.xml", ""); @@ -885,7 +885,7 @@ /// Syntax error in an XPointer is a resource error; and fatal because there's no fallback /// </summary> [Test] - [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_71() { RunAndCompare("badxptr2.xml", ""); @@ -1030,7 +1030,7 @@ /// href attribute with fragment ID is a fatal error even when there's an xpointer attribute /// </summary> [Test] - [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_83() { RunAndCompare("xpointeroverridesfragmentid.xml", ""); @@ -1042,7 +1042,7 @@ /// href attribute with fragment ID is a fatal error /// </summary> [Test] - [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_84() { RunAndCompare("ignoresfragmentid.xml", ""); @@ -1066,7 +1066,7 @@ /// syntax of fragment IDs from RFC 2396. /// </summary> [Test] - [ExpectedException(typeof(FragmentIdentifierInHrefAttribute))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_86() { RunAndCompare("meaninglessfragmentid.xml", ""); @@ -1168,7 +1168,7 @@ /// Included document has an include element with neither href nor xpointer attribute /// </summary> [Test] - [ExpectedException(typeof(MissingHrefAndXpointerException))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void harold_94() { RunAndCompare("toplevel.xml", ""); Index: XIncludeReaderTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeReaderTests.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- XIncludeReaderTests.cs 2 Nov 2004 14:31:57 -0000 1.13 +++ XIncludeReaderTests.cs 3 Nov 2004 12:55:46 -0000 1.14 @@ -29,16 +29,25 @@ { RunAndCompare(source, result, false); } - + /// <summary> /// Utility method for running tests. /// </summary> public static void RunAndCompare(string source, string result, bool textAsCDATA) + { + RunAndCompare(source, result, textAsCDATA, null); + } + + /// <summary> + /// Utility method for running tests. + /// </summary> + public static void RunAndCompare(string source, string result, bool textAsCDATA, XmlResolver resolver) { XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; XIncludingReader xir = new XIncludingReader(source); - + if (resolver != null) + xir.XmlResolver = resolver; xir.ExposeTextInclusionsAsCDATA = textAsCDATA; // while (xir.Read()) // { @@ -70,6 +79,7 @@ while (r2.NodeType == XmlNodeType.XmlDeclaration || r2.NodeType == XmlNodeType.Whitespace) r2.Read(); + Assert.AreEqual(r1.XmlLang, r2.XmlLang); switch (r1.NodeType) { case XmlNodeType.Attribute: @@ -145,15 +155,7 @@ r1 = null; r2.Close(); r2 = null; - StreamReader sr = new StreamReader(result); - string expectedResult = sr.ReadToEnd(); - sr.Close(); - MemoryStream ms = new MemoryStream(); - doc.Save(new StreamWriter(ms, Encoding.UTF8)); - ms.Position = 0; - string actualResult = new StreamReader(ms).ReadToEnd(); - Console.WriteLine("\n-----------Expected result:-----------\n{0}", expectedResult); - Console.WriteLine("-----------Actual result:-----------\n{0}", actualResult); + ReportResults(result, doc); throw e; } finally @@ -163,7 +165,21 @@ if (r2 != null) r2.Close(); } - } + ReportResults(result, doc); + } + + private static void ReportResults(string expected, XmlDocument actual) + { + StreamReader sr = new StreamReader(expected); + string expectedResult = sr.ReadToEnd(); + sr.Close(); + MemoryStream ms = new MemoryStream(); + actual.Save(new StreamWriter(ms, Encoding.UTF8)); + ms.Position = 0; + string actualResult = new StreamReader(ms).ReadToEnd(); + Console.WriteLine("\n-----------Expected result:-----------\n{0}", expectedResult); + Console.WriteLine("-----------Actual result:-----------\n{0}", actualResult); + } /// <summary> /// General test - it should work actually. @@ -256,7 +272,7 @@ [Test] public void XmlLangTest() { - RunAndCompare("../../tests/langtest.xml", "../../results/langtest.xml"); + RunAndCompare("../../tests/langtest.xml", "../../results/langtest.xml"); } /// <summary> @@ -315,14 +331,34 @@ Assert.AreEqual(sb.ToString(), expected); } -// /// <summary> -// /// Custom resolver test. -// /// </summary> -// [Test] -// public void CustomResolver() -// { -// RunAndCompare("../../tests/resolver.xml", "../../results/resolver.xml"); -// } + /// <summary> + /// Custom resolver test. + /// </summary> + [Test] + public void CustomResolver() + { + RunAndCompare("../../tests/resolver.xml", "../../results/resolver.xml", false, new TestResolver()); + } + + } + + public class TestResolver : XmlUrlResolver + { + public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn) + { + if (absoluteUri.Scheme == "textreader") + return new StringReader(@"<text attr=""val"">From custom resolver (as TextReader)</text>"); + else if (absoluteUri.Scheme == "stream") + { + return File.OpenRead("../../results/document.xml"); + } + else if (absoluteUri.Scheme == "xmlreader") + { + return new XmlTextReader(absoluteUri.AbsoluteUri, new StringReader(@"<text attr=""val"">From custom resolver (as XmlReader)</text>")); + } + else + return base.GetEntity(absoluteUri, role, ofObjectToReturn); + } } } Index: NistTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/NistTests.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- NistTests.cs 1 Nov 2004 08:04:00 -0000 1.6 +++ NistTests.cs 3 Nov 2004 12:55:46 -0000 1.7 @@ -58,7 +58,7 @@ /// element, result in fatal errors. /// </summary> [Test] - [ExpectedException(typeof(UnknownParseAttributeValueException))] + [ExpectedException(typeof(XIncludeSyntaxError))] public void Nist_include_03() { RunAndCompare("nist-include-03.xml", ""); |
From: Oleg T. <he...@us...> - 2004-11-03 12:55:56
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32016/v1/test/tests Modified Files: resolver.xml Log Message: Optimizations/Simplifications. Index: resolver.xml =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/tests/resolver.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- resolver.xml 14 Oct 2004 15:17:14 -0000 1.1 +++ resolver.xml 3 Nov 2004 12:55:47 -0000 1.2 @@ -1,7 +1,14 @@ <?xml version="1.0"?> <document xmlns:xi="http://www.w3.org/2001/XInclude"> - <p>Raw data from cache:</p> - <xi:include href="cache://source.xml"/> + <stream> + <xi:include href="stream://whatever"/> + </stream> + <textreader> + <xi:include href="textreader://whatever"/> + </textreader> + <xmlreader> + <xi:include href="xmlreader://whatever"/> + </xmlreader> <p>Filtered:</p> - <xi:include href="cache://source.xml" xpointer="xpointer(//warehouse)"/> + <xi:include href="textreader://whatever" xpointer="xpointer(//text())"/> </document> \ No newline at end of file |
From: Oleg T. <he...@us...> - 2004-11-02 16:49:55
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9804/v1/src Modified Files: XIncludingReader.cs XIncludingReaderState.cs Log Message: Code review Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- XIncludingReader.cs 2 Nov 2004 14:31:56 -0000 1.24 +++ XIncludingReader.cs 2 Nov 2004 16:49:39 -0000 1.25 @@ -26,7 +26,6 @@ /// Open Issues: /// o GetAttribute(int i)? /// o MoveToAttribute(int i)? - /// o GetEntity on custom XmlResolver ///</remarks> public class XIncludingReader : XmlReader { @@ -202,7 +201,7 @@ int ac = _reader.AttributeCount; if (_reader.GetAttribute(_keywords.XmlBase)==null) ac++; - if (_differentLang && _reader.GetAttribute(_keywords.XmlLang)==null) + if (_differentLang) ac++; return ac; } @@ -222,16 +221,10 @@ { get { - switch (_state) - { - case XIncludingReaderState.ExposingXmlBaseAttr: - case XIncludingReaderState.ExposingXmlBaseAttrValue: - case XIncludingReaderState.ExposingXmlLangAttr: - case XIncludingReaderState.ExposingXmlLangAttrValue: - return true; - default: - return _reader.HasValue; - } + if (_state == XIncludingReaderState.Default) + return _reader.HasValue; + else + return true; } } @@ -240,17 +233,12 @@ { get { - switch (_state) - { - case XIncludingReaderState.ExposingXmlBaseAttr: - case XIncludingReaderState.ExposingXmlBaseAttrValue: - case XIncludingReaderState.ExposingXmlLangAttr: - case XIncludingReaderState.ExposingXmlLangAttrValue: - //TODO: May be wrong if xml:base or xml:lang exists and it does default - return false; - default: - return _reader.IsDefault; - } + if (_state == XIncludingReaderState.Default) + return _reader.IsDefault; + else + //TODO: It might be wrong if xml:base or xml:lang + //are default + return false; } } @@ -376,12 +364,14 @@ /// <summary>See <see cref="XmlReader.Close"/></summary> public override void Close() { - _reader.Close(); + if (_reader != null) + _reader.Close(); //Close all readers in the stack while (_readers.Count>0) { _reader = (XmlReader)_readers.Pop(); - _reader.Close(); + if (_reader != null) + _reader.Close(); } } @@ -392,6 +382,7 @@ if (_readers.Count == 0) return _reader.Depth; else + //TODO: that might be way ineffective return ((XmlReader)_readers.Peek()).Depth + _reader.Depth; } } @@ -411,29 +402,29 @@ /// <summary>See <see cref="XmlReader.GetAttribute"/></summary> public override string GetAttribute(string name) { - if (_topLevel && - XIncludeKeywords.Equals(name, _keywords.XmlBase)) - return _reader.BaseURI; - else if (_topLevel && - XIncludeKeywords.Equals(name, _keywords.XmlLang)) - return _reader.XmlLang; - else - return _reader.GetAttribute(name); + if (_topLevel) + { + if (XIncludeKeywords.Equals(name, _keywords.XmlBase)) + return _reader.BaseURI; + else if (XIncludeKeywords.Equals(name, _keywords.XmlLang)) + return _reader.XmlLang; + } + return _reader.GetAttribute(name); } /// <summary>See <see cref="XmlReader.GetAttribute"/></summary> public override string GetAttribute(string name, string namespaceURI) { - if (_topLevel && - XIncludeKeywords.Equals(name, _keywords.Base) && - XIncludeKeywords.Equals(namespaceURI, _keywords.XmlNamespace)) - return _reader.BaseURI; - else if (_topLevel && - XIncludeKeywords.Equals(name, _keywords.Lang) && - XIncludeKeywords.Equals(namespaceURI, _keywords.XmlNamespace)) - return _reader.XmlLang; - else - return _reader.GetAttribute(name, namespaceURI); + if (_topLevel) + { + if (XIncludeKeywords.Equals(name, _keywords.Base) && + XIncludeKeywords.Equals(namespaceURI, _keywords.XmlNamespace)) + return _reader.BaseURI; + else if (XIncludeKeywords.Equals(name, _keywords.Lang) && + XIncludeKeywords.Equals(namespaceURI, _keywords.XmlNamespace)) + return _reader.XmlLang; + } + return _reader.GetAttribute(name, namespaceURI); } /// <summary>See <see cref="XmlReader.IsEmptyElement"/></summary> @@ -457,41 +448,41 @@ /// <summary>See <see cref="XmlReader.MoveToAttribute"/></summary> public override bool MoveToAttribute(string name) { - if (_topLevel && - XIncludeKeywords.Equals(name, _keywords.XmlBase)) - { - _state = XIncludingReaderState.ExposingXmlBaseAttr; - return true; - } - else if (_topLevel && - XIncludeKeywords.Equals(name, _keywords.XmlLang)) + if (_topLevel) { - _state = XIncludingReaderState.ExposingXmlLangAttr; - return true; + if (XIncludeKeywords.Equals(name, _keywords.XmlBase)) + { + _state = XIncludingReaderState.ExposingXmlBaseAttr; + return true; + } + else if (XIncludeKeywords.Equals(name, _keywords.XmlLang)) + { + _state = XIncludingReaderState.ExposingXmlLangAttr; + return true; + } } - else - return _reader.MoveToAttribute(name); + return _reader.MoveToAttribute(name); } /// <summary>See <see cref="XmlReader.MoveToAttribute"/></summary> public override bool MoveToAttribute(string name, string ns) { - if (_topLevel && - XIncludeKeywords.Equals(name, _keywords.Base) && - XIncludeKeywords.Equals(ns, _keywords.XmlNamespace)) - { - _state = XIncludingReaderState.ExposingXmlBaseAttr; - return true; - } - else if (_topLevel && - XIncludeKeywords.Equals(name, _keywords.Lang) && - XIncludeKeywords.Equals(ns, _keywords.XmlNamespace)) + if (_topLevel) { - _state = XIncludingReaderState.ExposingXmlLangAttr; - return true; - } - else - return _reader.MoveToAttribute(name, ns); + if (XIncludeKeywords.Equals(name, _keywords.Base) && + XIncludeKeywords.Equals(ns, _keywords.XmlNamespace)) + { + _state = XIncludingReaderState.ExposingXmlBaseAttr; + return true; + } + else if (XIncludeKeywords.Equals(name, _keywords.Lang) && + XIncludeKeywords.Equals(ns, _keywords.XmlNamespace)) + { + _state = XIncludingReaderState.ExposingXmlLangAttr; + return true; + } + } + return _reader.MoveToAttribute(name, ns); } /// <summary>See <see cref="XmlReader.MoveToElement"/></summary> @@ -524,10 +515,7 @@ } } - else - { - return _reader.MoveToFirstAttribute(); - } + return _reader.MoveToFirstAttribute(); } /// <summary>See <see cref="XmlReader.MoveToNextAttribute"/></summary> @@ -578,10 +566,7 @@ } } - else - { - return _reader.MoveToNextAttribute(); - } + return _reader.MoveToNextAttribute(); } /// <summary>See <see cref="XmlReader.ReadAttributeValue"/></summary> Index: XIncludingReaderState.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReaderState.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- XIncludingReaderState.cs 2 Nov 2004 14:31:56 -0000 1.4 +++ XIncludingReaderState.cs 2 Nov 2004 16:49:39 -0000 1.5 @@ -1,6 +1,5 @@ -namespace Mvp.Xml.XInclude { - - //TODO: why not class? +namespace Mvp.Xml.XInclude +{ internal struct FallbackState { //Fallback is being processed @@ -26,5 +25,5 @@ ExposingXmlLangAttr, //xml:lang attribute value is being exposed ExposingXmlLangAttrValue - } + } } |
From: Oleg T. <he...@us...> - 2004-11-02 14:32:07
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12895/v1/test/tests Added Files: langtest.xml russian.xml Log Message: Fixed support for xml:lang fixup --- NEW FILE: langtest.xml --- <?xml version="1.0" encoding="utf-8" ?> <foo xmlns:xi="http://www.w3.org/2003/XInclude"> <bar xml:lang="en-us"> <baz>whatever</baz> <xi:include href="russian.xml"/> <xi:include href="russian.xml" xpointer="xpointer(//text2)"/> <xi:include href="russian.xml" xpointer="xpointer(//english)"/> <xi:include href="russian.xml" xpointer="xpointer(//eng)"/> <xi:include href="russian.xml" xpointer="xpointer(//eng2)"/> <xi:include href="russian.xml" xpointer="xpointer(//eng3)"/> <xi:include href="russian.xml" xpointer="xpointer(//eng4)"/> <xi:include href="russian.xml" xpointer="xpointer(//eng5)"/> </bar> </foo> --- NEW FILE: russian.xml --- (This appears to be a binary file; contents omitted.) |
From: Oleg T. <he...@us...> - 2004-11-02 14:32:07
|
Update of /cvsroot/mvp-xml/XInclude/v1/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12895/v1/test Modified Files: Elliotte_Rusty_HaroldTests.cs EntryPoint.cs XIncludeReaderTests.cs XIncludeTest.csproj Log Message: Fixed support for xml:lang fixup Index: XIncludeTest.csproj =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeTest.csproj,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- XIncludeTest.csproj 1 Nov 2004 05:44:44 -0000 1.11 +++ XIncludeTest.csproj 2 Nov 2004 14:31:57 -0000 1.12 @@ -163,6 +163,10 @@ BuildAction = "Content" /> <File + RelPath = "results\langtest.xml" + BuildAction = "Content" + /> + <File RelPath = "results\nonxmlchar.xml" BuildAction = "Content" /> @@ -223,6 +227,10 @@ BuildAction = "Content" /> <File + RelPath = "tests\langtest.xml" + BuildAction = "Content" + /> + <File RelPath = "tests\nohref.xml" BuildAction = "Content" /> @@ -235,6 +243,10 @@ BuildAction = "Content" /> <File + RelPath = "tests\russian.xml" + BuildAction = "Content" + /> + <File RelPath = "tests\test2.xml" BuildAction = "Content" /> Index: EntryPoint.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/EntryPoint.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- EntryPoint.cs 1 Nov 2004 08:12:03 -0000 1.12 +++ EntryPoint.cs 2 Nov 2004 14:31:57 -0000 1.13 @@ -9,15 +9,15 @@ { public static void Main() { - //XIncludeReaderTests rt = new XIncludeReaderTests(); + XIncludeReaderTests rt = new XIncludeReaderTests(); //LTG_Edinburgh_UnivTests rt = new LTG_Edinburgh_UnivTests(); - NISTTests rt = new NISTTests(); + //NISTTests rt = new NISTTests(); //Elliotte_Rusty_HaroldTests rt = new Elliotte_Rusty_HaroldTests(); //FourThoughtTests rt = new FourThoughtTests(); //XIncludeSyntaxTests rt = new XIncludeSyntaxTests(); try { - rt.Nist_include_24(); + rt.XmlLangTest(); } catch (Exception e) { Index: XIncludeReaderTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/XIncludeReaderTests.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- XIncludeReaderTests.cs 1 Nov 2004 05:44:44 -0000 1.12 +++ XIncludeReaderTests.cs 2 Nov 2004 14:31:57 -0000 1.13 @@ -251,6 +251,15 @@ } /// <summary> + /// xml:lang fixup + /// </summary> + [Test] + public void XmlLangTest() + { + RunAndCompare("../../tests/langtest.xml", "../../results/langtest.xml"); + } + + /// <summary> /// ReadOuterXml() test. /// </summary> [Test] Index: Elliotte_Rusty_HaroldTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/test/Elliotte_Rusty_HaroldTests.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Elliotte_Rusty_HaroldTests.cs 1 Nov 2004 08:04:00 -0000 1.6 +++ Elliotte_Rusty_HaroldTests.cs 2 Nov 2004 14:31:57 -0000 1.7 @@ -954,7 +954,9 @@ [Test] public void harold_77() { - RunAndCompare("UnicodeBigUnmarked.xml", "../result/UnicodeBigUnmarked.xml"); + XIncludeReaderTests.RunAndCompare( + "http://localhost/test/UnicodeBigUnmarked.xml", + "../../XInclude-Test-Suite/Harold/test/../result/UnicodeBigUnmarked.xml"); } @@ -965,7 +967,9 @@ [Test] public void harold_78() { - RunAndCompare("UnicodeLittleUnmarked.xml", "../result/UnicodeLittleUnmarked.xml"); + XIncludeReaderTests.RunAndCompare( + "http://localhost/test/UnicodeLittleUnmarked.xml", + "../../XInclude-Test-Suite/Harold/test/../result/UnicodeLittleUnmarked.xml"); } @@ -973,9 +977,14 @@ /// <summary> /// Can autodetect EBCDIC files with a without a byte order mark when parse="text" /// </summary> + /// <remarks>EBCDIC is not supported encoding</remarks> [Test] + [ExpectedException(typeof(FatalResourceException))] public void harold_79() { + XIncludeReaderTests.RunAndCompare( + "http://localhost/test/EBCDIC.xml", + "../../XInclude-Test-Suite/Harold/test/../result/EBCDIC.xml"); RunAndCompare("EBCDIC.xml", "../result/EBCDIC.xml"); } |
From: Oleg T. <he...@us...> - 2004-11-02 14:32:07
|
Update of /cvsroot/mvp-xml/XInclude/v1/test/results In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12895/v1/test/results Added Files: langtest.xml Log Message: Fixed support for xml:lang fixup --- NEW FILE: langtest.xml --- <?xml version="1.0" encoding="utf-8"?> <foo xmlns:xi="http://www.w3.org/2003/XInclude"> <bar xml:lang="en-us"> <baz>whatever</baz> <russian-text xml:base="russian.xml" xml:lang=""> <text xml:lang="ru-ru">Ð ÑÑÑкий ÑекÑÑ</text> Another neutral text. <text2 xml:lang="he-IL">hebrew</text2> <eng xml:lang="en-us" xml:base="whatever"> <english>english - en-us</english> </eng> <eng2 attr="23" xml:lang="en-us"> <english>english - en-us</english> </eng2> <eng3 xml:lang="en-gb" attr="22" xml:base="whatever"> <english>english - en-us</english> </eng3> <eng4 xml:lang="en-gb" xml:base="whatever" attr="dd"> <english>english - en-us</english> </eng4> <eng5 attr="ff" xml:lang="" xml:base="whatever" attr2="dd"> <english>english - en-us</english> </eng5> </russian-text> <text2 xml:base="russian.xml" xml:lang="he-IL">hebrew</text2> <english xml:base="russian.xml">english - en-us</english><english xml:base="russian.xml">english - en-us</english><english xml:base="russian.xml" xml:lang="en-gb">english - en-us</english><english xml:base="russian.xml" xml:lang="en-gb">english - en-us</english><english xml:base="russian.xml" xml:lang="">english - en-us</english> <eng xml:base="russian.xml"> <english>english - en-us</english> </eng> <eng2 attr="23" xml:base="russian.xml"> <english>english - en-us</english> </eng2> <eng3 attr="22" xml:base="russian.xml" xml:lang="en-gb"> <english>english - en-us</english> </eng3> <eng4 attr="dd" xml:base="russian.xml" xml:lang="en-gb"> <english>english - en-us</english> </eng4> <eng5 attr="ff" attr2="dd" xml:base="russian.xml" xml:lang=""> <english>english - en-us</english> </eng5> </bar> </foo> |
From: Oleg T. <he...@us...> - 2004-11-02 14:32:07
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12895/v1/src Modified Files: TextIncludingReader.cs XIncludingReader.cs XIncludingReaderState.cs Log Message: Fixed support for xml:lang fixup Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- XIncludingReader.cs 1 Nov 2004 12:35:11 -0000 1.23 +++ XIncludingReader.cs 2 Nov 2004 14:31:56 -0000 1.24 @@ -17,17 +17,7 @@ #endregion namespace Mvp.Xml.XInclude -{ - internal struct FallbackState - { - //Fallback is being processed - public bool Fallbacking; - //xi:fallback element depth - public int FallbackDepth; - //Fallback processed flag - public bool FallbackProcessed; - } - +{ /// <summary> /// XInclude 1.0 aware XmlReader. /// </summary> @@ -73,6 +63,8 @@ XmlResolver _xmlResolver; //Expose text inclusions as CDATA private bool _exposeTextAsCDATA; + //Top-level included item has different xml:lang + private bool _differentLang = false; #endregion #region Constructors @@ -205,10 +197,15 @@ { get { - if (_topLevel) - return _reader.AttributeCount + - _reader.GetAttribute(_keywords.XmlBase)==null?1:0 + - _reader.GetAttribute(_keywords.XmlLang)==null?1:0; + if (_topLevel) + { + int ac = _reader.AttributeCount; + if (_reader.GetAttribute(_keywords.XmlBase)==null) + ac++; + if (_differentLang && _reader.GetAttribute(_keywords.XmlLang)==null) + ac++; + return ac; + } else return _reader.AttributeCount; } @@ -249,7 +246,7 @@ case XIncludingReaderState.ExposingXmlBaseAttrValue: case XIncludingReaderState.ExposingXmlLangAttr: case XIncludingReaderState.ExposingXmlLangAttrValue: - //TODO: May be wrong if xml:base or xml:lang exist and it does default + //TODO: May be wrong if xml:base or xml:lang exists and it does default return false; default: return _reader.IsDefault; @@ -506,53 +503,85 @@ /// <summary>See <see cref="XmlReader.MoveToFirstAttribute"/></summary> public override bool MoveToFirstAttribute() { - bool res = _reader.MoveToFirstAttribute(); - if (_topLevel && !res) + if (_topLevel) { - _state = XIncludingReaderState.ExposingXmlBaseAttr; - return true; - } - else - return res; + bool res = _reader.MoveToFirstAttribute(); + if (res) + { + //it might be xml:base or xml:lang + if (_reader.Name == _keywords.XmlBase || + _reader.Name == _keywords.XmlLang) + //omit them - we expose virtual ones at the end + return MoveToNextAttribute(); + else + return res; + } + else + { + //No attrs? Expose xml:base + _state = XIncludingReaderState.ExposingXmlBaseAttr; + return true; + } + + } + else + { + return _reader.MoveToFirstAttribute(); + } } /// <summary>See <see cref="XmlReader.MoveToNextAttribute"/></summary> public override bool MoveToNextAttribute() { - bool res = _reader.MoveToNextAttribute(); - if (_topLevel && !res && - _reader.GetAttribute(_keywords.Base, _keywords.XmlNamespace)==null) - { - //End of attributes and there is no xml:base - expose virtual one + if (_topLevel) + { switch (_state) - { + { case XIncludingReaderState.ExposingXmlBaseAttr: case XIncludingReaderState.ExposingXmlBaseAttrValue: + //Exposing xml:base already - switch to xml:lang + if (_differentLang) + { + _state = XIncludingReaderState.ExposingXmlLangAttr; + return true; + } + else + { + //No need for xml:lang, stop + _state = XIncludingReaderState.Default; + return false; + } + case XIncludingReaderState.ExposingXmlLangAttr: + case XIncludingReaderState.ExposingXmlLangAttrValue: + //Exposing xml:lang already - that's a last one _state = XIncludingReaderState.Default; - return false; + return false; default: - _state = XIncludingReaderState.ExposingXmlBaseAttr; - return true; - } - } - else if (_topLevel && XIncludeKeywords.Equals(_reader.LocalName, _keywords.Base) && - XIncludeKeywords.Equals(_reader.NamespaceURI, _keywords.XmlNamespace)) - { - //There is xml:base already - substitute its value - if (res) - { - _state = XIncludingReaderState.ExposingXmlBaseAttr; - return true; - } - else - { - //No more attributes - clean up - _state = XIncludingReaderState.Default; - return false; + //1+ attrs, default mode + bool res = _reader.MoveToNextAttribute(); + if (res) + { + //Still real attributes - it might be xml:base or xml:lang + if (_reader.Name == _keywords.XmlBase || + _reader.Name == _keywords.XmlLang) + //omit them - we expose virtual ones at the end + return MoveToNextAttribute(); + else + return res; + } + else + { + //No more attrs - expose virtual xml:base + _state = XIncludingReaderState.ExposingXmlBaseAttr; + return true; + } } - } - else - return res; + + } + else + { + return _reader.MoveToNextAttribute(); + } } /// <summary>See <see cref="XmlReader.ReadAttributeValue"/></summary> @@ -743,6 +772,8 @@ //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; + if (_topLevel) + _differentLang = AreDifferentLangs(_reader.XmlLang, ((XmlReader)_readers.Peek()).XmlLang); if (_topLevel && _reader.NodeType == XmlNodeType.Attribute) //Attempt to include an attribute or namespace node throw new AttributeOrNamespaceInIncludeLocationError(SR.AttributeOrNamespaceInIncludeLocationError); @@ -1263,9 +1294,9 @@ /// <summary> /// Compares two languages as per IETF RFC 3066. /// </summary> - private bool AreTheSameLangs(string lang1, string lang2) + private bool AreDifferentLangs(string lang1, string lang2) { - return lang1.ToLower() == lang2.ToLower(); + return lang1.ToLower() != lang2.ToLower(); } /// <summary> Index: XIncludingReaderState.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReaderState.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- XIncludingReaderState.cs 14 Oct 2004 14:17:55 -0000 1.3 +++ XIncludingReaderState.cs 2 Nov 2004 14:31:56 -0000 1.4 @@ -1,5 +1,16 @@ namespace Mvp.Xml.XInclude { - + + //TODO: why not class? + internal struct FallbackState + { + //Fallback is being processed + public bool Fallbacking; + //xi:fallback element depth + public int FallbackDepth; + //Fallback processed flag + public bool FallbackProcessed; + } + /// <summary> /// XIncludingReader state machine. /// </summary> Index: TextIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/TextIncludingReader.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- TextIncludingReader.cs 28 Oct 2004 18:27:05 -0000 1.6 +++ TextIncludingReader.cs 2 Nov 2004 14:31:56 -0000 1.7 @@ -292,30 +292,20 @@ /// of the resource to inlclude.</param> /// <returns>The document encoding as per XML declaration.</returns> /// <exception cref="ResourceException">Resource error.</exception> - private Encoding GetEncodingFromXMLDecl(string href) + private Encoding GetEncodingFromXMLDecl(string href) { - XmlTextReader tmpReader = new XmlTextReader(href); - tmpReader.WhitespaceHandling = WhitespaceHandling.None; - while (tmpReader.Read()) { - switch (tmpReader.NodeType) { - case XmlNodeType.XmlDeclaration: - if (tmpReader.MoveToAttribute("encoding")) { - string encValue = tmpReader.Value; - try { - return Encoding.GetEncoding(encValue); - } catch (Exception e) { - throw new ResourceException(SR.GetString("NotSupportedEncoding", encValue), e); - } - } else - //No encoding in XML declaration - UTF-8 by default - return Encoding.UTF8; - default: - //No XML declaration - UTF-8 by default - return Encoding.UTF8; - } - } - //Hmmm, empty file? Anyway - return Encoding.UTF8; + XmlTextReader tmpReader = new XmlTextReader(href); + tmpReader.WhitespaceHandling = WhitespaceHandling.None; + try + { + while (tmpReader.Read() && tmpReader.Encoding == null) {} + Encoding enc = tmpReader.Encoding; + return enc==null? Encoding.UTF8 : enc; + } + finally + { + tmpReader.Close(); + } } #endregion |
From: Oleg T. <he...@us...> - 2004-11-01 19:34:36
|
Update of /cvsroot/mvp-xml/WebSite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2764 Modified Files: upload.cmd Log Message: Added more stuff. Index: upload.cmd =================================================================== RCS file: /cvsroot/mvp-xml/WebSite/upload.cmd,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- upload.cmd 14 Jul 2004 03:48:22 -0000 1.1 +++ upload.cmd 1 Nov 2004 19:34:25 -0000 1.2 @@ -1,4 +1,8 @@ @echo off +set USER=helgy rem You need to install PSCP from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html and have it on your %path% -pscp index.html dca...@do...:/home/groups/m/mv/mvp-xml/htdocs/ -pscp style.css dca...@do...:/home/groups/m/mv/mvp-xml/htdocs/ \ No newline at end of file +rem pscp index.html %USER%@shell.sourceforge.net:/home/groups/m/mv/mvp-xml/htdocs +rem pscp style.css %USER%@shell.sourceforge.net:/home/groups/m/mv/mvp-xml/htdocs +pscp common/index.html %USER%@shell.sourceforge.net:/home/groups/m/mv/mvp-xml/htdocs/common +pscp xinclude/index.html %USER%@shell.sourceforge.net:/home/groups/m/mv/mvp-xml/htdocs/xinclude +pscp xpointer/index.html %USER%@shell.sourceforge.net:/home/groups/m/mv/mvp-xml/htdocs/xpointer \ No newline at end of file |
From: Oleg T. <he...@us...> - 2004-11-01 17:42:24
|
Update of /cvsroot/mvp-xml/WebSite/xpointer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10025/xpointer Modified Files: index.html Log Message: Fixed links. Index: index.html =================================================================== RCS file: /cvsroot/mvp-xml/WebSite/xpointer/index.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- index.html 1 Nov 2004 17:19:20 -0000 1.1 +++ index.html 1 Nov 2004 17:42:04 -0000 1.2 @@ -10,20 +10,20 @@ The XPointer.NET module provides an implementation of the <a href="http://www.w3.org/TR/xptr-framework/">XPointer Framework Recommendation</a> written in C# for the .NET platform. -XPointer.NET supports <a - href="http://http//www.w3.org/TR/xptr-element/">XPointer element() +XPointer.NET supports <a href="http://www.w3.org/TR/xptr-element/">XPointer +element() Scheme</a>, <a href="http://www.w3.org/TR/xptr-xmlns/">XPointer xmlns() Scheme</a>, <a href="http://simonstl.com/ietf/draft-stlaurent-xpath-frag-00.html"> XPointer xpath1() Scheme</a> and <a - href="http://simonstl.com/ietf/draft-stlaurent-xpath-frag-00.html"> + href="http://www.w3.org/TR/xptr-xpointer/"> XPointer xpointer() Scheme</a> (XPath subset only). XPointer.NET was designed and implemented for XInclude.NET module, but it can be used on its own.<br> <h2>Requirements</h2> <p>XPointer.NET is .NET Framework application and requires <a - href="http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/MSDN-FILES/027/001/829/msdncompositedoc.xml&frame=true" - target="_top"> .NET Framework</a> version 1.0 or 1.1 to be installed. </p> + href="http://msdn.microsoft.com/netframework/" target="_top"> .NET +Framework</a> version 1.0 or 1.1 to be installed. </p> <h2>Installation and Documentation</h2> <p>Find precompiled <font style="font-family: monospace;" face="Courier New">Mvp.Xml.XPointer.dll</font> library in the "<font @@ -43,12 +43,11 @@ <ul> <li><a href="http://www.w3.org/TR/xptr-framework/">XPointer Framework Recommendation</a></li> - <li><a href="http://http//www.w3.org/TR/xptr-element/">XPointer + <li><a href="http://www.w3.org/TR/xptr-element/">XPointer element() Scheme</a></li> <li><a href="http://www.w3.org/TR/xptr-xmlns/">XPointer xmlns() Scheme</a><span style="text-decoration: underline;"></span></li> - <li><a - href="http://simonstl.com/ietf/draft-stlaurent-xpath-frag-00.html">XPointer + <li><a href="http://www.w3.org/TR/xptr-xpointer/">XPointer xpointer() Scheme</a></li> </ul> <h2>History</h2> @@ -66,7 +65,8 @@ <h2>Usage</h2> <a href="../../../../temp/XInclude.NET-1.2/doc/GotDotNet.XInclude.XIncludingReader.html">XPointerReader</a> -class, found in the Mvp.Xml.XPointer namespace (#TODO), is the key +class (#TODO), found in the Mvp.Xml.XPointer namespace (#TODO), is the +key class. It's customized <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlReaderClassTopic.asp"> XmlReader</a>, which implements <a @@ -76,7 +76,7 @@ xmlns() Scheme</a><!--StartFragment -->, <a href="http://www.simonstl.com/ietf/draft-stlaurent-xpath-frag-00.html">The XPointer xpath1() Scheme</a> and <a - href="http://simonstl.com/ietf/draft-stlaurent-xpath-frag-00.html"> + href="http://www.w3.org/TR/xptr-xpointer/"> XPointer xpointer() Scheme</a> (XPath subset only) in a caching forward-only fashion.<br> <br> @@ -89,7 +89,7 @@ </h2> <ol> <li>Only XPath subset of the <a - href="http://simonstl.com/ietf/draft-stlaurent-xpath-frag-00.html"> + href="http://www.w3.org/TR/xptr-xpointer/"> XPointer xpointer() Scheme</a> is currently supported. </li> </ol> <h2>License</h2> @@ -115,11 +115,11 @@ the <a href="https://lists.sourceforge.net/mailman/listinfo/mvp-xml-help">mvp-xml-help</a> mailing list <a - href="http://sourceforge.net/mailarchive/forum.php?forum_id=">(archive)</a>. + href="http://sourceforge.net/mailarchive/forum.php?forum=mvp-xml-help">(archive)</a>. </p> <hr style="width: 100%; height: 2px;"> <p> The project is hosted at <a target="_blank" - href="http://prdownloads.sourceforge.net/mvp-xml/Mvp.Xml.zip?download"> + href="http://www.sourceforge.net"> SourceForge</a>. Find more at the <a href="http://sourceforge.net/projects/mvp-xml">Mvp.Xml project page at SourceForge</a>.<br> |
From: Oleg T. <he...@us...> - 2004-11-01 17:42:24
|
Update of /cvsroot/mvp-xml/WebSite/xinclude In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10025/xinclude Modified Files: index.html Log Message: Fixed links. Index: index.html =================================================================== RCS file: /cvsroot/mvp-xml/WebSite/xinclude/index.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- index.html 1 Nov 2004 17:19:18 -0000 1.1 +++ index.html 1 Nov 2004 17:42:04 -0000 1.2 @@ -12,13 +12,13 @@ Proposed Recommendation</a> and the <a href="http://www.w3.org/TR/xptr-framework/">XPointer Framework Recommendation</a> written in C# for the .NET platform. -XInclude.NET supports <a - href="http://http//www.w3.org/TR/xptr-element/">XPointer element() +XInclude.NET supports <a href="http://www.w3.org/TR/xptr-element/">XPointer +element() Scheme</a>, <a href="http://www.w3.org/TR/xptr-xmlns/">XPointer xmlns() Scheme</a>, <a href="http://simonstl.com/ietf/draft-stlaurent-xpath-frag-00.html"> XPointer xpath1() Scheme</a> and <a - href="http://simonstl.com/ietf/draft-stlaurent-xpath-frag-00.html"> + href="http://www.w3.org/TR/xptr-xpointer/"> XPointer xpointer() Scheme</a> (XPath subset only). XInclude.NET currently supports only streamable subset of the XInclude, implemented as fast, non-caching, forward-only <span @@ -29,8 +29,8 @@ Microsoft .NET 1.0 and 1.1 on Windows 2000 and Windows Server 2003.</p> <h2>Requirements</h2> <p>XInclude.NET is .NET Framework application and requires <a - href="http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/MSDN-FILES/027/001/829/msdncompositedoc.xml&frame=true" - target="_top"> .NET Framework</a> version 1.0 or 1.1 to be installed. </p> + href="http://msdn.microsoft.com/netframework/" target="_top"> .NET +Framework</a> version 1.0 or 1.1 to be installed. </p> <h2>Installation and Documentation</h2> <p>Find precompiled <font style="font-family: monospace;" face="Courier New">Mvp.Xml.XInclude.dll</font> library in the "<font @@ -52,12 +52,11 @@ (XInclude)1.0</a></li> <li><a href="http://www.w3.org/TR/xptr-framework/">XPointer Framework Recommendation</a></li> - <li><a href="http://http//www.w3.org/TR/xptr-element/">XPointer + <li><a href="http://www.w3.org/TR/xptr-element/">XPointer element() Scheme</a></li> <li><a href="http://www.w3.org/TR/xptr-xmlns/">XPointer xmlns() Scheme</a><span style="text-decoration: underline;"></span></li> - <li><a - href="http://simonstl.com/ietf/draft-stlaurent-xpath-frag-00.html">XPointer + <li><a href="http://www.w3.org/TR/xptr-xpointer/">XPointer xpointer() Scheme</a></li> </ul> <p></p> @@ -105,6 +104,7 @@ <h2>Usage</h2> <p><a href="../../../../temp/XInclude.NET-1.2/doc/GotDotNet.XInclude.XIncludingReader.html">XIncludingReader</a> +(#TODO) class, found in the Mvp.Xml.XInclude namespace (#TODO), is the key class. It's customized <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlReaderClassTopic.asp"> @@ -156,11 +156,11 @@ xmlns() Scheme</a>,<!--StartFragment --> <a href="http://www.simonstl.com/ietf/draft-stlaurent-xpath-frag-00.html">The XPointer xpath1() Scheme</a> and <a - href="http://simonstl.com/ietf/draft-stlaurent-xpath-frag-00.html"> + href="http://www.w3.org/TR/xptr-xpointer/"> XPointer xpointer() Scheme</a> (XPath subset only). </p> <p><a href="../../../../temp/XInclude.NET-1.2/doc/GotDotNet.XPointer.XPointerReader.html">XPointerReader</a> -class, found in <span style="text-decoration: underline;">Mvp.Xml.</span><a +class (#TODO), found in <span style="text-decoration: underline;">Mvp.Xml.</span><a href="../../../../temp/XInclude.NET-1.2/doc/GotDotNet.XPointer.html">XPointer namespace</a> (#TODO) represents XPointer-aware XmlReader and can be used as such outside of XInclude context too.</p> @@ -197,11 +197,11 @@ the <a href="https://lists.sourceforge.net/mailman/listinfo/mvp-xml-help">mvp-xml-help</a> mailing list <a - href="http://sourceforge.net/mailarchive/forum.php?forum_id=">(archive)</a>. + href="http://sourceforge.net/mailarchive/forum.php?forum=mvp-xml-help">(archive)</a>. </p> <hr style="width: 100%; height: 2px;"> <p> The project is hosted at <a target="_blank" - href="http://prdownloads.sourceforge.net/mvp-xml/Mvp.Xml.zip?download"> + href="http://www.sourceforge.net"> SourceForge</a>. Find more at the <a href="http://sourceforge.net/projects/mvp-xml">Mvp.Xml project page at SourceForge</a>.<br> |