def alternate_content_is_replaced_by_contents_of_fallback(): xml_string = ( '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + '<numbering xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">' + '<mc:AlternateContent>' + '<mc:Choice Requires="w14">' + '<choice/>' + '</mc:Choice>' + '<mc:Fallback>' + '<fallback/>' + '</mc:Fallback>' + '</mc:AlternateContent>' + '</numbering>') result = office_xml.read(io.StringIO(xml_string)) assert_equal([xml.element("fallback")], result.children)
def _read_content_types_xml(fileobj): with open_zip(fileobj, "r") as zip_file: return xml.parse_xml( io.StringIO(zip_file.read_str("[Content_Types].xml")), [("ct", "http://schemas.openxmlformats.org/package/2006/content-types")], ) original_relationships_xml = ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">' + '<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/>' + '</Relationships>') expected_relationships_xml = xml.element("r:Relationships", {}, [ xml.element("r:Relationship", {"Id": "rId3", "Type": "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings", "Target": "settings.xml"}), xml.element("r:Relationship", {"Id": "rMammothStyleMap", "Type": "http://schemas.zwobble.org/mammoth/style-map", "Target": "/mammoth/style-map"}), ]) original_content_types_xml = ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">' + '<Default Extension="png" ContentType="image/png"/>' + '</Types>' ) expected_content_types_xml = xml.element("ct:Types", {}, [ xml.element("ct:Default", {"Extension": "png", "ContentType": "image/png"}), xml.element("ct:Override", {"PartName": "/mammoth/style-map", "ContentType": "text/prs.mammoth.style-map"}), ]) def _normal_docx():
original_relationships_xml = ( '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">' + '<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/>' + '</Relationships>') expected_relationships_xml = xml.element("r:Relationships", {}, [ xml.element( "r:Relationship", { "Id": "rId3", "Type": "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings", "Target": "settings.xml" }), xml.element( "r:Relationship", { "Id": "rMammothStyleMap", "Type": "http://schemas.zwobble.org/mammoth/style-map", "Target": "/mammoth/style-map" }), ]) original_content_types_xml = ( '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">' + '<Default Extension="png" ContentType="image/png"/>' + '</Types>') expected_content_types_xml = xml.element("ct:Types", {}, [ xml.element("ct:Default", {