module Text.XML.HXT.Arrow.ReadDocument
( readDocument
, readFromDocument
, readString
, readFromString
, hread
, hreadDoc
, xread
, xreadDoc
)
where
import Control.Arrow.ListArrows
import Data.Maybe ( fromMaybe )
import qualified Data.Map as M
import Text.XML.HXT.DOM.Interface
import Text.XML.HXT.Arrow.XmlArrow
import Text.XML.HXT.Arrow.Edit ( canonicalizeAllNodes
, canonicalizeForXPath
, canonicalizeContents
, rememberDTDAttrl
, removeDocWhiteSpace
)
import qualified Text.XML.HXT.Arrow.ParserInterface as PI
import Text.XML.HXT.Arrow.ProcessDocument ( getDocumentContents
, parseXmlDocument
, parseXmlDocumentWithExpat
, parseHtmlDocument
, propagateAndValidateNamespaces
, andValidateNamespaces
)
import Text.XML.HXT.Arrow.XmlState
import Text.XML.HXT.Arrow.XmlState.TypeDefs
readDocument :: SysConfigList -> String -> IOStateArrow s b XmlTree
readDocument :: forall s b. SysConfigList -> String -> IOStateArrow s b XmlTree
readDocument SysConfigList
config String
src
= forall s a b. IOStateArrow s a b -> IOStateArrow s a b
localSysEnv
forall a b. (a -> b) -> a -> b
$
forall s b. SysConfigList -> String -> IOStateArrow s b XmlTree
readDocument' SysConfigList
config String
src
readDocument' :: SysConfigList -> String -> IOStateArrow s b XmlTree
readDocument' :: forall s b. SysConfigList -> String -> IOStateArrow s b XmlTree
readDocument' SysConfigList
config String
src
= forall s c. SysConfigList -> IOStateArrow s c c
configSysVars SysConfigList
config
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall {s0} {a}. Bool -> IOSLA (XIOState s0) a XmlTree
readD forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< forall c s b. Selector XIOSysState c -> IOStateArrow s b c
getSysVar Selector XIOSysState Bool
theWithCache
where
readD :: Bool -> IOSLA (XIOState s0) a XmlTree
readD Bool
True
= forall (a :: * -> * -> *) c b. ArrowList a => c -> a b c
constA forall a. HasCallStack => a
undefined
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
(forall b c s0. IOSArrow b c -> IOStateArrow s0 b c
withoutUserState forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< (forall c s b. Selector XIOSysState c -> IOStateArrow s b c
getSysVar Selector XIOSysState (String -> IOSArrow XmlTree XmlTree)
theCacheRead forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> (c -> d) -> a b d
>>^ (forall a b. (a -> b) -> a -> b
$ String
src)))
readD Bool
False
= forall s b. String -> IOStateArrow s b XmlTree
readDocument'' String
src
readDocument'' :: String -> IOStateArrow s b XmlTree
readDocument'' :: forall s b. String -> IOStateArrow s b XmlTree
readDocument'' String
src
= forall s b. String -> IOStateArrow s b XmlTree
getDocumentContents String
src
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
( forall {s}.
String
-> (Bool, (Bool, ([String], (Bool, Bool))))
-> IOSLA (XIOState s) XmlTree XmlTree
processDoc
forall (a :: * -> * -> *) c1 c2 b d.
ArrowList a =>
(c1 -> c2 -> a b d) -> a b (c1, c2) -> a b d
$<<
( IOSLA (XIOState s) XmlTree String
getMimeType
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&&
forall c s b. Selector XIOSysState c -> IOStateArrow s b c
getSysVar (Selector XIOSysState Bool
theParseByMimeType forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState Bool
theParseHTML forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState [String]
theAcceptedMimeTypes forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState Bool
theRelaxValidate forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState Bool
theXmlSchemaValidate
)
)
)
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall s b. Int -> String -> IOStateArrow s b b
traceMsg Int
1 (String
"readDocument: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show String
src forall a. [a] -> [a] -> [a]
++ String
" processed")
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall s. IOStateArrow s XmlTree XmlTree
traceSource
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall s. IOStateArrow s XmlTree XmlTree
traceTree
where
processNoneEmptyDoc :: a XmlTree XmlTree -> a XmlTree XmlTree
processNoneEmptyDoc a XmlTree XmlTree
p
= forall (a :: * -> * -> *) b c d.
ArrowIf a =>
a b c -> a b d -> a b d -> a b d
ifA (forall (a :: * -> * -> *) b c. ArrowList a => LA b c -> a b c
fromLA LA XmlTree XmlTree
hasEmptyBody)
(forall (a :: * -> * -> *) (t :: * -> *) b.
(ArrowTree a, Tree t) =>
a (t b) (t b) -> a (t b) (t b)
replaceChildren forall (a :: * -> * -> *) b c. ArrowList a => a b c
none)
a XmlTree XmlTree
p
where
hasEmptyBody :: LA XmlTree XmlTree
hasEmptyBody
= forall (a :: * -> * -> *).
ArrowXml a =>
String -> (String -> Bool) -> a XmlTree XmlTree
hasAttrValue String
transferStatus (forall a. Eq a => a -> a -> Bool
/= String
"200")
forall (a :: * -> * -> *) b c d.
ArrowIf a =>
a b c -> a b d -> a b d
`guards`
( forall (a :: * -> * -> *) b c. ArrowIf a => a b c -> a b b
neg forall (a :: * -> * -> *) (t :: * -> *) b.
(ArrowTree a, Tree t) =>
a (t b) (t b)
getChildren
forall (a :: * -> * -> *) b c.
ArrowPlus a =>
a b c -> a b c -> a b c
<+>
( forall (a :: * -> * -> *) (t :: * -> *) b.
(ArrowTree a, Tree t) =>
a (t b) (t b)
getChildren forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall (a :: * -> * -> *). ArrowXml a => a XmlTree XmlTree
isWhiteSpace )
)
getMimeType :: IOSLA (XIOState s) XmlTree String
getMimeType
= forall (a :: * -> * -> *). ArrowXml a => String -> a XmlTree String
getAttrValue String
transferMimeType forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> (c -> d) -> a b d
>>^ String -> String
stringToLower
applyMimeTypeHandler :: String -> IOStateArrow s0 XmlTree XmlTree
applyMimeTypeHandler String
mt
= forall b c s0. IOSArrow b c -> IOStateArrow s0 b c
withoutUserState (forall {s}.
Map String (IOSLA (XIOState s) XmlTree XmlTree)
-> IOSLA (XIOState s) XmlTree XmlTree
applyMTH forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< forall c s b. Selector XIOSysState c -> IOStateArrow s b c
getSysVar Selector XIOSysState MimeTypeHandlers
theMimeTypeHandlers)
where
applyMTH :: Map String (IOSLA (XIOState s) XmlTree XmlTree)
-> IOSLA (XIOState s) XmlTree XmlTree
applyMTH Map String (IOSLA (XIOState s) XmlTree XmlTree)
mtTable
= forall a. a -> Maybe a -> a
fromMaybe forall (a :: * -> * -> *) b c. ArrowList a => a b c
none forall a b. (a -> b) -> a -> b
$
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\ IOSLA (XIOState s) XmlTree XmlTree
f -> forall {a :: * -> * -> *}.
ArrowTree a =>
a XmlTree XmlTree -> a XmlTree XmlTree
processNoneEmptyDoc
(forall {s} {b}. IOStateArrow s b b
traceMimeStart forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> IOSLA (XIOState s) XmlTree XmlTree
f forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> forall {s} {b}. IOStateArrow s b b
traceMimeEnd)
) forall a b. (a -> b) -> a -> b
$
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup String
mt Map String (IOSLA (XIOState s) XmlTree XmlTree)
mtTable
traceMimeStart :: IOStateArrow s b b
traceMimeStart
= forall s b. Int -> String -> IOStateArrow s b b
traceMsg Int
2 forall a b. (a -> b) -> a -> b
$
String
"readDocument: calling user defined document parser"
traceMimeEnd :: IOStateArrow s b b
traceMimeEnd
= forall s b. Int -> String -> IOStateArrow s b b
traceMsg Int
2 forall a b. (a -> b) -> a -> b
$
String
"readDocument: user defined document parser finished"
processDoc :: String
-> (Bool, (Bool, ([String], (Bool, Bool))))
-> IOSLA (XIOState s) XmlTree XmlTree
processDoc String
mimeType (Bool, (Bool, ([String], (Bool, Bool))))
options
= forall s b. Int -> String -> IOStateArrow s b b
traceMsg Int
1 ([String] -> String
unwords [ String
"readDocument:", forall a. Show a => a -> String
show String
src
, String
"(mime type:", forall a. Show a => a -> String
show String
mimeType, String
") will be processed"
]
)
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
( forall {s0}. String -> IOStateArrow s0 XmlTree XmlTree
applyMimeTypeHandler String
mimeType
forall (a :: * -> * -> *) b c. ArrowIf a => a b c -> a b c -> a b c
`orElse`
forall {s}.
String
-> (Bool, (Bool, ([String], (Bool, Bool))))
-> IOSLA (XIOState s) XmlTree XmlTree
processDoc' String
mimeType (Bool, (Bool, ([String], (Bool, Bool))))
options
)
processDoc' :: String
-> (Bool, (Bool, ([String], (Bool, Bool))))
-> IOSLA (XIOState s) XmlTree XmlTree
processDoc' String
mimeType ( Bool
parseByMimeType
, ( Bool
parseHtml
, ( [String]
acceptedMimeTypes
, ( Bool
validateWithRelax
, Bool
validateWithXmlSchema
))))
= ( if [String] -> String -> Bool
isAcceptedMimeType [String]
acceptedMimeTypes String
mimeType
then ( forall {a :: * -> * -> *}.
ArrowTree a =>
a XmlTree XmlTree -> a XmlTree XmlTree
processNoneEmptyDoc
( ( forall {s}.
(Bool, (Bool, (Bool, (Bool, (Bool, Bool)))))
-> IOSLA (XIOState s) XmlTree XmlTree
parse forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< forall c s b. Selector XIOSysState c -> IOStateArrow s b c
getSysVar (Selector XIOSysState Bool
theValidate forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState Bool
theSubstDTDEntities forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState Bool
theSubstHTMLEntities forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState Bool
theIgnoreNoneXmlContents forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState Bool
theTagSoup forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState Bool
theExpat
)
)
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
( if Bool
isXmlOrHtml
then ( ( forall {s}. (Bool, Bool) -> IOStateArrow s XmlTree XmlTree
checknamespaces forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< forall c s b. Selector XIOSysState c -> IOStateArrow s b c
getSysVar (Selector XIOSysState Bool
theCheckNamespaces forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState Bool
theTagSoup
)
)
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall (a :: * -> * -> *). ArrowList a => a XmlTree XmlTree
rememberDTDAttrl
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
( forall {a :: * -> * -> *}.
ArrowList a =>
(Bool, (Bool, Bool)) -> a XmlTree XmlTree
canonicalize forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< forall c s b. Selector XIOSysState c -> IOStateArrow s b c
getSysVar (Selector XIOSysState Bool
thePreserveComment forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState Bool
theCanonicalize forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState Bool
theTagSoup
)
)
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
( forall {a :: * -> * -> *}.
ArrowXml a =>
(Bool, Bool) -> a XmlTree XmlTree
whitespace forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< forall c s b. Selector XIOSysState c -> IOStateArrow s b c
getSysVar (Selector XIOSysState Bool
theRemoveWS forall s a b. Selector s a -> Selector s b -> Selector s (a, b)
.&&&.
Selector XIOSysState Bool
theTagSoup
)
)
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall s. IOStateArrow s XmlTree XmlTree
relaxOrXmlSchema
)
else forall (a :: * -> * -> *) b. ArrowList a => a b b
this
)
)
)
else ( forall s b. Int -> String -> IOStateArrow s b b
traceMsg Int
1 ([String] -> String
unwords [ String
"readDocument:", forall a. Show a => a -> String
show String
src
, String
"mime type:", forall a. Show a => a -> String
show String
mimeType, String
"not accepted"])
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall (a :: * -> * -> *) (t :: * -> *) b.
(ArrowTree a, Tree t) =>
a (t b) (t b) -> a (t b) (t b)
replaceChildren forall (a :: * -> * -> *) b c. ArrowList a => a b c
none
)
)
where
isAcceptedMimeType :: [String] -> String -> Bool
isAcceptedMimeType :: [String] -> String -> Bool
isAcceptedMimeType [String]
mts String
mt
| forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
mts
Bool -> Bool -> Bool
||
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
mt = Bool
True
| Bool
otherwise = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ((String, String) -> (String, String) -> Bool -> Bool
matchMt (String, String)
mt') Bool
False forall a b. (a -> b) -> a -> b
$ [(String, String)]
mts'
where
mt' :: (String, String)
mt' = String -> (String, String)
parseMt String
mt
mts' :: [(String, String)]
mts' = forall a b. (a -> b) -> [a] -> [b]
map String -> (String, String)
parseMt
forall a b. (a -> b) -> a -> b
$
[String]
mts
parseMt :: String -> (String, String)
parseMt = forall a. (a -> Bool) -> [a] -> ([a], [a])
break (forall a. Eq a => a -> a -> Bool
== Char
'/')
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second (forall a. Int -> [a] -> [a]
drop Int
1)
matchMt :: (String, String) -> (String, String) -> Bool -> Bool
matchMt (String
ma,String
mi) (String
mas,String
mis) Bool
r = ( (String
ma forall a. Eq a => a -> a -> Bool
== String
mas Bool -> Bool -> Bool
|| String
mas forall a. Eq a => a -> a -> Bool
== String
"*")
Bool -> Bool -> Bool
&&
(String
mi forall a. Eq a => a -> a -> Bool
== String
mis Bool -> Bool -> Bool
|| String
mis forall a. Eq a => a -> a -> Bool
== String
"*")
)
Bool -> Bool -> Bool
|| Bool
r
parse :: (Bool, (Bool, (Bool, (Bool, (Bool, Bool)))))
-> IOSLA (XIOState s) XmlTree XmlTree
parse ( Bool
validate
, ( Bool
substDTD
, ( Bool
substHTML
, ( Bool
removeNoneXml
, ( Bool
withTagSoup'
, Bool
withExpat'
)))))
| Bool -> Bool
not Bool
isXmlOrHtml = if Bool
removeNoneXml
then forall (a :: * -> * -> *) (t :: * -> *) b.
(ArrowTree a, Tree t) =>
a (t b) (t b) -> a (t b) (t b)
replaceChildren forall (a :: * -> * -> *) b c. ArrowList a => a b c
none
else forall (a :: * -> * -> *) b. ArrowList a => a b b
this
| Bool
isHtml
Bool -> Bool -> Bool
||
Bool
withTagSoup' = forall s c. SysConfig -> IOStateArrow s c c
configSysVar (forall s a. Selector s a -> a -> s -> s
setS Selector XIOSysState Bool
theLowerCaseNames Bool
isHtml)
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall s. IOStateArrow s XmlTree XmlTree
parseHtmlDocument
| Bool
isXml = if Bool
withExpat'
then forall s. IOStateArrow s XmlTree XmlTree
parseXmlDocumentWithExpat
else forall s.
Bool -> Bool -> Bool -> Bool -> IOStateArrow s XmlTree XmlTree
parseXmlDocument
Bool
validate
Bool
substDTD
Bool
substHTML
Bool
validateWithRelax
| Bool
otherwise = forall (a :: * -> * -> *) b. ArrowList a => a b b
this
checknamespaces :: (Bool, Bool) -> IOStateArrow s XmlTree XmlTree
checknamespaces (Bool
withNamespaces, Bool
withTagSoup')
| Bool
withNamespaces
Bool -> Bool -> Bool
&&
Bool
withTagSoup' = forall s. IOStateArrow s XmlTree XmlTree
andValidateNamespaces
| Bool
withNamespaces
Bool -> Bool -> Bool
||
Bool
validateWithRelax
Bool -> Bool -> Bool
||
Bool
validateWithXmlSchema
= forall s. IOStateArrow s XmlTree XmlTree
propagateAndValidateNamespaces
| Bool
otherwise = forall (a :: * -> * -> *) b. ArrowList a => a b b
this
canonicalize :: (Bool, (Bool, Bool)) -> a XmlTree XmlTree
canonicalize (Bool
preserveCmt, (Bool
canonicalize', Bool
withTagSoup'))
| Bool
withTagSoup' = forall (a :: * -> * -> *) b. ArrowList a => a b b
this
| Bool
validateWithRelax
Bool -> Bool -> Bool
||
Bool
validateWithXmlSchema = forall (a :: * -> * -> *). ArrowList a => a XmlTree XmlTree
canonicalizeAllNodes
| Bool
canonicalize'
Bool -> Bool -> Bool
&&
Bool
preserveCmt = forall (a :: * -> * -> *). ArrowList a => a XmlTree XmlTree
canonicalizeForXPath
| Bool
canonicalize' = forall (a :: * -> * -> *). ArrowList a => a XmlTree XmlTree
canonicalizeAllNodes
| Bool
otherwise = forall (a :: * -> * -> *) b. ArrowList a => a b b
this
relaxOrXmlSchema :: IOSLA (XIOState s0) XmlTree XmlTree
relaxOrXmlSchema
| Bool
validateWithXmlSchema = forall b c s0. IOSArrow b c -> IOStateArrow s0 b c
withoutUserState forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< forall c s b. Selector XIOSysState c -> IOStateArrow s b c
getSysVar Selector XIOSysState (IOSArrow XmlTree XmlTree)
theXmlSchemaValidator
| Bool
validateWithRelax = forall b c s0. IOSArrow b c -> IOStateArrow s0 b c
withoutUserState forall (a :: * -> * -> *) c b d.
ArrowList a =>
(c -> a b d) -> a b c -> a b d
$< forall c s b. Selector XIOSysState c -> IOStateArrow s b c
getSysVar Selector XIOSysState (IOSArrow XmlTree XmlTree)
theRelaxValidator
| Bool
otherwise = forall (a :: * -> * -> *) b. ArrowList a => a b b
this
whitespace :: (Bool, Bool) -> a XmlTree XmlTree
whitespace (Bool
removeWS, Bool
withTagSoup')
| ( Bool
removeWS
Bool -> Bool -> Bool
||
Bool
validateWithXmlSchema
)
Bool -> Bool -> Bool
&&
Bool -> Bool
not Bool
withTagSoup' = forall (a :: * -> * -> *). ArrowXml a => a XmlTree XmlTree
removeDocWhiteSpace
| Bool
otherwise = forall (a :: * -> * -> *) b. ArrowList a => a b b
this
isHtml :: Bool
isHtml = ( Bool -> Bool
not Bool
parseByMimeType Bool -> Bool -> Bool
&& Bool
parseHtml )
Bool -> Bool -> Bool
||
( Bool
parseByMimeType Bool -> Bool -> Bool
&& String -> Bool
isHtmlMimeType String
mimeType )
isXml :: Bool
isXml = ( Bool -> Bool
not Bool
parseByMimeType Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
parseHtml )
Bool -> Bool -> Bool
||
( Bool
parseByMimeType
Bool -> Bool -> Bool
&&
( String -> Bool
isXmlMimeType String
mimeType
Bool -> Bool -> Bool
||
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
mimeType
)
)
isXmlOrHtml :: Bool
isXmlOrHtml = Bool
isHtml Bool -> Bool -> Bool
|| Bool
isXml
readFromDocument :: SysConfigList -> IOStateArrow s String XmlTree
readFromDocument :: forall s. SysConfigList -> IOStateArrow s String XmlTree
readFromDocument SysConfigList
config
= forall (a :: * -> * -> *) b c. ArrowList a => a b (a b c) -> a b c
applyA ( forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr forall a b. (a -> b) -> a -> b
$ forall s b. SysConfigList -> String -> IOStateArrow s b XmlTree
readDocument SysConfigList
config )
readString :: SysConfigList -> String -> IOStateArrow s b XmlTree
readString :: forall s b. SysConfigList -> String -> IOStateArrow s b XmlTree
readString SysConfigList
config String
content
= forall s b. SysConfigList -> String -> IOStateArrow s b XmlTree
readDocument SysConfigList
config (String
stringProtocol forall a. [a] -> [a] -> [a]
++ String
content)
readFromString :: SysConfigList -> IOStateArrow s String XmlTree
readFromString :: forall s. SysConfigList -> IOStateArrow s String XmlTree
readFromString SysConfigList
config
= forall (a :: * -> * -> *) b c. ArrowList a => a b (a b c) -> a b c
applyA ( forall (a :: * -> * -> *) b c. Arrow a => (b -> c) -> a b c
arr forall a b. (a -> b) -> a -> b
$ forall s b. SysConfigList -> String -> IOStateArrow s b XmlTree
readString SysConfigList
config )
hread :: ArrowXml a => a String XmlTree
hread :: forall (a :: * -> * -> *). ArrowXml a => a String XmlTree
hread
= forall (a :: * -> * -> *) b c. ArrowList a => LA b c -> a b c
fromLA forall a b. (a -> b) -> a -> b
$
forall (a :: * -> * -> *). ArrowList a => a String XmlTree
PI.hread
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall b c.
[IfThen (LA (NTree b) c) (LA (NTree b) (NTree b))]
-> LA (NTree b) (NTree b)
editNTreeA [forall (a :: * -> * -> *). ArrowXml a => a XmlTree XmlTree
isError forall a b. a -> b -> IfThen a b
:-> forall (a :: * -> * -> *) b c. ArrowList a => a b c
none]
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall (a :: * -> * -> *). ArrowList a => a XmlTree XmlTree
canonicalizeContents
hreadDoc :: ArrowXml a => a String XmlTree
hreadDoc :: forall (a :: * -> * -> *). ArrowXml a => a String XmlTree
hreadDoc
= forall (a :: * -> * -> *) b c. ArrowList a => LA b c -> a b c
fromLA forall a b. (a -> b) -> a -> b
$
forall (a :: * -> * -> *) n.
ArrowXml a =>
[a n XmlTree] -> [a n XmlTree] -> a n XmlTree
root [] [forall (a :: * -> * -> *). ArrowList a => a String XmlTree
PI.hreadDoc]
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall b c.
[IfThen (LA (NTree b) c) (LA (NTree b) (NTree b))]
-> LA (NTree b) (NTree b)
editNTreeA [forall (a :: * -> * -> *). ArrowXml a => a XmlTree XmlTree
isError forall a b. a -> b -> IfThen a b
:-> forall (a :: * -> * -> *) b c. ArrowList a => a b c
none]
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall (a :: * -> * -> *). ArrowList a => a XmlTree XmlTree
canonicalizeForXPath
forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>
forall (a :: * -> * -> *) (t :: * -> *) b.
(ArrowTree a, Tree t) =>
a (t b) (t b)
getChildren
xread :: ArrowXml a => a String XmlTree
xread :: forall (a :: * -> * -> *). ArrowXml a => a String XmlTree
xread = forall (a :: * -> * -> *). ArrowXml a => a String XmlTree
PI.xreadCont
xreadDoc :: ArrowXml a => a String XmlTree
xreadDoc :: forall (a :: * -> * -> *). ArrowXml a => a String XmlTree
xreadDoc = forall (a :: * -> * -> *). ArrowXml a => a String XmlTree
PI.xreadDoc