Package xmlschema_acue :: Package validators :: Module notations

Source Code for Module xmlschema_acue.validators.notations

 1  # -*- coding: utf-8 -*- 
 2  # 
 3  # Copyright (c), 2016-2019, SISSA (International School for Advanced Studies). 
 4  # All rights reserved. 
 5  # This file is distributed under the terms of the MIT License. 
 6  # See the file 'LICENSE' in the root directory of the present 
 7  # distribution, or http://opensource.org/licenses/MIT. 
 8  # 
 9  # @author Davide Brunato <brunato@sissa.it> 
10  # 
11  from __future__ import unicode_literals 
12   
13  from xmlschema_acue.exceptions import XMLSchemaValueError 
14  from xmlschema_acue.qnames import XSD_NOTATION 
15  from xmlschema_acue.helpers import get_qname 
16   
17  from xmlschema_acue.validators.xsdbase import XsdComponent 
18 19 20 -class XsdNotation(XsdComponent):
21 """ 22 Class for XSD 'notation' declarations. 23 24 <notation 25 id = ID 26 name = NCName 27 public = token 28 system = anyURI 29 {any attributes with non-schema namespace}...> 30 Content: (annotation?) 31 </notation> 32 """ 33 _admitted_tags = {XSD_NOTATION} 34
35 - def __init__(self, elem, schema, parent):
36 if parent is not None: 37 raise XMLSchemaValueError("'parent' attribute is not None but %r must be global!" % self) 38 super(XsdNotation, self).__init__(elem, schema, parent)
39 40 @property
41 - def built(self):
42 return True
43
44 - def _parse(self):
45 super(XsdNotation, self)._parse() 46 if not self.is_global: 47 self.parse_error("a notation declaration must be global.", self.elem) 48 try: 49 self.name = get_qname(self.target_namespace, self.elem.attrib['name']) 50 except KeyError: 51 self.parse_error("a notation must have a 'name'.", self.elem) 52 53 if 'public' not in self.elem.attrib and 'system' not in self.elem.attrib: 54 self.parse_error("a notation must has a 'public' or a 'system' attribute.", self.elem)
55 56 @property
57 - def public(self):
58 return self.elem.get('public')
59 60 @property
61 - def system(self):
62 return self.elem.get('system')
63