2017-06-30 16:00:37 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2019-01-20 16:53:23 +01:00
|
|
|
# Copyright (c), 2016-2019, SISSA (International School for Advanced Studies).
|
2017-06-30 16:00:37 +02:00
|
|
|
# All rights reserved.
|
|
|
|
# This file is distributed under the terms of the MIT License.
|
|
|
|
# See the file 'LICENSE' in the root directory of the present
|
|
|
|
# distribution, or http://opensource.org/licenses/MIT.
|
|
|
|
#
|
|
|
|
# @author Davide Brunato <brunato@sissa.it>
|
|
|
|
#
|
2018-09-15 22:18:16 +02:00
|
|
|
from __future__ import unicode_literals
|
2018-10-08 23:47:18 +02:00
|
|
|
|
2019-10-07 15:31:18 +02:00
|
|
|
from ..qnames import XSD_NOTATION, get_qname
|
2018-04-05 09:28:49 +02:00
|
|
|
from .xsdbase import XsdComponent
|
2017-06-30 16:00:37 +02:00
|
|
|
|
|
|
|
|
2018-04-05 09:28:49 +02:00
|
|
|
class XsdNotation(XsdComponent):
|
2017-06-30 16:00:37 +02:00
|
|
|
"""
|
2019-08-19 13:52:30 +02:00
|
|
|
Class for XSD *notation* declarations.
|
|
|
|
|
|
|
|
.. <notation
|
|
|
|
id = ID
|
|
|
|
name = NCName
|
|
|
|
public = token
|
|
|
|
system = anyURI
|
|
|
|
{any attributes with non-schema namespace}...>
|
|
|
|
Content: (annotation?)
|
|
|
|
</notation>
|
2017-06-30 16:00:37 +02:00
|
|
|
"""
|
2019-07-30 21:06:54 +02:00
|
|
|
_ADMITTED_TAGS = {XSD_NOTATION}
|
2018-08-06 07:11:37 +02:00
|
|
|
|
2017-07-07 12:48:19 +02:00
|
|
|
@property
|
|
|
|
def built(self):
|
|
|
|
return True
|
2017-07-03 15:29:33 +02:00
|
|
|
|
2017-06-30 16:00:37 +02:00
|
|
|
def _parse(self):
|
|
|
|
super(XsdNotation, self)._parse()
|
2019-08-19 13:52:30 +02:00
|
|
|
if self.parent is not None:
|
2019-07-29 16:01:48 +02:00
|
|
|
self.parse_error("a notation declaration must be global", self.elem)
|
2017-06-30 16:00:37 +02:00
|
|
|
try:
|
2017-07-04 16:14:26 +02:00
|
|
|
self.name = get_qname(self.target_namespace, self.elem.attrib['name'])
|
2017-06-30 16:00:37 +02:00
|
|
|
except KeyError:
|
2019-07-29 16:01:48 +02:00
|
|
|
self.parse_error("a notation must have a 'name' attribute", self.elem)
|
2017-06-30 16:00:37 +02:00
|
|
|
|
2019-03-19 10:47:41 +01:00
|
|
|
if 'public' not in self.elem.attrib and 'system' not in self.elem.attrib:
|
2019-07-29 16:01:48 +02:00
|
|
|
self.parse_error("a notation must has a 'public' or a 'system' attribute", self.elem)
|
2017-06-30 16:00:37 +02:00
|
|
|
|
|
|
|
@property
|
|
|
|
def public(self):
|
2017-07-03 15:29:33 +02:00
|
|
|
return self.elem.get('public')
|
2017-06-30 16:00:37 +02:00
|
|
|
|
|
|
|
@property
|
|
|
|
def system(self):
|
2017-07-03 15:29:33 +02:00
|
|
|
return self.elem.get('system')
|