Hi Malcom,
I discovered a problem with Xml2Haskell which is possibly a (small) bug.
I have a DTD, which I translate with "DTDToHaskell" to a Haskell module.
Further, I use a small main module and a XML input file for testing it.
When I execute the above example, I get the error message:
Fail: DTD_Root.hs:32: Non-exhaustive patterns in function fromElem
After inserting:
fromElem rest = (Nothing, rest)
to line 40 of DTD_Root.hs, everything works fine.
I use GHC 4.08.2 on Windows - since unfortunately GHC5.0 for Win is not available yet
:-(
Here's the DTD:
<!DOCTYPE Root [
<!ELEMENT Root ( Group* )>
<!ELEMENT Group ( Group | Item* )>
<!ATTLIST Group
name CDATA #REQUIRED
>
<!ATTLIST Item
name CDATA #REQUIRED
val CDATA #REQUIRED
>
]>
And that's the main module:
module Main(main) where
import DTD_Root
import Xml2Haskell(readXml,writeXml)
main = do
d <- read_test_in
writeXml "test-out.xml" d
where read_test_in :: IO Root
read_test_in = readXml "test-in.xml"
The "test-in.xml" has the following contents:
<Root>
<Group name="Abc">
<Item name="Test" val="1" />
</Group>
</Root>
I compile it like this:
dtdtohaskell demo.dtd DTD_Root.hs
ghc -c DTD_Root.hs -package text
ghc -c main.hs -package text
ghc -o main *.o -package text
Christian
<<demo.dtd>> <<test-in.xml>> <<main.hs>>
demo.dtd
test-in.xml
main.hs