From: Oleg T. <he...@us...> - 2004-11-01 12:35:21
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10448/v1/src Modified Files: SR.resx XIncludingReader.cs Log Message: Bugs... Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- XIncludingReader.cs 1 Nov 2004 05:44:44 -0000 1.22 +++ XIncludingReader.cs 1 Nov 2004 12:35:11 -0000 1.23 @@ -51,8 +51,10 @@ private Uri _topBaseUri; //Top-level included item flag private bool _topLevel; - //One top-level element has been included already - private bool _gotTopLevelElem; + //A top-level included element has been included already + private bool _gotTopIncludedElem; + //At least one element has been returned by the reader + private bool _gotElement; //Internal state private XIncludingReaderState _state; //Name table @@ -747,11 +749,11 @@ if (_topLevel && ((XmlReader)_readers.Peek()).Depth == 0 && _reader.NodeType == XmlNodeType.Element) { - if (_gotTopLevelElem) + if (_gotTopIncludedElem) //Attempt to include more than one element at the top level throw new MalformedXInclusionResultError(SR.MalformedXInclusionResult); else - _gotTopLevelElem = true; + _gotTopIncludedElem = true; } switch (_reader.NodeType) @@ -811,7 +813,10 @@ _reader.BaseURI.ToString())); } else + { + _gotElement = true; goto default; + } case XmlNodeType.EndElement: //Looking for end of xi:fallback if (_fallbackState.Fallbacking && @@ -844,9 +849,13 @@ CheckAndSkipContent(); return Read(); } - else + else + { + if (!_gotElement) + throw new MalformedXInclusionResultError(SR.MalformedXInclusionResult); //That's all, folks return false; + } } } // Read() @@ -1255,9 +1264,8 @@ /// Compares two languages as per IETF RFC 3066. /// </summary> private bool AreTheSameLangs(string lang1, string lang2) - { - //TODO: Wise comparison? - return lang1 == lang2; + { + return lang1.ToLower() == lang2.ToLower(); } /// <summary> @@ -1297,10 +1305,18 @@ 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(); + 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())); } Index: SR.resx =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/SR.resx,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- SR.resx 31 Oct 2004 08:02:27 -0000 1.6 +++ SR.resx 1 Nov 2004 12:35:11 -0000 1.7 @@ -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 in the streaming mode</value> + <value>XIncludingReader doesn't support intra-document references.</value> </data> <data name="CustomXmlResolverError" type="System.String" mimetype="System.String"> <value>An exception has occured during GetEntity call to custom XmlResolver.</value> @@ -121,7 +121,7 @@ <value>xi:include element cannot contain more than one xi:fallback element. Location: {0}, Line {1}, Position {2}.</value> </data> <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> + <value>Malformed XInclusion result - xi:include element at the top level must include a single element and optional comments and PIs.</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> |