xml-types 0.2 → 0.3
raw patch · 2 files changed
+12/−37 lines, 2 filesdep −containers
Dependencies removed: containers
Files
- Data/XML/Types.hs +11/−35
- xml-types.cabal +1/−2
Data/XML/Types.hs view
@@ -36,8 +36,6 @@ -- ** Doctypes , Doctype (..) , ExternalID (..)- , DoctypeNode (..)- , Declaration -- ** Incremental processing , Event (..)@@ -68,7 +66,6 @@ , attributeText ) where import Control.Monad ((>=>))-import qualified Data.Map as M import Data.Maybe (isJust) import Data.Text (Text) import qualified Data.Text as T@@ -126,7 +123,7 @@ data Element = Element { elementName :: Name- , elementAttributes :: M.Map Name [Content]+ , elementAttributes :: [(Name, [Content])] , elementNodes :: [Node] } deriving (Show, Eq)@@ -180,15 +177,17 @@ (ns, local) -> Name (T.pack (drop 1 local)) (Just (T.pack ns)) Nothing fromString local = Name (T.pack local) Nothing Nothing +-- | Note: due to the incredible complexity of DTDs, this type only supports+-- external subsets. I've tried adding internal subset types, but they+-- quickly gain more code than the rest of this module put together.+--+-- It is possible that some future version of this library might support+-- internal subsets, but I am no longer actively working on adding them. data Doctype = Doctype { doctypeName :: Text- , doctypeExternalID :: Maybe ExternalID- , doctypeNodes :: [DoctypeNode]+ , doctypeID :: Maybe ExternalID }- deriving (Show, Eq)--instance Ord Doctype where- compare = compare `on` (\x -> (doctypeName x, doctypeExternalID x))+ deriving (Show, Eq, Ord) instance Typeable Doctype where typeOf = typeString "Doctype"@@ -201,28 +200,6 @@ instance Typeable ExternalID where typeOf = typeString "ExternalID" -data DoctypeNode- = DoctypeDeclaration Declaration- | DoctypeInstruction Instruction- | DoctypeComment Text- deriving (Show, Eq)--instance Typeable DoctypeNode where- typeOf = typeString "DoctypeNode"---- | Internal doctype declarations are still largely unimplemented. This--- type will be populated and published in a later version of @xml-types@.----data Declaration- = DeclareElement Text- | DeclareAttributeList Text- | DeclareEntity Text- | DeclareNotation Text- deriving (Show, Eq)--instance Typeable Declaration where- typeOf = typeString "Declaration"- -- | Some XML processing tools are incremental, and work in terms of events -- rather than node trees. The 'Event' type allows a document to be fully -- specified as a sequence of events.@@ -239,10 +216,9 @@ = EventBeginDocument | EventEndDocument | EventBeginDoctype Text (Maybe ExternalID)- | EventDeclaration Declaration | EventEndDoctype | EventInstruction Instruction- | EventBeginElement Name (M.Map Name [Content])+ | EventBeginElement Name [(Name, [Content])] | EventEndElement Name | EventContent Content | EventComment Text@@ -296,7 +272,7 @@ hasAttributeText name p e = [e | maybe False p (attributeText name e)] attributeContent :: Name -> Element -> Maybe [Content]-attributeContent name e = M.lookup name (elementAttributes e)+attributeContent name e = lookup name (elementAttributes e) attributeText :: Name -> Element -> Maybe Text attributeText name e = fmap contentFlat (attributeContent name e)
xml-types.cabal view
@@ -1,5 +1,5 @@ name: xml-types-version: 0.2+version: 0.3 synopsis: Basic types for representing XML license: MIT license-file: license.txt@@ -21,7 +21,6 @@ build-depends: base >=3 && < 5 , text- , containers exposed-modules: Data.XML.Types