@@ -218,12 +218,12 @@ def from_string(self, string):
218
218
def check_mandatory_arguments (self , data , ArgClass , tag_name , node ):
219
219
for k , v in ArgClass .arguments :
220
220
if v != 0 and not ArgClass .map (k ) in data :
221
- self .error ("missing element <%s> within <%s> tag" %
221
+ self .error ("missing element <%s> within <%s> tag\n " %
222
222
(k , tag_name ) + repr (data ), node )
223
223
224
224
def is_valid_argument (self , tag_name , ArgClass , parent_node , child = None ):
225
225
if tag_name not in ArgClass .arguments_keys :
226
- self .error ("Invalid element <%s> inside <%s> tag" %
226
+ self .error ("Invalid element <%s> inside <%s> tag\n " %
227
227
(tag_name , parent_node .tag ),
228
228
parent_node if child is None else child )
229
229
@@ -247,7 +247,7 @@ def warn(self, msg, elem):
247
247
248
248
def parse_element (self , node ):
249
249
if node .tag not in self .tags :
250
- self .error ("Invalid element <%s>" % node .tag , node )
250
+ self .error ("Invalid element <%s> " % node .tag , node )
251
251
return None # won't be able to parse this one
252
252
return getattr (self , "parse_" + node .tag )(node , self .tags [node .tag ])
253
253
@@ -273,7 +273,7 @@ def parse_tag(self, root, fmt, insert_children=True):
273
273
continue
274
274
275
275
# We currently do not support XML attributes.
276
- self .error ("Attribute not supported, ignoring '%s=%s'" % (k , v ), root )
276
+ self .error ("Attribute not supported, ignoring '%s=%s' " % (k , v ), root )
277
277
278
278
for node in root :
279
279
node .tag = node .tag .lower ()
@@ -299,7 +299,7 @@ def parse_tag(self, root, fmt, insert_children=True):
299
299
else :
300
300
arguments [tag ] = curr_text
301
301
else :
302
- self .error ("Invalid element <%s> in odML document section <%s>"
302
+ self .error ("Invalid element <%s> in odML document section <%s> "
303
303
% (node .tag , root .tag ), node )
304
304
305
305
if sys .version_info > (3 ,):
@@ -310,7 +310,11 @@ def parse_tag(self, root, fmt, insert_children=True):
310
310
self .check_mandatory_arguments (check_args , fmt , root .tag , root )
311
311
312
312
# Instantiate the current odML object with the parsed attributes.
313
- obj = fmt .create (** arguments )
313
+ obj = fmt .create ()
314
+ try :
315
+ obj = fmt .create (** arguments )
316
+ except Exception as e :
317
+ self .error (str (e ), root )
314
318
315
319
if insert_children :
316
320
for child in children :
0 commit comments