{-# LANGUAGE FlexibleContexts #-}
module Text.XML.HXT.DTDValidation.DTDValidation
( removeDoublicateDefs
, validateDTD
)
where
import Text.XML.HXT.DTDValidation.AttributeValueValidation
import Text.XML.HXT.DTDValidation.TypeDefs
validateDTD :: XmlArrow
validateDTD :: XmlArrow
validateDTD
= XmlArrow
forall (a :: * -> * -> *). ArrowDTD a => a XmlTree XmlTree
isDTDDoctype
XmlArrow -> XmlArrow -> XmlArrow
forall (a :: * -> * -> *) b c d.
ArrowIf a =>
a b c -> a b d -> a b d
`guards`
( XmlArrow -> LA XmlTree [XmlTree]
forall (a :: * -> * -> *) b c. ArrowList a => a b c -> a b [c]
listA XmlArrow
forall (a :: * -> * -> *) (t :: * -> *) b.
(ArrowTree a, Tree t) =>
a (t b) (t b)
getChildren
LA XmlTree [XmlTree] -> LA [XmlTree] XmlTree -> XmlArrow
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
( [String] -> [String] -> LA [XmlTree] XmlTree
validateParts ([String] -> [String] -> LA [XmlTree] XmlTree)
-> LA [XmlTree] ([String], [String]) -> LA [XmlTree] XmlTree
forall (a :: * -> * -> *) c1 c2 b d.
ArrowList a =>
(c1 -> c2 -> a b d) -> a b (c1, c2) -> a b d
$<< (LA [XmlTree] [String]
getNotationNames LA [XmlTree] [String]
-> LA [XmlTree] [String] -> LA [XmlTree] ([String], [String])
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& LA [XmlTree] [String]
getElemNames) )
)
where
validateParts :: [String] -> [String] -> LA [XmlTree] XmlTree
validateParts notationNames :: [String]
notationNames elemNames :: [String]
elemNames
= LA [XmlTree] XmlTree
validateNotations
LA [XmlTree] XmlTree
-> LA [XmlTree] XmlTree -> LA [XmlTree] XmlTree
forall (a :: * -> * -> *) b c.
ArrowPlus a =>
a b c -> a b c -> a b c
<+>
[String] -> LA [XmlTree] XmlTree
validateEntities [String]
notationNames
LA [XmlTree] XmlTree
-> LA [XmlTree] XmlTree -> LA [XmlTree] XmlTree
forall (a :: * -> * -> *) b c.
ArrowPlus a =>
a b c -> a b c -> a b c
<+>
[String] -> LA [XmlTree] XmlTree
validateElements [String]
elemNames
LA [XmlTree] XmlTree
-> LA [XmlTree] XmlTree -> LA [XmlTree] XmlTree
forall (a :: * -> * -> *) b c.
ArrowPlus a =>
a b c -> a b c -> a b c
<+>
[String] -> [String] -> LA [XmlTree] XmlTree
validateAttributes [String]
elemNames [String]
notationNames
getNotationNames :: LA [XmlTree] [String]
getNotationNames :: LA [XmlTree] [String]
getNotationNames = LA [XmlTree] String -> LA [XmlTree] [String]
forall (a :: * -> * -> *) b c. ArrowList a => a b c -> a b [c]
listA (LA [XmlTree] String -> LA [XmlTree] [String])
-> LA [XmlTree] String -> LA [XmlTree] [String]
forall a b. (a -> b) -> a -> b
$ LA [XmlTree] XmlTree
forall (a :: * -> * -> *) b. ArrowList a => a [b] b
unlistA LA [XmlTree] XmlTree -> LA XmlTree String -> LA [XmlTree] String
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> XmlArrow
forall (a :: * -> * -> *). ArrowDTD a => a XmlTree XmlTree
isDTDNotation XmlArrow -> LA XmlTree String -> LA XmlTree String
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> String -> LA XmlTree String
forall (a :: * -> * -> *). ArrowDTD a => String -> a XmlTree String
getDTDAttrValue String
a_name
getElemNames :: LA [XmlTree] [String]
getElemNames :: LA [XmlTree] [String]
getElemNames = LA [XmlTree] String -> LA [XmlTree] [String]
forall (a :: * -> * -> *) b c. ArrowList a => a b c -> a b [c]
listA (LA [XmlTree] String -> LA [XmlTree] [String])
-> LA [XmlTree] String -> LA [XmlTree] [String]
forall a b. (a -> b) -> a -> b
$ LA [XmlTree] XmlTree
forall (a :: * -> * -> *) b. ArrowList a => a [b] b
unlistA LA [XmlTree] XmlTree -> LA XmlTree String -> LA [XmlTree] String
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> XmlArrow
forall (a :: * -> * -> *). ArrowDTD a => a XmlTree XmlTree
isDTDElement XmlArrow -> LA XmlTree String -> LA XmlTree String
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> String -> LA XmlTree String
forall (a :: * -> * -> *). ArrowDTD a => String -> a XmlTree String
getDTDAttrValue String
a_name
checkName :: String -> SLA [String] XmlTree XmlTree -> SLA