utils.xml

Xml utils for the core applications

utils.xml.convert_value(value)

Convert the value to the true type

Parameters:value

Returns:

utils.xml.get_hash(xml_string)

Get the hash of an XML string.

Parameters:xml_string

Returns:

utils.xml.get_imports_and_includes(xsd_string)

Get a list of imports and includes in the file.

Parameters:xsd_string

Returns: list of imports, list of includes

utils.xml.get_local_dependencies(xsd_string)

Get local dependencies from an xsd.

Parameters:xsd_string – XSD as string.
Returns:Local dependencies
utils.xml.get_template_with_server_dependencies(xsd_string, dependencies)

Return the template with schema locations pointing to the server.

Parameters:
  • xsd_string
  • dependencies

Returns:

utils.xml.has_xsl_namespace(xml_string)

True if XML has the XSL namespace.

Parameters:xml_string

Returns:

utils.xml.is_schema_valid(xsd_string)

Test if the schema is valid to be uploaded.

Parameters:xsd_string

Returns:

utils.xml.is_well_formed_xml(xml_string)

True if well formatted XML.

Parameters:xml_string

Returns:

utils.xml.post_processor(path, key, value)

Called after XML to JSON transformation.

Parameters:
  • path
  • key
  • value

Returns:

utils.xml.raw_xml_to_dict(raw_xml, postprocessor=None)

Transform a raw xml to dict. Returns an empty dict if the parsing failed.

Parameters:
  • raw_xml
  • postprocessor

Returns:

utils.xml.remove_lists_from_xml_dict(xml_dict, max_list_size=0)

Remove from dictionary the lists that exceed max list size.

Parameters:
  • xml_dict
  • max_list_size

Returns:

utils.xml.unparse(json_dict)

Unparse JSON data.

Parameters:json_dict

Returns:

utils.xml.update_dependencies(xsd_string, dependencies)

Update dependencies of the schemas with given dependencies.

Parameters:
  • xsd_string
  • dependencies

Returns:

utils.xml.validate_xml_data(xsd_tree, xml_tree)

Check if XML data is valid, send XML data to server to be validated if XERCES_VALIDATION is true

Parameters:
  • xsd_tree
  • xml_tree

Returns:None if no errors, string otherwise

utils.xml.validate_xml_schema(xsd_tree)

Check if XSD schema is valid, send XSD Schema to server to be validated if XERCES_VALIDATION is true.

Parameters:xsd_tree

Returns: None if no errors, string otherwise

utils.xml.xsl_transform(xml_string, xslt_string)

Apply transformation to xml.

Parameters:
  • xml_string
  • xslt_string

Returns: