From: Daniel C. \(kzu\) <dca...@us...> - 2004-11-17 15:18:20
|
Update of /cvsroot/mvp-xml/Common/v1/src/XPath In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5194/v1/src/XPath Modified Files: XPathNavigatorReader.cs Log Message: Fixed bug that didn't allow reading comments and PIs even if they are allows under the root (not considered as fragments) Index: XPathNavigatorReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v1/src/XPath/XPathNavigatorReader.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- XPathNavigatorReader.cs 14 Nov 2004 01:24:29 -0000 1.4 +++ XPathNavigatorReader.cs 17 Nov 2004 15:18:10 -0000 1.5 @@ -129,6 +129,19 @@ } } ArrayList _orderedattributes; + /// <summary> + /// Whether the reader should continue even if the current element has ended or is empty. + /// </summary> + private bool AllowFragment + { + get + { + return _fragment || + _navigator.NodeType == XPathNodeType.ProcessingInstruction || + _navigator.NodeType == XPathNodeType.Comment; + } + } + #endregion Private Members #region ReadFragmentXml @@ -574,7 +587,7 @@ if (_isendelement) { - if (_fragment) + if (AllowFragment) { // If XML fragment is allowed, we'll let movements // outside the original location, but only to sibling nodes. @@ -620,20 +633,29 @@ return _navigator.MoveToFirstChild(); } - // If XML fragment is not allowed and we're already at the - // original location, and the were no children, this is an empty root. - if (_navigator.IsSamePosition(_original) && !_fragment && !_navigator.HasChildren) - { - _eof = true; - _state = ReadState.EndOfFile; - return false; - } - // If XML fragment is not allowed and we're already at the - // original location, set as end element. - if (_navigator.IsSamePosition(_original) && !_fragment) + if (_navigator.IsSamePosition(_original)) { - _isendelement = true; - return true; + // If XML fragment is not allowed and we're already at the + // original location, and the were no children, this is an empty root. + if (!AllowFragment && _navigator.IsEmptyElement) + { + _eof = true; + _state = ReadState.EndOfFile; + return false; + } + else if (!AllowFragment) + { + // If XML fragment is not allowed and we're already at the + // original location, set as end element. + _isendelement = true; + return true; + } + else + { + // Reposition original pointer. + // If this is false, the following code will check ending conditions. + _original.MoveToNext(); + } } // Otherwise, try to move to sibling. if (_navigator.MoveToNext()) |