File: xpath3.py

package info (click to toggle)
python-xmlschema 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,208 kB
  • sloc: python: 39,174; xml: 1,282; makefile: 36
file content (42 lines) | stat: -rw-r--r-- 1,379 bytes parent folder | download
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
36
37
38
39
40
41
42
#
# 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>
#
"""
Optional module for handling XPath 3 parsing on XSD 1.1 assertions.
"""
from typing import Optional

from elementpath import XPathToken, XPathContext
from elementpath.xpath3 import XPath3Parser

__all__ = ['XPath3Parser', 'XsdAssertionXPath3Parser']


class XsdAssertionXPath3Parser(XPath3Parser):
    """Parser for XSD 1.1 assertion facets with XPath 3."""


XsdAssertionXPath3Parser.unregister('last')
XsdAssertionXPath3Parser.unregister('position')


# noinspection PyUnusedLocal
@XsdAssertionXPath3Parser.method(
    XsdAssertionXPath3Parser.function('last', nargs=0)
)
def evaluate_last(self: XPathToken, context: Optional[XPathContext] = None) -> None:
    raise self.missing_context("context item size is undefined")  # pragma: no cover


# noinspection PyUnusedLocal
@XsdAssertionXPath3Parser.method(
    XsdAssertionXPath3Parser.function('position', nargs=0)
)
def evaluate_position(self: XPathToken, context: Optional[XPathContext] = None) -> None:
    raise self.missing_context("context item position is undefined")  # pragma: no cover