~singpolyma/xml-types-haskell

ab1606426236c32724fda30acf931c23d4f756f2 — John Millikin 11 years ago bd7a280
Give up on supporting internal DTD subsets. They're just too complex to
work with easily, and I don't think anybody actually cares about them.

* Remove ``Declaration`` and ``DoctypeNode``.

* Rename ``doctypeExternalID`` to ``doctypeID``

* Add explanatory comment to ``Doctype``, regarding why it doesn't support
  internal subsets.
1 files changed, 8 insertions(+), 31 deletions(-)

M Data/XML/Types.hs
M Data/XML/Types.hs => Data/XML/Types.hs +8 -31
@@ 36,8 36,6 @@ module Data.XML.Types
	-- ** Doctypes
	, Doctype (..)
	, ExternalID (..)
	, DoctypeNode (..)
	, Declaration
	
	-- ** Incremental processing
	, Event (..)


@@ 179,15 177,17 @@ instance IsString Name where
		(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"


@@ 200,28 200,6 @@ data ExternalID
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.


@@ 238,7 216,6 @@ data Event
	= EventBeginDocument
	| EventEndDocument
	| EventBeginDoctype Text (Maybe ExternalID)
	| EventDeclaration Declaration
	| EventEndDoctype
	| EventInstruction Instruction
	| EventBeginElement Name [(Name, [Content])]