@@ -486,12 +486,15 @@ archiveToComments zf =
486 Just c -> Comments cmts_namespaces c
486 Just c -> Comments cmts_namespaces c
487 Nothing -> Comments cmts_namespaces M.empty
487 Nothing -> Comments cmts_namespaces M.empty
489−filePathToRelType :: FilePath -> Maybe DocumentLocation
489+filePathToRelType :: FilePath -> FilePath -> Maybe DocumentLocation
490−filePathToRelType "word/_rels/document.xml.rels" = Just InDocument
491−filePathToRelType "word/_rels/document2.xml.rels" = Just InDocument
492−filePathToRelType "word/_rels/footnotes.xml.rels" = Just InFootnote
490+filePathToRelType "word/_rels/footnotes.xml.rels" _ = Just InFootnote
493−filePathToRelType "word/_rels/endnotes.xml.rels" = Just InEndnote
491+filePathToRelType "word/_rels/endnotes.xml.rels" _ = Just InEndnote
492+-- -- to see if it's a documentPath, we have to check against the dynamic
493+-- -- docPath specified in "_rels/.rels"
494−filePathToRelType _ = Nothing
494+filePathToRelType path docXmlPath =
495+ if path == "word/_rels/" ++ (takeFileName docXmlPath) ++ ".rels"
496+ then Just InDocument
496relElemToRelationship :: DocumentLocation -> Element -> Maybe Relationship
499relElemToRelationship :: DocumentLocation -> Element -> Maybe Relationship
497relElemToRelationship relType element | qName (elName element) == "Relationship" =
500relElemToRelationship relType element | qName (elName element) == "Relationship" =
@@ -501,16 +504,20 @@ relElemToRelationship relType element | qName (elName element) == "Relationship"
501 return $ Relationship relType relId target
504 return $ Relationship relType relId target
502relElemToRelationship _ _ = Nothing
505relElemToRelationship _ _ = Nothing
504−filePathToRelationships :: Archive -> FilePath -> [Relationship]
507+filePathToRelationships :: Archive -> (Maybe FilePath) -> FilePath -> [Relationship]
508+filePathToRelationships ar mDocXmlPath fp
509+ | Just docXmlPath <- mDocXmlPath
505−filePathToRelationships ar fp | Just relType <- filePathToRelType fp
510+ , Just relType <- filePathToRelType fp docXmlPath
506− , Just entry <- findEntryByPath fp ar
511+ , Just entry <- findEntryByPath fp ar
507− , Just relElems <- (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry =
512+ , Just relElems <- (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry =
508 mapMaybe (relElemToRelationship relType) $ elChildren relElems
513 mapMaybe (relElemToRelationship relType) $ elChildren relElems
509−filePathToRelationships _ _ = []
514+filePathToRelationships _ _ _ = []
511archiveToRelationships :: Archive -> [Relationship]
516archiveToRelationships :: Archive -> [Relationship]
512archiveToRelationships archive =
517archiveToRelationships archive =
518+ let mDocXmlPath = getDocumentPath archive
513− concatMap (filePathToRelationships archive) $ filesInArchive archive
520+ concatMap (filePathToRelationships archive mDocXmlPath) $ filesInArchive archive
515filePathIsMedia :: FilePath -> Bool
522filePathIsMedia :: FilePath -> Bool
516filePathIsMedia fp =
523filePathIsMedia fp =