Author: atsushi
Date: 2006-04-18 05:48:46 -0400 (Tue, 18 Apr 2006)
New Revision: 59581

Modified:
   trunk/mcs/class/Commons.Xml.Relaxng/Commons.Xml.Nvdl/ChangeLog
   trunk/mcs/class/Commons.Xml.Relaxng/Commons.Xml.Nvdl/NvdlSimplified.cs
   trunk/mcs/class/Commons.Xml.Relaxng/Commons.Xml.Nvdl/NvdlValidator.cs
Log:
2006-04-18  Atsushi Enomoto <[EMAIL PROTECTED]>

        * NvdlSimplified.cs, NvdlValidator.cs :
          Support for revised "trigger" in FDIS was not enough. The validator
          must not trigger such element that has a parent which could be
          triggered (the parent does not have to be actually triggered).
          Thus, introduced a new class SimpleTrigger which holds own qname
          array.



Modified: trunk/mcs/class/Commons.Xml.Relaxng/Commons.Xml.Nvdl/ChangeLog
===================================================================
--- trunk/mcs/class/Commons.Xml.Relaxng/Commons.Xml.Nvdl/ChangeLog      
2006-04-18 09:41:23 UTC (rev 59580)
+++ trunk/mcs/class/Commons.Xml.Relaxng/Commons.Xml.Nvdl/ChangeLog      
2006-04-18 09:48:46 UTC (rev 59581)
@@ -1,5 +1,14 @@
 2006-04-18  Atsushi Enomoto <[EMAIL PROTECTED]>
 
+       * NvdlSimplified.cs, NvdlValidator.cs :
+         Support for revised "trigger" in FDIS was not enough. The validator
+         must not trigger such element that has a parent which could be
+         triggered (the parent does not have to be actually triggered).
+         Thus, introduced a new class SimpleTrigger which holds own qname
+         array.
+
+2006-04-18  Atsushi Enomoto <[EMAIL PROTECTED]>
+
        * NvdlSimplified.cs : according to the section 6.4.10 overriden rules
          should be filtered out, and rules with cancelNestedAction should be
          removed *after* filtering overriden rules out.

Modified: trunk/mcs/class/Commons.Xml.Relaxng/Commons.Xml.Nvdl/NvdlSimplified.cs
===================================================================
--- trunk/mcs/class/Commons.Xml.Relaxng/Commons.Xml.Nvdl/NvdlSimplified.cs      
2006-04-18 09:41:23 UTC (rev 59580)
+++ trunk/mcs/class/Commons.Xml.Relaxng/Commons.Xml.Nvdl/NvdlSimplified.cs      
2006-04-18 09:48:46 UTC (rev 59581)
@@ -46,7 +46,7 @@
        internal class SimpleRules : SimplifiedItem
        {
                SimpleMode startMode;
-               XmlQualifiedName [] triggers;
+               SimpleTrigger [] triggers;
 
                // FIXME: It is not used in validation step, so move it to
                // compile context
@@ -64,7 +64,7 @@
                        get { return startMode; }
                }
 
-               public XmlQualifiedName [] Triggers {
+               public SimpleTrigger [] Triggers {
                        get { return triggers; }
                }
 
@@ -123,17 +123,10 @@
                        // 6.4.10 : done in SimpleRule.Simplify
 
                        ArrayList tl = new ArrayList ();
-                       for (int i = 0; i < rules.Triggers.Count; i++) {
-                               NvdlTrigger t = rules.Triggers [i];
-                               foreach (string ss in t.NameList.Split (' ')) {
-                                       string s = ss.Trim ();
-                                       if (s.Length == 0)
-                                               continue;
-                                       tl.Add (new XmlQualifiedName (s, t.NS));
-                               }
-                       }
-                       triggers = (XmlQualifiedName []) tl.ToArray (
-                               typeof (XmlQualifiedName));
+                       for (int i = 0; i < rules.Triggers.Count; i++)
+                               tl.Add (new SimpleTrigger (rules.Triggers [i]));
+                       triggers = (SimpleTrigger []) tl.ToArray (
+                               typeof (SimpleTrigger));
 
                        modes = (SimpleMode [])
                                new ArrayList (ctx.GetCompiledModes ())
@@ -154,6 +147,40 @@
                #endregion
        }
 
+       internal class SimpleTrigger : SimplifiedItem
+       {
+               XmlQualifiedName [] names;
+
+               public SimpleTrigger (NvdlTrigger trigger)
+               {
+                       FillLocation (trigger);
+
+                       ArrayList al = new ArrayList ();
+                       foreach (string ss in trigger.NameList.Split (' ')) {
+                               string s = ss.Trim ();
+                               if (s.Length == 0)
+                                       continue;
+                               al.Add (new XmlQualifiedName (s, trigger.NS));
+                       }
+                       names = (XmlQualifiedName []) al.ToArray (
+                               typeof (XmlQualifiedName));
+               }
+
+               public XmlQualifiedName [] Names {
+                       get { return names; }
+               }
+
+               public bool Cover (string localName, string ns)
+               {
+                       for (int i = 0; i < Names.Length; i++) {
+                               XmlQualifiedName q = Names [i];
+                               if (q.Name == localName && q.Namespace == ns)
+                                       return true;
+                       }
+                       return false;
+               }
+       }
+
        internal class SimpleMode : SimplifiedItem
        {
                string name;

Modified: trunk/mcs/class/Commons.Xml.Relaxng/Commons.Xml.Nvdl/NvdlValidator.cs
===================================================================
--- trunk/mcs/class/Commons.Xml.Relaxng/Commons.Xml.Nvdl/NvdlValidator.cs       
2006-04-18 09:41:23 UTC (rev 59580)
+++ trunk/mcs/class/Commons.Xml.Relaxng/Commons.Xml.Nvdl/NvdlValidator.cs       
2006-04-18 09:48:46 UTC (rev 59581)
@@ -21,6 +21,12 @@
                // IsEmptyElement is true).
                NvdlSectionStack sectionStack = new NvdlSectionStack ();
 
+               // This qname stack is required for section 7.3 check that
+               // if parent "element" of an element (note that it is not
+               // "element section") must not be located by the same
+               // trigger element
+               Stack qnameStack = new Stack ();
+
                public NvdlDispatcher (SimpleRules rules, NvdlValidatingReader 
source)
                {
                        this.validator = source;
@@ -43,17 +49,39 @@
                {
 NvdlDebug.Writer.WriteLine ("  <dispatcher.StartElement {0}. stack depth: {1}. 
current section ns {2}",
 Reader.Name, sectionStack.Count, section == null ? "(none)" : 
section.Namespace);
-                       if (section == null)
-                               section = new NvdlSection (this, null);
-                       else if (section.Namespace != Reader.NamespaceURI)
-                               section = new NvdlSection (this, section);
+                       section = GetSection (section);
 
                        sectionStack.Push (section);
                        section.StartElement ();
                        if (Reader.IsEmptyElement)
                                sectionStack.Pop ().EndSection ();
+
+                       else
+                               qnameStack.Push (new XmlQualifiedName 
(Reader.LocalName, Reader.NamespaceURI));
                }
 
+               NvdlSection GetSection (NvdlSection section)
+               {
+                       if (section == null)
+                               return new NvdlSection (this, null);
+                       else if (section.Namespace != Reader.NamespaceURI)
+                               return new NvdlSection (this, section);
+                       else if (qnameStack.Count > 0 && rules.Triggers.Length 
> 0) {
+                               for (int t = 0; t < rules.Triggers.Length; t++) 
{
+                                       SimpleTrigger st = rules.Triggers [t];
+                                       XmlQualifiedName parent =
+                                               (XmlQualifiedName) 
qnameStack.Peek ();
+                                       if (st.Cover (Reader.LocalName,
+                                                     Reader.NamespaceURI) &&
+                                           !st.Cover (parent.Name, 
parent.Namespace)) {
+NvdlDebug.Writer.WriteLine ("======== triggered by {0}", st.Location);
+                                               return new NvdlSection (this, 
section);
+                                       }
+                               }
+                       }
+                       return section;
+               }
+
                public void EndElement ()
                {
 NvdlDebug.Writer.WriteLine ("  <dispatcher.EndElement {0}. depth: {1}",
@@ -67,6 +95,8 @@
                                else
                                        section = null;
                        }
+
+                       qnameStack.Pop ();
                }
 
                public void Text ()

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to