Esempio n. 1
0
def parse_schema_file(file_name,
                      files=None,
                      repr_=Thier_repr(with_ns=False),
                      skip_errors=False):
    """Parses a schema file and returns a _Schema object. Schema files typically
    have the `*.xsd` extension.

    :param file_name: The path to the file that contains the schema document
        to be parsed.
    :param files: A dict that maps namespaces to path to schema files that
        contain the schema document for those namespaces.
    :param repr_: A callable that functions as `repr`.
    :param skip_errors: Skip parsing errors and return a partial schema.
        See debug log for details.

    :return: :class:`spyne.interface.xml_schema.parser._Schema` instance.
    """

    if files is None:
        files = dict()

    elt = etree.fromstring(open(file_name, 'rb').read(), parser=PARSER)
    wd = abspath(dirname(file_name))
    return XmlSchemaParser(files, wd, repr_=repr_,
                           skip_errors=skip_errors).parse_schema(elt)
Esempio n. 2
0
def parse_schema_element(elt, files={}, repr_=Thier_repr(with_ns=False),
                                                         skip_errors=False):
    """Parses a `<xs:schema>` element and returns a _Schema object.

    :param elt: The `<xs:schema>` element, an lxml.etree._Element instance.
    :param files: A dict that maps namespaces to path to schema files that
        contain the schema document for those namespaces.
    :param repr_: A callable that functions as `repr`.
    :param skip_errors: Skip parsing errors and return a partial schema.
        See debug log for details.

    :return: :class:`spyne.interface.xml_schema.parser._Schema` instance.
    """

    return XmlSchemaParser(files, repr_=repr_,
                            skip_errors=skip_errors).parse_schema(elt)
Esempio n. 3
0
def parse_schema_string(s, files={}, repr_=Thier_repr(with_ns=False),
                                                         skip_errors=False):
    """Parses a schema string and returns a _Schema object.

    :param s: The string or bytes object that contains the schema document.
    :param files: A dict that maps namespaces to path to schema files that
        contain the schema document for those namespaces.
    :param repr_: A callable that functions as `repr`.
    :param skip_errors: Skip parsing errors and return a partial schema.
        See debug log for details.

    :return: :class:`spyne.interface.xml_schema.parser._Schema` instance.
    """

    elt = etree.fromstring(s, parser=PARSER)
    return XmlSchemaParser(files, repr_=repr_,
                            skip_errors=skip_errors).parse_schema(elt)
Esempio n. 4
0
def parse_schema_file(file_name, files={}, repr_=Thier_repr(with_ns=False)):
    elt = etree.fromstring(open(file_name, 'rb').read(), parser=PARSER)
    return XmlSchemaParser(files, abspath(dirname(file_name)), repr_=repr_) \
                                                             .parse_schema(elt)
Esempio n. 5
0
def parse_schema_element(elt, files={}, repr_=Thier_repr(with_ns=False)):
    return XmlSchemaParser(files, repr_=repr_).parse_schema(elt)
Esempio n. 6
0
def parse_schema_string(s, files={}, repr_=Thier_repr(with_ns=False)):
    elt = etree.fromstring(s, parser=PARSER)
    return XmlSchemaParser(files, repr_=repr_).parse_schema(elt)