Docx reader utils: handle empty namespace in elemName

Previously, if given an empty namespace:

    (elemName ns "" "foo")

`elemName` would output a QName with a `Just ""` namespace. This is
never what we want. Now we output a `Nothing`. If someone *does* want a
`Just ""` in the namespace, they can enter the QName value explicitly.
This commit is contained in:
Jesse Rosenthal 2016-11-02 11:51:53 -04:00
parent bdda4b185b
commit 1138ae6656

View file

@ -18,7 +18,8 @@ attrToNSPair (Attr (QName s _ (Just "xmlns")) val) = Just (s, val)
attrToNSPair _ = Nothing
elemName :: NameSpaces -> String -> String -> QName
elemName ns prefix name = QName name (lookup prefix ns) (Just prefix)
elemName ns prefix name =
QName name (lookup prefix ns) (if null prefix then Nothing else Just prefix)
isElem :: NameSpaces -> String -> String -> Element -> Bool
isElem ns prefix name element =