[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8114 - trunk/gnue-common/src/definitions
From: |
reinhard |
Subject: |
[gnue] r8114 - trunk/gnue-common/src/definitions |
Date: |
Tue, 6 Dec 2005 15:25:34 -0600 (CST) |
Author: reinhard
Date: 2005-12-06 15:25:33 -0600 (Tue, 06 Dec 2005)
New Revision: 8114
Modified:
trunk/gnue-common/src/definitions/GParser.py
Log:
Check if a tag is valid under this parent.
Modified: trunk/gnue-common/src/definitions/GParser.py
===================================================================
--- trunk/gnue-common/src/definitions/GParser.py 2005-12-06 21:20:29 UTC
(rev 8113)
+++ trunk/gnue-common/src/definitions/GParser.py 2005-12-06 21:25:33 UTC
(rev 8114)
@@ -356,15 +356,36 @@
#
assert gDebug (7, "<%s>" % tname)
- try:
- baseAttrs = self.xmlElements [tname].get ('Attributes', {})
-
- except KeyError:
+ # Check whether this tag is valid at all
+ if not self.xmlElements.has_key (tname):
raise MarkupError, \
(u_("Error processing <%(tagname)s> tag [I do not know what a "
- "<%(tagname)s> tag does]") % {'tagname': tname}, self.url,
- self.parser.getLineNumber ())
+ "<%(tagname)s> tag does]") % {'tagname': tname},
+ self.url,
+ self.parser.getLineNumber ())
+ # The definition for this tag
+ elementDefinition = self.xmlElements [tname]
+
+ # Check whether this tag is valid for the current parent
+ if self.nameStack:
+ ok = False
+ if self.nameStack [0] in elementDefinition.get ('ParentTags', []):
+ ok = True
+ elif elementDefinition.get ('UsableBySiblings', False):
+ for ancestor in self.nameStack:
+ if ancestor in elementDefinition.get ('ParentTags', []):
+ ok = True
+ break
+ if not ok:
+ raise MarkupError, \
+ (u_("Error processing <%(tagname)s> tag [tag not allowed at "
+ "this position]") % {'tagname': tname},
+ self.url,
+ self.parser.getLineNumber ())
+
+ baseAttrs = elementDefinition.get ('Attributes', {})
+
xmlns = {}
for qattr in attrs.keys ():
@@ -436,9 +457,9 @@
if self.bootstrapflag:
if self.xmlStack [0] is not None:
- object = self.xmlElements [tname]['BaseClass'] (self.xmlStack [0])
+ object = elementDefinition ['BaseClass'] (self.xmlStack [0])
else:
- object = self.xmlElements [tname]['BaseClass'] ()
+ object = elementDefinition ['BaseClass'] ()
self.root = object
self.bootstrapflag = 1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8114 - trunk/gnue-common/src/definitions,
reinhard <=