diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2006-08-04 10:35:17 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2006-08-04 10:35:17 +0400 |
commit | 8ae9f1becbac9443758ddd0f9e9920eae80a4f4a (patch) | |
tree | 154c93c0638d01e2ada4a4c6ea2372b50bee4499 /mcs/class/System.XML/Mono.Xml.Schema | |
parent | 3abf933fcab3b697bc30032b77025d659b631351 (diff) |
2006-08-04 Atsushi Enomoto <atsushi@ximian.com>
* XsdIdentityState.cs : Fixed bug #78985. If there are two identical
field path "@key" in two different keys where one is in scope
within another, it incorrectly matched the attribute whose name
is same but in different element hierarchy (depth).
* XmlSchemaTest.cs : added bug #78985 case.
* 78985.xsd, 78985.xml : test for bug #78985.
svn path=/trunk/mcs/; revision=63338
Diffstat (limited to 'mcs/class/System.XML/Mono.Xml.Schema')
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.Schema/ChangeLog | 7 | ||||
-rw-r--r-- | mcs/class/System.XML/Mono.Xml.Schema/XsdIdentityState.cs | 33 |
2 files changed, 28 insertions, 12 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog b/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog index b007d226b1a..93fbac15f67 100644 --- a/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog +++ b/mcs/class/System.XML/Mono.Xml.Schema/ChangeLog @@ -1,3 +1,10 @@ +2006-08-04 Atsushi Enomoto <atsushi@ximian.com> + + * XsdIdentityState.cs : Fixed bug #78985. If there are two identical + field path "@key" in two different keys where one is in scope + within another, it incorrectly matched the attribute whose name + is same but in different element hierarchy (depth). + 2006-04-12 Atsushi Enomoto <atsushi@ximian.com> * XmlSchemaValidatingReader.cs : don't reject such XmlReader that diff --git a/mcs/class/System.XML/Mono.Xml.Schema/XsdIdentityState.cs b/mcs/class/System.XML/Mono.Xml.Schema/XsdIdentityState.cs index 1ca39ef40ef..61e5f9d1205 100644 --- a/mcs/class/System.XML/Mono.Xml.Schema/XsdIdentityState.cs +++ b/mcs/class/System.XML/Mono.Xml.Schema/XsdIdentityState.cs @@ -105,9 +105,11 @@ namespace Mono.Xml.Schema return true; } - // if (elementPath) check only elements; else only attributes. + // if matchesAttr then check attributes; otherwise check elements. internal XsdIdentityPath Matches (bool matchesAttr, object sender, XmlNameTable nameTable, ArrayList qnameStack, string sourceUri, object schemaType, NSResolver nsResolver, IXmlLineInfo lineInfo, int depth, string attrName, string attrNS, object attrValue) { + XsdIdentityPath matchedAttrPath = null; + for (int i = 0; i < field.Paths.Length; i++) { XsdIdentityPath path = field.Paths [i]; bool isAttribute = path.IsAttribute; @@ -123,14 +125,15 @@ namespace Mono.Xml.Schema } else if (step.Name == attrName && step.Namespace == attrNS) match = true; - if (match) { - this.FillAttributeFieldValue (sender, nameTable, sourceUri, schemaType, nsResolver, attrValue, lineInfo, depth); - if (this.Identity != null) - return path; - } + if (!match) + continue; + // first -1 is to reduce attr path step, next -1 is to reduce Attribute's depth in XmlReader. + if (entry.StartDepth + (path.OrderedSteps.Length - 1) != depth - 1) + continue; // matched at different nest level + matchedAttrPath = path; } if (FieldFound && (depth > this.FieldFoundDepth && this.FieldFoundPath == path)) - continue; + continue; // don't return; other fields might hit errorneously. // Only "." hits. if (path.OrderedSteps.Length == 0) { @@ -169,7 +172,13 @@ namespace Mono.Xml.Schema if (iter >= 0) // i.e. did not match against the path. continue; - return path; + if (!matchesAttr) + return path; + } + if (matchedAttrPath != null) { + this.FillAttributeFieldValue (sender, nameTable, sourceUri, schemaType, nsResolver, attrValue, lineInfo, depth); + if (this.Identity != null) + return matchedAttrPath; } return null; } @@ -177,10 +186,10 @@ namespace Mono.Xml.Schema private void FillAttributeFieldValue (object sender, XmlNameTable nameTable, string sourceUri, object schemaType, NSResolver nsResolver, object identity, IXmlLineInfo lineInfo, int depth) { if (this.FieldFound) - throw new ValException ("The key value was already found." - + (this.FieldHasLineInfo ? - String.Format (CultureInfo.InvariantCulture, " At line {0}, position {1}.", FieldLineNumber, FieldLinePosition) : - ""), + throw new ValException (String.Format ("The key value was already found as '{0}'{1}.", Identity, + (this.FieldHasLineInfo ? + String.Format (CultureInfo.InvariantCulture, " at line {0}, position {1}", FieldLineNumber, FieldLinePosition) : + "")), sender, sourceUri, entry.OwnerSequence.SourceSchemaIdentity, null); XmlSchemaDatatype dt = schemaType as XmlSchemaDatatype; XmlSchemaSimpleType st = schemaType as XmlSchemaSimpleType; |