Esempio n. 1
0
 def __call__(self, elem):
     if not self.token.evaluate(XPathContext(root=elem)):
         msg = "expression is not true with test path %r."
         yield XMLSchemaValidationError(self,
                                        obj=elem,
                                        reason=msg % self.path)
Esempio n. 2
0
def long_validator(x):
    if not (-2**127 <= x < 2**127):
        yield XMLSchemaValidationError(long_validator, x, "value must be -2^127 <= x < 2^127.")
Esempio n. 3
0
def unsigned_byte_validator(x):
    if not (0 <= x < 2**8):
        yield XMLSchemaValidationError(unsigned_byte_validator, x, "value must be 0 <= x < 256.")
Esempio n. 4
0
def short_validator(x):
    if not (-2**15 <= x < 2**15):
        yield XMLSchemaValidationError(short_validator, x, "value must be -2^16 <= x < 2^16.")
Esempio n. 5
0
def int_validator(x):
    if not (-2**63 <= x < 2**63):
        yield XMLSchemaValidationError(int_validator, x, "value must be -2^63 <= x < 2^63.")
Esempio n. 6
0
 def hex_length_validator(self, x):
     if len(x) != self.value * 2:
         yield XMLSchemaValidationError(
             self, x, "binary length has to be %r." % self.value)
Esempio n. 7
0
def unsigned_int_validator(x):
    if not (0 <= x < 2**64):
        yield XMLSchemaValidationError(unsigned_int_validator, x, "value must be 0 <= x < 2^64.")
Esempio n. 8
0
def hex_binary_validator(x):
    if x and (len(x) % 2 or HEX_BINARY_PATTERN.match(x) is None):
        yield XMLSchemaValidationError(hex_binary_validator, x, "not an hexadecimal number.")
Esempio n. 9
0
def finite_number_validator(x):
    try:
        if isinf(x) or isnan(x):
            yield XMLSchemaValidationError(finite_number_validator, x, "value {!r} is not an xs:decimal".format(x))
    except TypeError:
        pass
Esempio n. 10
0
def non_positive_int_validator(x):
    if x > 0:
        yield XMLSchemaValidationError(non_positive_int_validator, x, "value must be non positive.")
Esempio n. 11
0
def non_negative_int_validator(x):
    if x < 0:
        yield XMLSchemaValidationError(non_negative_int_validator, x, "value must be non negative.")
Esempio n. 12
0
def positive_int_validator(x):
    if x <= 0:
        yield XMLSchemaValidationError(positive_int_validator, x, "value must be positive.")
Esempio n. 13
0
def negative_int_validator(x):
    if x >= 0:
        yield XMLSchemaValidationError(negative_int_validator, x, reason="value must be negative.")
Esempio n. 14
0
def unsigned_long_validator(x):
    if not (0 <= x < 2**128):
        yield XMLSchemaValidationError(unsigned_long_validator, x, "value must be 0 <= x < 2^128.")
Esempio n. 15
0
 def collapse_white_space_validator(self, x):
     if '\t' in x or '\n' in x or '  ' in x:
         yield XMLSchemaValidationError(self, x)
Esempio n. 16
0
def qname_validator(x):
    if datatypes.QNAME_PATTERN.match(x) is None:
        yield XMLSchemaValidationError(qname_validator, x, "value {!r} is not an xs:QName".format(x))
Esempio n. 17
0
 def length_validator(self, x):
     if len(x) != self.value:
         yield XMLSchemaValidationError(self, x,
                                        "length has to be %r." % self.value)
Esempio n. 18
0
def byte_validator(x):
    if not (-2**7 <= x < 2**7):
        yield XMLSchemaValidationError(int_validator, x, "value must be -128 <= x < 128.")
Esempio n. 19
0
 def base64_length_validator(self, x):
     x = x.replace(' ', '')
     if (len(x) // 4 * 3 - (x[-1] == '=') - (x[-2] == '=')) != self.value:
         yield XMLSchemaValidationError(
             self, x, "binary length has to be %r." % self.value)
Esempio n. 20
0
def unsigned_short_validator(x):
    if not (0 <= x < 2**16):
        yield XMLSchemaValidationError(unsigned_short_validator, x, "value must be 0 <= x < 2^32.")