[Haskell] HaXML incorrect interpretation of XML spec!
S. Alexander Jacobson
alex at alexjacobson.com
Thu Oct 28 00:44:12 EDT 2004
I modified the Prolog type to be
data Prolog = Prolog (Maybe XMLDecl) [Misc] (Maybe DocTypeDecl) [Misc]
and then modified the Prolog parser (which
actually was correct) to actually use the misc
values in constucting the Prolog. I replace the
prolog function in pretty.hs with
prolog (Prolog x m1 dtd m2) = maybe xmldecl x $$
vcat (map misc m1) $$
maybe doctypedecl dtd $$
vcat (map misc m2)
and did a few more similar things in
Haskell2XML and XML2Haskell (about a 5 min
operation) and it all seems to work properly.
Implementation question: Why is there so much
replicated code in HaXML/Html (parse.hs and
Given that this fix was so very easy and given
that the parser was already spec consistent, I now
have to assume that there was good reason for the
Prolog to be spec inconsistent, but I don't know
what it is...
On Wed, 27 Oct 2004, S. Alexander Jacobson wrote:
> The XML spec defines the prolog(1) as follows:
>  prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
> In other words you can have Misc before AND after
> the doctype declaration!
> HaXml defines the prolog(2) as:
> data Prolog = Prolog (Maybe XMLDecl) (Maybe DocTypeDecl)
> HaXml therefore does not allow PIs before the
> beginning of the top level element. This is a
> problem in practice for people who want to use
> e.g. XML-Stylesheets(3) where if one is using XSL
> to produce HTML it is necessary to put
> the stylesheet declaration BEFORE the root element
> (if the root element is not HTML). e.g.
> <?xml version="1.0"?>
> <?xml:stylesheet type="text/xsl" href="style.xsl"?>
> <foo id="57" category="2"/>
> Is there some way to puta PI before the
> root element in combinators?
> (1) http://www.w3.org/TR/REC-xml/#sec-prolog-dtd
> (2) http://www.cs.york.ac.uk/fp/HaXml/HaXml/Text.XML.HaXml.Types.html#Prolog
> (3) http://www.w3.org/TR/xml-stylesheet/
> S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com
> Haskell mailing list
> Haskell at haskell.org
S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com
More information about the Haskell