1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#
# Copyright (c), 2023, SISSA (International School for Advanced Studies).
# 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>
#
from typing import Optional
from elementpath import XPath2Parser, XPathToken, XPathContext
class XsdAssertionXPathParser(XPath2Parser):
"""Parser for XSD 1.1 assertion facets."""
XsdAssertionXPathParser.unregister('last')
XsdAssertionXPathParser.unregister('position')
# noinspection PyUnusedLocal
@XsdAssertionXPathParser.method(
XsdAssertionXPathParser.function('last', nargs=0)
)
def evaluate_last(self: XPathToken, context: Optional[XPathContext] = None) -> None:
raise self.missing_context("context item size is undefined")
# noinspection PyUnusedLocal
@XsdAssertionXPathParser.method(
XsdAssertionXPathParser.function('position', nargs=0)
)
def evaluate_position(self: XPathToken, context: Optional[XPathContext] = None) -> None:
raise self.missing_context("context item position is undefined")
|