@@ -26,38 +26,6 @@ type XSDMonad a = WriterT (M.Map Text Datatype) (Either SomeException) a
26parseXSD :: ParseSettings -> ByteString -> Either SomeException XSD
26parseXSD :: ParseSettings -> ByteString -> Either SomeException XSD
27parseXSD ps bs = parseLBS ps bs >>= toXsd
27parseXSD ps bs = parseLBS ps bs >>= toXsd
31− | Expectation :+: Expectation
33−satisfy :: Expectation -> XML.Node -> Bool
34−satisfy exp node@(NodeElement (XML.Element name _ _)) =
36− NodeElement (XML.Element (Name name _ _) _ _) -> case exp of
37− ExpName n -> name == n
38− exp1 :+: exp2 -> satisfy exp1 node && satisfy exp2 node
44−satisfySome c e = satisfySome' True c e
47− :: Bool -- ^ check current
51−satisfySome' checkCurrent cur [] = True
52−satisfySome' checkCurrent cur (exp:exps) = result
54− satisfyCurrent = satisfy exp (node cur)
55− validChildren = P.filter (satisfy (P.head exps) . node) (child cur)
57− if checkCurrent && P.null exps
59− else P.foldr (\c r -> r && satisfySome' False c exps) True validChildren
61-- Show is Meh
29-- Show is Meh
62throwXsd :: Show s => s -> XSDMonad a
30throwXsd :: Show s => s -> XSDMonad a
63throwXsd = throwError . SomeException . XSDException . show
31throwXsd = throwError . SomeException . XSDException . show
@@ -91,6 +59,7 @@ safeHead :: [a] -> Maybe a
91safeHead [] = Nothing
59safeHead [] = Nothing
92safeHead (a:_) = Just a
60safeHead (a:_) = Just a
62+-- | Takes a cursor to the element itself.
94toElem :: Cursor -> XSDMonad XSD.Element
63toElem :: Cursor -> XSDMonad XSD.Element
95toElem cursor = do
64toElem cursor = do
96 case node cursor of
65 case node cursor of