
On Tue, May 31, 2011 at 00:30, Yitzchak Gale
For example, I couldn't use name, because for DTD namespaces *are* significant so they need a different Eq instance. I ended up just using Text."
I don't understand what this means; the xml-types Eq instance for Name compares both the namespace and local name
Ah, OK. I misunderstood the docs - it says that the "prefix" is not used in the Eq instance, so I took that to mean that namespaces prefixes were not used. Now that I look more carefully at the code itself, I see that is not true.
But then what is a "prefix"? The IsString instance always sets the prefix to Nothing. I've scoured the XML spec and not found anything it could possibly represent. What have I missed?
Lets say you have a document like this:
Another point I noticed when looking at the IsString instance for Name: it can introduce crashes into a program if someone accidentally puts a '{' at the beginning of a Name string. Everywhere else, your code is safe; even if someone inserts invalid XML, you leave it up to the application to decide how much to validate and what to do if validation fails.
So could you please change this to pass the string through as a plain Name without a namespace if Clark notation parsing fails? Thanks.
The IsString instance is intended for overloaded string literals -- that is, the source code would look something like this: ------------------ elem = Element "{http://my/namespace/here}doc" [] [] ------------------ It's not intended for parsing arbitrary input, as it performs no validation of its input (aside from trivial checks for Clark brackets). If you are concerned that a developer may cause exceptions by writing incorrect code, it would be better to use the Name constructor directly.
I noticed that you did not send your response to the list. Do you mind if I forward a copy of this response to the web-devel list?
Oops, didn't realize there were two separate email threads. Here's the
text of my earlier email, for future readers:
----------------
On Mon, May 30, 2011 at 11:13, John Millikin
I agree that it makes more sense as a separate package -- DTDs are sort of a layer on top of XML, and there's lots of people who want to work with one without worrying about the other. I don't mind merging them if you want, but separate seems better.
For example, I couldn't use name, because for DTD namespaces *are* significant so they need a different Eq instance. I ended up just using Text."
I don't understand what this means; the xml-types Eq instance for Name compares both the namespace and local name:
-------------------------------- instance Eq Name where (==) = (==) `on` (\x -> (nameNamespace x, nameLocalName x)) --------------------------------
As to the package itself, I have only one suggestion: can you add a constructor to DTDComponent for processing instructions? If I'm reading the XML spec correctly, these can occur anywhere within a DTD.
Thank you very much for the good work!