-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Ogma: Runtime Monitor translator: XML Frontend
--   
--   Ogma is a tool to facilitate the integration of safe runtime monitors
--   into other systems. Ogma extends Copilot, a high-level runtime
--   verification framework that generates hard real-time C99 code.
--   
--   This library contains a frontend to read specifications from XML
--   files.
@package ogma-language-xmlspec
@version 1.10.0

-- | Print XML trees.
--   
--   This variant of the function to show XML trees available in HXT is
--   needed because of issues with values being quoted by HXT's default
--   function.
--   
--   It's based on the same ideas, but it's been implemented using the
--   pretty-library instead of using plain string functions.
module Language.XMLSpec.PrintTrees

-- | Render a document into a string.
flattenDoc :: Doc -> String

-- | Class for values that can be converted into a document.
class Pretty x
pretty :: Pretty x => x -> Doc

-- | Pretty print an attribute followed by its value.
prettyAttr :: String -> Attributes -> Doc

-- | Pretty print a content element.
prettyContent :: XmlTree -> Doc

-- | Pretty print the type of an element.
prettyElemType :: String -> XmlTrees -> Doc

-- | Pretty print an entity.
prettyEntity :: String -> Attributes -> XmlTrees -> Doc

-- | Pretty print trees as text, quoting them.
prettyLiteralTrees :: XmlTrees -> Doc

-- | Pretty print an external ID.
prettyExternalId :: Attributes -> Doc

-- | Pretty print a Parameter Entity Reference.
prettyPEAttr :: Attributes -> Doc

-- | Given a list of attributes, pretty print the value in them.
prettyValue :: Attributes -> XmlTrees -> Doc
prettyEnum :: Attributes -> Doc

-- | Forward slash character.
slash :: Doc

-- | New line character.
nl :: Doc

-- | Enclose document in angle brackets.
angles :: Doc -> Doc

-- | Compose two documents, separating them by a new line.
--   
--   The new line is not inserted if either document is empty.
(<|>) :: Doc -> Doc -> Doc

-- | Concatenate a list od documents, separating them by a given separator.
sepBy :: Doc -> [Doc] -> Doc
instance Language.XMLSpec.PrintTrees.Pretty [Text.XML.HXT.DOM.TypeDefs.XmlTree]
instance Language.XMLSpec.PrintTrees.Pretty Text.XML.HXT.DOM.TypeDefs.XmlTree
instance Language.XMLSpec.PrintTrees.Pretty (Text.XML.HXT.DOM.TypeDefs.DTDElem, Text.XML.HXT.DOM.TypeDefs.Attributes, Text.XML.HXT.DOM.TypeDefs.XmlTrees)
instance Language.XMLSpec.PrintTrees.Pretty Text.XML.HXT.DOM.QualifiedName.QName
instance Language.XMLSpec.PrintTrees.Pretty (GHC.Base.String, Text.XML.HXT.DOM.TypeDefs.Attributes)

-- | Parser for Ogma specs stored in XML files.
module Language.XMLSpec.Parser

-- | List of XPath routes to the elements we need to parse.
--   
--   The optional paths denote elements that may not exist. If they are
--   nothing, those elements are not parsed in the input file.
--   
--   The subfields are applied on each string matching the parent element.
--   That is, the internal var ID XPath will be a applied to the strings
--   returned when applying the internal vars XPath (if it exists). Paths
--   whose names are plural denote expected lists of elements.
--   
--   The components of a tuple (String, Maybe (String, String)) mean the
--   following: if a string is present but the second component is Nothing,
--   then the string is the XPath expression to be used. If a Just value is
--   present, the first element of its inner tuple represents a key, and
--   the second element represents an XPath expression that will produce a
--   value when evaluated globally in the file. After evaluating that
--   expression, the key must be found in the first string of the three and
--   replaced with the result of evaluating the expression.
data XMLFormat
XMLFormat :: Maybe String -> (String, Maybe (String, String)) -> (String, Maybe (String, String)) -> Maybe (String, Maybe (String, String)) -> Maybe String -> (String, Maybe (String, String)) -> Maybe (String, Maybe (String, String)) -> (String, Maybe (String, String)) -> (String, Maybe (String, String)) -> Maybe (String, Maybe (String, String)) -> (String, Maybe (String, String)) -> Maybe (String, Maybe (String, String)) -> Maybe (String, Maybe (String, String)) -> XMLFormat
[specInternalVars] :: XMLFormat -> Maybe String
[specInternalVarId] :: XMLFormat -> (String, Maybe (String, String))
[specInternalVarExpr] :: XMLFormat -> (String, Maybe (String, String))
[specInternalVarType] :: XMLFormat -> Maybe (String, Maybe (String, String))
[specExternalVars] :: XMLFormat -> Maybe String
[specExternalVarId] :: XMLFormat -> (String, Maybe (String, String))
[specExternalVarType] :: XMLFormat -> Maybe (String, Maybe (String, String))
[specRequirements] :: XMLFormat -> (String, Maybe (String, String))
[specRequirementId] :: XMLFormat -> (String, Maybe (String, String))
[specRequirementDesc] :: XMLFormat -> Maybe (String, Maybe (String, String))
[specRequirementExpr] :: XMLFormat -> (String, Maybe (String, String))
[specRequirementResultType] :: XMLFormat -> Maybe (String, Maybe (String, String))
[specRequirementResultExpr] :: XMLFormat -> Maybe (String, Maybe (String, String))

-- | Parse an XML file and extract a Spec from it.
--   
--   An auxiliary function must be provided to parse the requirement
--   expressions.
--   
--   Fails if any of the XPaths in the argument XMLFormat are not valid
--   expressions, of the XML is malformed, or if the elements are not found
--   with the frequency expected (e.g., an external variable id is not
--   found even though external variables are found).
parseXMLSpec :: (String -> IO (Either String a)) -> a -> XMLFormat -> String -> IO (Either String (Spec a))

-- | Internal representation of an XML Format specification.
data XMLFormatInternal
XMLFormatInternal :: Maybe XPathExpr -> XPathExpr -> XPathExpr -> Maybe XPathExpr -> Maybe XPathExpr -> XPathExpr -> Maybe XPathExpr -> XPathExpr -> XPathExpr -> Maybe XPathExpr -> [XPathExpr] -> Maybe XPathExpr -> Maybe XPathExpr -> XMLFormatInternal
[xfiInternalVars] :: XMLFormatInternal -> Maybe XPathExpr
[xfiInternalVarId] :: XMLFormatInternal -> XPathExpr
[xfiInternalVarExpr] :: XMLFormatInternal -> XPathExpr
[xfiInternalVarType] :: XMLFormatInternal -> Maybe XPathExpr
[xfiExternalVars] :: XMLFormatInternal -> Maybe XPathExpr
[xfiExternalVarId] :: XMLFormatInternal -> XPathExpr
[xfiExternalVarType] :: XMLFormatInternal -> Maybe XPathExpr
[xfiRequirements] :: XMLFormatInternal -> XPathExpr
[xfiRequirementId] :: XMLFormatInternal -> XPathExpr
[xfiRequirementDesc] :: XMLFormatInternal -> Maybe XPathExpr
[xfiRequirementExpr] :: XMLFormatInternal -> [XPathExpr]
[xfiRequirementResultType] :: XMLFormatInternal -> Maybe XPathExpr
[xfiRequirementResultExpr] :: XMLFormatInternal -> Maybe XPathExpr

-- | Internal representation of an XPath expression.
type XPathExpr = String

-- | Resolve an indirect XPath query, returning an XPath expression.
resolveIndirectly :: String -> (String, Maybe (String, String)) -> ExceptT String IO XPathExpr

-- | Resolve an indirect XPath query, returning a list of XPath
--   expressions.
resolveIndirectly' :: String -> (String, Maybe (String, String)) -> ExceptT String IO [XPathExpr]

-- | Check that an XPath expression is syntactically correct.
checkXPathExpr :: String -> Either String XPathExpr

-- | Check an XMLFormat and return an internal representation.
--   
--   Fails with an error message if any of the given expressions are not a
--   valid XPath expression.
parseXMLFormat :: XMLFormat -> String -> ExceptT String IO XMLFormatInternal

-- | Execute an XPath query in an XML string, returning the list of strings
--   that match the path.
executeXPath :: String -> String -> IO [String]

-- | Unescape <, > and
--   & in a string.
textUnescape :: String -> String

-- | Swap the Maybe and Either layers of a value.
swapMaybeEither :: Maybe (Either a b) -> Either a (Maybe b)

-- | Swap the Maybe and Either layers of a value.
swapMaybeExceptT :: Monad m => Maybe (ExceptT a m b) -> ExceptT a m (Maybe b)

-- | Convert a list to an Either, failing if the list provided does not
--   have exactly one value.
listToEither :: String -> [String] -> Either String String

-- | Replace a string by another string
replace :: String -> String -> String -> String

-- | Map a monadic action over the elements of a container and concatenate
--   the resulting lists.
concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b]
instance GHC.Read.Read Language.XMLSpec.Parser.XMLFormat
instance GHC.Show.Show Language.XMLSpec.Parser.XMLFormat
