Ejemplo 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)
Ejemplo 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.")
Ejemplo 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.")
Ejemplo 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.")
Ejemplo 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.")
Ejemplo 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)
Ejemplo 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.")
Ejemplo 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.")
Ejemplo 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
Ejemplo n.º 10
0
def non_positive_int_validator(x):
    if x > 0:
        yield XMLSchemaValidationError(non_positive_int_validator, x, "value must be non positive.")
Ejemplo n.º 11
0
def non_negative_int_validator(x):
    if x < 0:
        yield XMLSchemaValidationError(non_negative_int_validator, x, "value must be non negative.")
Ejemplo n.º 12
0
def positive_int_validator(x):
    if x <= 0:
        yield XMLSchemaValidationError(positive_int_validator, x, "value must be positive.")
Ejemplo n.º 13
0
def negative_int_validator(x):
    if x >= 0:
        yield XMLSchemaValidationError(negative_int_validator, x, reason="value must be negative.")
Ejemplo 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.")
Ejemplo 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)
Ejemplo 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))
Ejemplo n.º 17
0
 def length_validator(self, x):
     if len(x) != self.value:
         yield XMLSchemaValidationError(self, x,
                                        "length has to be %r." % self.value)
Ejemplo 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.")
Ejemplo 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)
Ejemplo 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.")