MCPcopy Create free account
hub / github.com/sissaschool/xmlschema / normalize

Method normalize

xmlschema/validators/simple_types.py:447–463  ·  view source on GitHub ↗

Normalize and restrict value-space with pre-lexical and lexical facets. :param text: text string encoded value. :return: a normalized string.

(self, text: str | bytes)

Source from the content-addressed store, hash-verified

445 any(self.is_derived(mt) for mt in other.member_types)
446
447 def normalize(self, text: str | bytes) -> str:
448 """
449 Normalize and restrict value-space with pre-lexical and lexical facets.
450
451 :param text: text string encoded value.
452 :return: a normalized string.
453 """
454 if isinstance(text, bytes):
455 text = text.decode('utf-8')
456
457 match self.white_space:
458 case 'replace':
459 return self._REGEX_SPACE.sub(' ', text)
460 case 'collapse':
461 return self._REGEX_SPACES.sub(' ', text).strip()
462 case _:
463 return text
464
465 def text_decode(self, text: str, validation: str = 'skip',
466 context: ValidationContext | None = None) -> DecodedValueType:

Callers 12

raw_decodeMethod · 0.95
raw_encodeMethod · 0.95
raw_decodeMethod · 0.45
is_restrictionMethod · 0.45
raw_decodeMethod · 0.45
raw_encodeMethod · 0.45
raw_decodeMethod · 0.45
raw_decodeMethod · 0.45
raw_encodeMethod · 0.45
raw_decodeMethod · 0.45
raw_encodeMethod · 0.45
_parseMethod · 0.45

Calls 1

decodeMethod · 0.45

Tested by

no test coverage detected