DtdToHaskell(1)

πŸŽ€ DtdToHaskell πŸŽ€

Bestie, this is the manual for DtdToHaskell, the User Commands tool that turns XML DTDs into Haskell types. Let's get into it πŸ’–

✨ NAME ✨

DtdToHaskell, an XML DTD to Haskell translator πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

DtdToHaskell [ dtdfile [ outfile ]]

Missing file arguments or dashes (-) mean standard input or output, respectively 🫢

🌸 DESCRIPTION 🌸

Okay so DtdToHaskell can translate any valid XML DTD into equivalent Haskell types πŸ”₯ That means you can generate, edit, and transform documents as normal typed values in your programs, then read and write them as human-readable XML. It's giving total glow-up energy ✨ It uses the Text.XML.HaXml.XmlContent class as its framework for printing and parsing.

It reads and parses a DTD from dtdfile. That file can be just a DTD, or a full XML document with an internal DTD, both are valid vibes 🧚 Then it generates into outfile a Haskell module with a collection of type definitions, plus some class instance declarations for I/O.

To use the resulting module, you need to import it, and import Text.XML.HaXml.XmlContent. To read and write XML files as values of the declared types, use some of the convenience functions from XmlContent πŸ’œ

You'll want to study the auto-generated type declarations before writing your own code with them. Lowkey, though, most things have pretty obvious parallels to the DTD structure, so it's not that deep πŸ™ˆ

🚧 LIMITATIONS 🚧

Okay, real talk, there are a few things to know πŸ’€

The generated Haskell references types like OneOf3 wherever there's a choice between n (in this case 3) different tags. Currently, the module Text.XML.HaXml.OneOfN defines these types up to n=20. If your DTD needs bigger choices, use the tool MkOneOf to generate the extra size or range of sizes you need 🌈

We mangle tag names and attribute names so they have the correct lexical form in Haskell. The tea is that this means we can't tell apart Myname and myname, which are different names in XML but translate to overlapping types in Haskell. They'll probably refuse to compile 😭

Attribute names translate into named fields. Haskell doesn't allow different types to have the same named field, so if your XML document uses the same name for similar attributes on different tags, it would crash and burn πŸ’€ We fixed this by incorporating the tagname into the named field in addition to the attribute name, e.g. tagAttr instead of just attr. Uglier, but more portable πŸ’…

XML namespaces are still a work in progress πŸ™ˆ Currently, we just mangle the namespace identifier into any tag name which uses it. The probably right way to do it would be to treat the namespace as a separate imported module, and translate the namespace prefix into a module qualifier. Does this sound about right? (It isn't implemented yet.)

External subset is giving main character energy πŸ‘‘ Since HaXml release 1.00, we support the XML DTD external subset. This means we can read and parse a whole bunch of files as part of the same DTD, and we respect INCLUDE and IGNORE conditional sections. The sub-DTD files must be available locally, though. We don't go looking for them on the web πŸ•ΈοΈ

There are some fringe parts of the DTD we aren't entirely sure about, such as Tokenised Types and Notation Types. In particular, there's no validity checking of these external references. If you find a problem, mail us at:

Malcolm.Wallace@cs.york.ac.uk

The HaXml library and tools were written by, and are copyright to:

Copyright Β© 1998 – 2006    Malcolm Wallace and Colin Runciman

The library incorporates the module Text.ParserCombinators.HuttonMeijerWallace:

Copyright Β© 1996           Graham Hutton and Erik Meijer

...with modifications:

Copyright Β© 1998 – 2000    Malcolm Wallace

And it may also use or incorporate the module Text.PrettyPrint.HughesPJ:

Copyright Β© 1996 – 1997    John Hughes and Simon Peyton Jones

The HaXml library is licensed under the terms of the GNU Lesser General Public Licence (LGPL), with one special exception πŸ¦‹ As a relaxation of clause 6 of the LGPL, the copyright holders of this library give permission to use, copy, link, modify, and distribute binary-only object-code versions of an executable linked with the Library. You don't have to supply any mechanism to modify or replace the Library and relink (clauses 6a, 6b, 6c, 6d, 6e), as long as all the other terms of clause 6 are complied with.

The HaXml tools Xtract, Validate, DtdToHaskell, and MkOneOf are licensed under the terms of the GNU General Public Licence (GPL) πŸ’œ

This library and toolset is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Licences for more details πŸ™ˆ

πŸ”— SEE ALSO πŸ”—

MkOneOf(1), Validate(1) 🌸

πŸ’Œ AUTHOR πŸ’Œ

The contents of this manual page were copied from the HTML documentation and slightly edited by Arjan Oosting <arjan@debian.org> for the Debian system (but may be used by others) 🫢


That's the tea, bestie! πŸ“ DtdToHaskell, version 1.17, October 2007 🧚 Stay iconic and keep those types typed πŸ’–βœ¨