module Text.XML.HXT.DTDValidation.Validation
( getDTDSubset
, generalEntitiesDefined
, validate
, validateDTD
, validateDoc
, removeDoublicateDefs
, transform
)
where
import Text.XML.HXT.DTDValidation.TypeDefs
import qualified Text.XML.HXT.DTDValidation.DocTransformation as DocTransformation
import qualified Text.XML.HXT.DTDValidation.DocValidation as DocValidation
import qualified Text.XML.HXT.DTDValidation.DTDValidation as DTDValidation
import qualified Text.XML.HXT.DTDValidation.IdValidation as IdValidation
validate :: XmlArrow
validate :: XmlArrow
validate = XmlArrow
validateDTD XmlArrow -> XmlArrow -> XmlArrow
forall (a :: * -> * -> *) b c.
ArrowPlus a =>
a b c -> a b c -> a b c
<+> XmlArrow
validateDoc
validateDTD :: XmlArrow
validateDTD :: XmlArrow
validateDTD = [IfThen XmlArrow XmlArrow] -> XmlArrow
forall (a :: * -> * -> *) b c d.
ArrowIf a =>
[IfThen (a b c) (a b d)] -> a b d
choiceA
[ XmlArrow
getDTDSubset XmlArrow -> XmlArrow -> IfThen XmlArrow XmlArrow
forall a b. a -> b -> IfThen a b
:-> XmlArrow
DTDValidation.validateDTD
, XmlArrow
forall (a :: * -> * -> *) b. ArrowList a => a b b
this XmlArrow -> XmlArrow -> IfThen XmlArrow XmlArrow
forall a b. a -> b -> IfThen a b
:-> String -> XmlArrow
forall (a :: * -> * -> *) n. ArrowXml a => String -> a n XmlTree
err String
"Can't validate DTD: There is no DOCTYPE declaration in the document."
]
validateDoc :: XmlArrow
validateDoc :: XmlArrow
validateDoc
= [XmlTree] -> XmlArrow
validateDoc' ([XmlTree] -> XmlArrow) -> LA XmlTree [XmlTree] -> XmlArrow
forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< LA XmlTree [XmlTree]
getDTD
where
validateDoc' :: [XmlTree] -> XmlArrow
validateDoc' [] = String -> XmlArrow
forall (a :: * -> * -> *) n. ArrowXml a => String -> a n XmlTree
err String
"Can't validate document: There is no DOCTYPE declaration in the document."
validateDoc' (XmlTree
dtdPart:[XmlTree]
_) = XmlTree -> XmlArrow
DocValidation.validateDoc XmlTree
dtdPart
XmlArrow -> XmlArrow -> XmlArrow
forall (a :: * -> * -> *) b c.
ArrowPlus a =>
a b c -> a b c -> a b c
<+>
XmlTree -> XmlArrow
IdValidation.validateIds XmlTree
dtdPart
getDTD :: XmlArrowS
getDTD :: LA XmlTree [XmlTree]
getDTD = XmlArrow -> LA XmlTree [XmlTree]
forall (a :: * -> * -> *) b c. ArrowList a => a b c -> a b [c]
listA ( XmlArrow
getDTDSubset
XmlArrow -> XmlArrow -> XmlArrow
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
XmlArrow
removeDoublicateDefs
)
transform :: XmlArrow
transform :: XmlArrow
transform = [IfThen XmlArrow XmlArrow] -> XmlArrow
forall (a :: * -> * -> *) b c d.
ArrowIf a =>
[IfThen (a b c) (a b d)] -> a b d
choiceA
[ XmlArrow
forall (a :: * -> * -> *). ArrowXml a => a XmlTree XmlTree
isRoot XmlArrow -> XmlArrow -> IfThen XmlArrow XmlArrow
forall a b. a -> b -> IfThen a b
:-> ([XmlTree] -> XmlArrow
transformDoc ([XmlTree] -> XmlArrow) -> LA XmlTree [XmlTree] -> XmlArrow
forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< LA XmlTree [XmlTree]
getDTD)
, XmlArrow
forall (a :: * -> * -> *) b. ArrowList a => a b b
this XmlArrow -> XmlArrow -> IfThen XmlArrow XmlArrow
forall a b. a -> b -> IfThen a b
:-> String -> XmlArrow
forall (a :: * -> * -> *) n. ArrowXml a => String -> a n XmlTree
fatal String
"Can't transform document: No document root given"
]
where
transformDoc :: [XmlTree] -> XmlArrow
transformDoc [] = XmlArrow
forall (a :: * -> * -> *) b. ArrowList a => a b b
this
transformDoc [XmlTree]
dtd = XmlTree -> XmlArrow
DocTransformation.transform ([XmlTree] -> XmlTree
forall a. [a] -> a
head [XmlTree]
dtd)
removeDoublicateDefs :: XmlArrow
removeDoublicateDefs :: XmlArrow
removeDoublicateDefs = XmlArrow
DTDValidation.removeDoublicateDefs
getDTDSubset :: XmlArrow
getDTDSubset :: XmlArrow
getDTDSubset = XmlArrow
forall (a :: * -> * -> *) (t :: * -> *) b.
(ArrowTree a, Tree t) =>
a (t b) (t b)
getChildren
XmlArrow -> XmlArrow -> XmlArrow
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
( LA XmlTree (AssocList String String) -> XmlArrow
forall (a :: * -> * -> *) b c. ArrowIf a => a b c -> a b b
filterA (LA XmlTree (AssocList String String) -> XmlArrow)
-> LA XmlTree (AssocList String String) -> XmlArrow
forall a b. (a -> b) -> a -> b
$ XmlArrow
forall (a :: * -> * -> *). ArrowDTD a => a XmlTree XmlTree
isDTDDoctype XmlArrow
-> LA XmlTree (AssocList String String)
-> LA XmlTree (AssocList String String)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> LA XmlTree (AssocList String String)
forall (a :: * -> * -> *).
ArrowXml a =>
a XmlTree (AssocList String String)
getDTDAttrl LA XmlTree (AssocList String String)
-> LA (AssocList String String) (AssocList String String)
-> LA XmlTree (AssocList String String)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (AssocList String String -> Bool)
-> LA (AssocList String String) (AssocList String String)
forall (a :: * -> * -> *) b. ArrowList a => (b -> Bool) -> a b b
isA (String -> AssocList String String -> Bool
forall k v. Eq k => k -> AssocList k v -> Bool
hasEntry String
a_name) )
generalEntitiesDefined :: XmlArrow
generalEntitiesDefined :: XmlArrow
generalEntitiesDefined = XmlArrow
getDTDSubset
XmlArrow -> XmlArrow -> XmlArrow
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
XmlArrow -> XmlArrow
forall (a :: * -> * -> *) (t :: * -> *) b c.
(ArrowTree a, Tree t) =>
a (t b) c -> a (t b) c
deep XmlArrow
forall (a :: * -> * -> *). ArrowDTD a => a XmlTree XmlTree
isDTDEntity