module Text.XML.HXT.DTDValidation.AttributeValueValidation
( checkAttributeValue
, normalizeAttributeValue
)
where
import Text.XML.HXT.Parser.XmlParsec
( parseNMToken
, parseName
)
import Text.XML.HXT.DTDValidation.TypeDefs
checkAttributeValue :: XmlTrees -> XmlTree -> XmlArrow
checkAttributeValue :: XmlTrees -> XmlTree -> XmlArrow
checkAttributeValue XmlTrees
dtdPart XmlTree
attrDecl
| XmlTree -> Bool
isDTDAttlistNode XmlTree
attrDecl
= [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
isElem XmlArrow -> XmlArrow -> IfThen XmlArrow XmlArrow
forall a b. a -> b -> IfThen a b
:-> ( [Char] -> XmlArrow
checkAttrVal ([Char] -> XmlArrow) -> LA XmlTree [Char] -> XmlArrow
forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< [Char] -> LA XmlTree [Char]
forall (a :: * -> * -> *). ArrowXml a => [Char] -> a XmlTree [Char]
getAttrValue [Char]
attrName )
, XmlArrow
forall (a :: * -> * -> *). ArrowDTD a => a XmlTree XmlTree
isDTDAttlist XmlArrow -> XmlArrow -> IfThen XmlArrow XmlArrow
forall a b. a -> b -> IfThen a b
:-> ( [Char] -> XmlArrow
checkAttrVal ([Char] -> XmlArrow) -> LA XmlTree [Char] -> XmlArrow
forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< (LA XmlTree Attributes
forall (a :: * -> * -> *). ArrowXml a => a XmlTree Attributes
getDTDAttrl LA XmlTree Attributes
-> (Attributes -> [Char]) -> LA XmlTree [Char]
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> (c -> d) -> a b d
>>^ Attributes -> [Char]
dtd_default) )
, XmlArrow
forall (a :: * -> * -> *) b. ArrowList a => a b b
this XmlArrow -> XmlArrow -> IfThen XmlArrow XmlArrow
forall a b. a -> b -> IfThen a b
:-> XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => a b c
none
]
| Bool
otherwise
= XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => a b c
none
where
al :: Attributes
al = XmlTree -> Attributes
getDTDAttributes XmlTree
attrDecl
attrName :: [Char]
attrName = Attributes -> [Char]
dtd_value Attributes
al
attrType :: [Char]
attrType = Attributes -> [Char]
dtd_type Attributes
al
checkAttrVal :: [Char] -> XmlArrow
checkAttrVal [Char]
attrValue
= [Char] -> XmlTrees -> [Char] -> XmlTree -> XmlArrow
checkValue [Char]
attrType XmlTrees
dtdPart [Char]
normalizedVal XmlTree
attrDecl
where
normalizedVal :: [Char]
normalizedVal = Maybe XmlTree -> [Char] -> [Char]
normalizeAttributeValue (XmlTree -> Maybe XmlTree
forall a. a -> Maybe a
Just XmlTree
attrDecl) [Char]
attrValue
checkValue :: String -> XmlTrees -> String -> XmlTree -> XmlArrow
checkValue :: [Char] -> XmlTrees -> [Char] -> XmlTree -> XmlArrow
checkValue [Char]
typ XmlTrees
dtdPart [Char]
attrValue XmlTree
attrDecl
| [Char]
typ [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
k_cdata = XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => a b c
none
| [Char]
typ [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
k_enumeration = XmlTree -> [Char] -> XmlArrow
checkValueEnumeration XmlTree
attrDecl [Char]
attrValue
| [Char]
typ [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
k_entity = XmlTrees -> XmlTree -> [Char] -> XmlArrow
checkValueEntity XmlTrees
dtdPart XmlTree
attrDecl [Char]
attrValue
| [Char]
typ [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
k_entities = XmlTrees -> XmlTree -> [Char] -> XmlArrow
checkValueEntities XmlTrees
dtdPart XmlTree
attrDecl [Char]
attrValue
| [Char]
typ [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
k_id = XmlTree -> [Char] -> XmlArrow
checkValueId XmlTree
attrDecl [Char]
attrValue
| [Char]
typ [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
k_idref = XmlTree -> [Char] -> XmlArrow
checkValueIdref XmlTree
attrDecl [Char]
attrValue
| [Char]
typ [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
k_idrefs = XmlTree -> [Char] -> XmlArrow
checkValueIdrefs XmlTree
attrDecl [Char]
attrValue
| [Char]
typ [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
k_nmtoken = XmlTree -> [Char] -> XmlArrow
checkValueNmtoken XmlTree
attrDecl [Char]
attrValue
| [Char]
typ [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
k_nmtokens = XmlTree -> [Char] -> XmlArrow
checkValueNmtokens XmlTree
attrDecl [Char]
attrValue
| [Char]
typ [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
k_notation = XmlTree -> [Char] -> XmlArrow
checkValueEnumeration XmlTree
attrDecl [Char]
attrValue
| Bool
otherwise = [Char] -> XmlArrow
forall a. HasCallStack => [Char] -> a
error ([Char]
"Attribute type " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show [Char]
typ [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" unknown.")
checkValueEnumeration :: XmlTree -> String -> XmlArrow
checkValueEnumeration :: XmlTree -> [Char] -> XmlArrow
checkValueEnumeration XmlTree
attrDecl [Char]
attrValue
| XmlTree -> Bool
isDTDAttlistNode XmlTree
attrDecl
Bool -> Bool -> Bool
&&
[Char]
attrValue [Char] -> [[Char]] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [[Char]]
enumVals
= [Char] -> XmlArrow
forall (a :: * -> * -> *) n. ArrowXml a => [Char] -> a n XmlTree
err ( [Char]
"Attribute " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show (Attributes -> [Char]
dtd_value Attributes
al) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" for element " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show (Attributes -> [Char]
dtd_name Attributes
al) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++
[Char]
" must have a value from list "[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [[Char]] -> [Char]
forall a. Show a => a -> [Char]
show [[Char]]
enumVals [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
".")
| Bool
otherwise
= XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => a b c
none
where
al :: Attributes
al = XmlTree -> Attributes
getDTDAttributes XmlTree
attrDecl
enumVals :: [String]
enumVals :: [[Char]]
enumVals = (XmlTree -> [Char]) -> XmlTrees -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map (Attributes -> [Char]
dtd_name (Attributes -> [Char])
-> (XmlTree -> Attributes) -> XmlTree -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XmlTree -> Attributes
getDTDAttributes) (XmlTrees -> [[Char]]) -> XmlTrees -> [[Char]]
forall a b. (a -> b) -> a -> b
$ (XmlArrow -> XmlTree -> XmlTrees
forall a b. LA a b -> a -> [b]
runLA XmlArrow
forall (a :: * -> * -> *) (t :: * -> *) b.
(ArrowTree a, Tree t) =>
a (t b) (t b)
getChildren XmlTree
attrDecl)
checkValueEntity :: XmlTrees -> XmlTree -> String -> XmlArrow
checkValueEntity :: XmlTrees -> XmlTree -> [Char] -> XmlArrow
checkValueEntity XmlTrees
dtdPart XmlTree
attrDecl [Char]
attrValue
| XmlTree -> Bool
isDTDAttlistNode XmlTree
attrDecl
Bool -> Bool -> Bool
&&
[Char]
attrValue [Char] -> [[Char]] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [[Char]]
upEntities
= [Char] -> XmlArrow
forall (a :: * -> * -> *) n. ArrowXml a => [Char] -> a n XmlTree
err ( [Char]
"Entity " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show [Char]
attrValue [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" of attribute " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show (Attributes -> [Char]
dtd_value Attributes
al) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++
[Char]
" for element " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show (Attributes -> [Char]
dtd_name Attributes
al) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" is not unparsed. " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++
[Char]
"The following unparsed entities exist: " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [[Char]] -> [Char]
forall a. Show a => a -> [Char]
show [[Char]]
upEntities [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
".")
| Bool
otherwise
= XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => a b c
none
where
al :: Attributes
al = XmlTree -> Attributes
getDTDAttributes XmlTree
attrDecl
upEntities :: [String]
upEntities :: [[Char]]
upEntities = (XmlTree -> [Char]) -> XmlTrees -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map (Attributes -> [Char]
dtd_name (Attributes -> [Char])
-> (XmlTree -> Attributes) -> XmlTree -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XmlTree -> Attributes
getDTDAttributes) (XmlArrow
forall (a :: * -> * -> *). ArrowDTD a => a XmlTree XmlTree
isUnparsedEntity XmlArrow -> XmlTrees -> XmlTrees
$$ XmlTrees
dtdPart)
checkValueEntities ::XmlTrees -> XmlTree -> String -> XmlArrow
checkValueEntities :: XmlTrees -> XmlTree -> [Char] -> XmlArrow
checkValueEntities XmlTrees
dtdPart XmlTree
attrDecl [Char]
attrValue
| XmlTree -> Bool
isDTDAttlistNode XmlTree
attrDecl
= if [[Char]] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [[Char]]
valueList
then [Char] -> XmlArrow
forall (a :: * -> * -> *) n. ArrowXml a => [Char] -> a n XmlTree
err ([Char]
"Attribute " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show (Attributes -> [Char]
dtd_value Attributes
al) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" of element " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++
[Char] -> [Char]
forall a. Show a => a -> [Char]
show (Attributes -> [Char]
dtd_name Attributes
al) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" must be one or more names.")
else [XmlArrow] -> XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => [a b c] -> a b c
catA ([XmlArrow] -> XmlArrow)
-> ([[Char]] -> [XmlArrow]) -> [[Char]] -> XmlArrow
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Char] -> XmlArrow) -> [[Char]] -> [XmlArrow]
forall a b. (a -> b) -> [a] -> [b]
map (XmlTrees -> XmlTree -> [Char] -> XmlArrow
checkValueEntity XmlTrees
dtdPart XmlTree
attrDecl) ([[Char]] -> XmlArrow) -> [[Char]] -> XmlArrow
forall a b. (a -> b) -> a -> b
$ [[Char]]
valueList
| Bool
otherwise
= XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => a b c
none
where
al :: Attributes
al = XmlTree -> Attributes
getDTDAttributes XmlTree
attrDecl
valueList :: [[Char]]
valueList = [Char] -> [[Char]]
words [Char]
attrValue
checkValueNmtoken :: XmlTree -> String -> XmlArrow
checkValueNmtoken :: XmlTree -> [Char] -> XmlArrow
checkValueNmtoken XmlTree
attrDecl [Char]
attrValue
| XmlTree -> Bool
isDTDAttlistNode XmlTree
attrDecl
= [Char] -> LA XmlTree [Char]
forall (a :: * -> * -> *) c b. ArrowList a => c -> a b c
constA [Char]
attrValue LA XmlTree [Char] -> LA [Char] XmlTree -> XmlArrow
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> LA [Char] XmlTree
checkNmtoken
| Bool
otherwise
= XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => a b c
none
where
al :: Attributes
al = XmlTree -> Attributes
getDTDAttributes XmlTree
attrDecl
checkNmtoken :: LA [Char] XmlTree
checkNmtoken
= LA [Char] XmlTree
forall (a :: * -> * -> *). ArrowXml a => a [Char] XmlTree
mkText LA [Char] XmlTree -> XmlArrow -> LA [Char] XmlTree
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (XmlTree -> XmlTrees) -> XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => (b -> [c]) -> a b c
arrL ([Char] -> XmlTree -> XmlTrees
parseNMToken [Char]
"")
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
forall (a :: * -> * -> *). ArrowXml a => a XmlTree XmlTree
isError
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 [Char]
forall (a :: * -> * -> *). ArrowXml a => a XmlTree [Char]
getErrorMsg
LA XmlTree [Char] -> LA [Char] XmlTree -> XmlArrow
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
([Char] -> [Char]) -> LA [Char] [Char]
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr (\ [Char]
s -> ( [Char]
"Attribute value " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show [Char]
attrValue [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" of attribute " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show (Attributes -> [Char]
dtd_value Attributes
al) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++
[Char]
" for element " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show (Attributes -> [Char]
dtd_name Attributes
al) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" must be a name token, "[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ ([Char] -> [[Char]]
lines [Char]
s) [[Char]] -> Int -> [Char]
forall a. [a] -> Int -> a
!! Int
1 [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++[Char]
".") )
LA [Char] [Char] -> LA [Char] XmlTree -> LA [Char] XmlTree
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Int -> LA [Char] XmlTree
forall (a :: * -> * -> *). ArrowXml a => Int -> a [Char] XmlTree
mkError Int
c_err
checkValueNmtokens :: XmlTree -> String -> XmlArrow
checkValueNmtokens :: XmlTree -> [Char] -> XmlArrow
checkValueNmtokens XmlTree
attrDecl [Char]
attrValue
| XmlTree -> Bool
isDTDAttlistNode XmlTree
attrDecl
= if [[Char]] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [[Char]]
valueList
then [Char] -> XmlArrow
forall (a :: * -> * -> *) n. ArrowXml a => [Char] -> a n XmlTree
err ( [Char]
"Attribute "[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show (Attributes -> [Char]
dtd_value Attributes
al) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++[Char]
" of element " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++
[Char] -> [Char]
forall a. Show a => a -> [Char]
show (Attributes -> [Char]
dtd_name Attributes
al) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" must be one or more name tokens.")
else [XmlArrow] -> XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => [a b c] -> a b c
catA ([XmlArrow] -> XmlArrow)
-> ([[Char]] -> [XmlArrow]) -> [[Char]] -> XmlArrow
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Char] -> XmlArrow) -> [[Char]] -> [XmlArrow]
forall a b. (a -> b) -> [a] -> [b]
map (XmlTree -> [Char] -> XmlArrow
checkValueNmtoken XmlTree
attrDecl) ([[Char]] -> XmlArrow) -> [[Char]] -> XmlArrow
forall a b. (a -> b) -> a -> b
$ [[Char]]
valueList
| Bool
otherwise
= XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => a b c
none
where
al :: Attributes
al = XmlTree -> Attributes
getDTDAttributes XmlTree
attrDecl
valueList :: [[Char]]
valueList = [Char] -> [[Char]]
words [Char]
attrValue
checkValueId :: XmlTree -> String -> XmlArrow
checkValueId :: XmlTree -> [Char] -> XmlArrow
checkValueId XmlTree
attrDecl [Char]
attrValue
= [Char] -> XmlTree -> [Char] -> XmlArrow
checkForName [Char]
"Attribute value" XmlTree
attrDecl [Char]
attrValue
checkValueIdref :: XmlTree -> String -> XmlArrow
checkValueIdref :: XmlTree -> [Char] -> XmlArrow
checkValueIdref XmlTree
attrDecl [Char]
attrValue
= [Char] -> XmlTree -> [Char] -> XmlArrow
checkForName [Char]
"Attribute value" XmlTree
attrDecl [Char]
attrValue
checkValueIdrefs :: XmlTree -> String -> XmlArrow
checkValueIdrefs :: XmlTree -> [Char] -> XmlArrow
checkValueIdrefs XmlTree
attrDecl [Char]
attrValue
= [XmlArrow] -> XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => [a b c] -> a b c
catA ([XmlArrow] -> XmlArrow)
-> ([Char] -> [XmlArrow]) -> [Char] -> XmlArrow
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Char] -> XmlArrow) -> [[Char]] -> [XmlArrow]
forall a b. (a -> b) -> [a] -> [b]
map (XmlTree -> [Char] -> XmlArrow
checkValueIdref XmlTree
attrDecl) ([[Char]] -> [XmlArrow])
-> ([Char] -> [[Char]]) -> [Char] -> [XmlArrow]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> [[Char]]
words ([Char] -> XmlArrow) -> [Char] -> XmlArrow
forall a b. (a -> b) -> a -> b
$ [Char]
attrValue
checkForName :: String -> XmlTree -> String -> XmlArrow
checkForName :: [Char] -> XmlTree -> [Char] -> XmlArrow
checkForName [Char]
msg XmlTree
attrDecl [Char]
attrValue
| XmlTree -> Bool
isDTDAttlistNode XmlTree
attrDecl
= [Char] -> LA XmlTree [Char]
forall (a :: * -> * -> *) c b. ArrowList a => c -> a b c
constA [Char]
attrValue LA XmlTree [Char] -> LA [Char] XmlTree -> XmlArrow
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> LA [Char] XmlTree
checkName
| Bool
otherwise
= XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => a b c
none
where
al :: Attributes
al = XmlTree -> Attributes
getDTDAttributes XmlTree
attrDecl
checkName :: LA [Char] XmlTree
checkName
= LA [Char] XmlTree
forall (a :: * -> * -> *). ArrowXml a => a [Char] XmlTree
mkText LA [Char] XmlTree -> XmlArrow -> LA [Char] XmlTree
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (XmlTree -> XmlTrees) -> XmlArrow
forall (a :: * -> * -> *) b c. ArrowList a => (b -> [c]) -> a b c
arrL ([Char] -> XmlTree -> XmlTrees
parseName [Char]
"")
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
forall (a :: * -> * -> *). ArrowXml a => a XmlTree XmlTree
isError
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 [Char]
forall (a :: * -> * -> *). ArrowXml a => a XmlTree [Char]
getErrorMsg
LA XmlTree [Char] -> LA [Char] XmlTree -> XmlArrow
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
([Char] -> [Char]) -> LA [Char] [Char]
forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr (\[Char]
s -> ( [Char]
msg [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show [Char]
attrValue [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++[Char]
" of attribute " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show (Attributes -> [Char]
dtd_value Attributes
al) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++
[Char]
" for element "[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show (Attributes -> [Char]
dtd_name Attributes
al) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++[Char]
" must be a name, " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ ([Char] -> [[Char]]
lines [Char]
s) [[Char]] -> Int -> [Char]
forall a. [a] -> Int -> a
!! Int
1 [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
".") )
LA [Char] [Char] -> LA [Char] XmlTree -> LA [Char] XmlTree
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
Int -> LA [Char] XmlTree
forall (a :: * -> * -> *). ArrowXml a => Int -> a [Char] XmlTree
mkError Int
c_err
normalizeAttributeValue :: Maybe XmlTree -> String -> String
normalizeAttributeValue :: Maybe XmlTree -> [Char] -> [Char]
normalizeAttributeValue (Just XmlTree
attrDecl) [Char]
value
= [Char] -> [Char]
normalizeAttribute [Char]
attrType
where
al :: Attributes
al = XmlTree -> Attributes
getDTDAttributes XmlTree
attrDecl
attrType :: [Char]
attrType = Attributes -> [Char]
dtd_type Attributes
al
normalizeAttribute :: String -> String
normalizeAttribute :: [Char] -> [Char]
normalizeAttribute [Char]
typ
| [Char]
typ [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
k_cdata = [Char] -> [Char]
cdataNormalization [Char]
value
| Bool
otherwise = [Char] -> [Char]
otherNormalization [Char]
value
normalizeAttributeValue Maybe XmlTree
Nothing [Char]
value
= [Char] -> [Char]
cdataNormalization [Char]
value
cdataNormalization :: String -> String
cdataNormalization :: [Char] -> [Char]
cdataNormalization = [Char] -> [Char]
forall a. a -> a
id
otherNormalization :: String -> String
otherNormalization :: [Char] -> [Char]
otherNormalization = [Char] -> [Char]
reduceWSSequences ([Char] -> [Char]) -> ([Char] -> [Char]) -> [Char] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> [Char]
stringTrim ([Char] -> [Char]) -> ([Char] -> [Char]) -> [Char] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> [Char]
cdataNormalization
reduceWSSequences :: String -> String
reduceWSSequences :: [Char] -> [Char]
reduceWSSequences [Char]
str = [[Char]] -> [Char]
unwords ([Char] -> [[Char]]
words [Char]
str)