From: Oleg T. <he...@us...> - 2004-10-18 18:20:00
|
Update of /cvsroot/mvp-xml/XInclude/v1/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23707/v1/src Modified Files: SR.cs SR.resx XIncludeException.cs XIncludingReader.cs Log Message: Testing... Index: XIncludeException.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludeException.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- XIncludeException.cs 16 Oct 2004 21:01:37 -0000 1.4 +++ XIncludeException.cs 18 Oct 2004 18:19:21 -0000 1.5 @@ -95,4 +95,12 @@ public AttributeOrNamespaceInIncludeLocationError(string message) : base(message) {} } + /// <summary> + /// Not wellformed inclusion result (e.g. top-level xi:include + /// includes multiple elements). + /// </summary> + public class MalformedXInclusionResultError : FatalException + { + public MalformedXInclusionResultError(string message) : base(message) {} + } } Index: XIncludingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/XIncludingReader.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- XIncludingReader.cs 17 Oct 2004 21:01:11 -0000 1.9 +++ XIncludingReader.cs 18 Oct 2004 18:19:21 -0000 1.10 @@ -50,7 +50,9 @@ //Top base URI private Uri _topBaseUri; //Top-level included item flag - private bool _topLevel = false; + private bool _topLevel; + //One top-level element has been included already + private bool _gotTopLevelElem; //Internal state private XIncludingReaderState _state; //Name table @@ -551,11 +553,19 @@ //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 && _reader.NodeType == XmlNodeType.Attribute) - { - //Attempt to include an attribute + if (_topLevel && _reader.NodeType == XmlNodeType.Attribute) + //Attempt to include an attribute or namespace node throw new AttributeOrNamespaceInIncludeLocationError(SR.AttributeOrNamespaceInIncludeLocationError); - } + if (_topLevel && ((XmlReader)_readers.Peek()).Depth == 0 && + _reader.NodeType == XmlNodeType.Element) + { + if (_gotTopLevelElem) + //Attempt to include more than one element at the top level + throw new MalformedXInclusionResultError(SR.MalformedXInclusionResult); + else + _gotTopLevelElem = true; + } + switch (_reader.NodeType) { case XmlNodeType.XmlDeclaration: Index: SR.cs =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/SR.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SR.cs 14 Oct 2004 13:47:07 -0000 1.2 +++ SR.cs 18 Oct 2004 18:19:21 -0000 1.3 @@ -82,6 +82,15 @@ { return SR.GetString("CustomXmlResolverError"); } + } + + /// <summary></summary> + public static string MalformedXInclusionResult + { + get + { + return SR.GetString("MalformedXInclusionResult"); + } } } Index: SR.resx =================================================================== RCS file: /cvsroot/mvp-xml/XInclude/v1/src/SR.resx,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SR.resx 14 Oct 2004 13:47:07 -0000 1.2 +++ SR.resx 18 Oct 2004 18:19:21 -0000 1.3 @@ -120,4 +120,7 @@ <data name="TwoFallbacksLong" type="System.String" mimetype="System.String"> <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> + </data> </root> \ No newline at end of file |