def check_optional(name, allowXHTML=False, merge_multiple=False):
 def check(n, filename):
  n = get_nodes_by_name(n, name)
  if ((len(n) > 1) and (not merge_multiple)):
   raise ManifestException(("Invalid manifest file: must have a single '%s' element" % name))
  if n:
   values = []
   for child in n:
    if allowXHTML:
     values.append(''.join([x.toxml() for x in child.childNodes]))
    else:
     values.append(_get_text(child.childNodes).strip())
   return ', '.join(values)
 return check

def check_optional ( name , allowXHTML = False , merge_multiple = False ) : def check ( n , filename ) : n = get_nodes_by_name ( n , name ) if ( ( len ( n ) > 1 ) and ( not merge_multiple ) ) : raise ManifestException ( ( "Invalid manifest file: must have a single '%s' element" % name ) ) if n : values = [ ] for child in n : if allowXHTML : values . append ( '' . join ( [ x . toxml ( ) for x in child . childNodes ] ) ) else : values . append ( _get_text ( child . childNodes ) . strip ( ) ) return ', ' . join ( values ) return check
validator for optional elements .