File: README

package info (click to toggle)
ghc-cvs 20040725-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 68,484 kB
  • ctags: 19,658
  • sloc: haskell: 251,945; ansic: 109,709; asm: 24,961; sh: 12,825; perl: 5,786; makefile: 5,334; xml: 3,884; python: 682; yacc: 650; lisp: 477; cpp: 337; ml: 76; fortran: 24; csh: 18
file content (77 lines) | stat: -rw-r--r-- 2,543 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Please note:
The example code in this directory may not always work with the
current version of the the HaXml libraries.  What little time I have
for maintenance goes into the main HaXml facilites, not into testing
these small demonstration exercises.  Sorry.


Parse/Pretty-Print example  (Canonicalise.hs)
--------------------------
To demonstrate parsing and pretty-printing, I wrote a simple in-out
application:
    $ hmake Canonicalise -I../lib
Test it on some XML documents:
    $ ./Canonicalise album.xml
You will notice that it changes some parts of the document, for instance in
    $ ./Canonicalise subjdb.xml
all parameter entities are replaced with their expansion.


Xml2Haskell example  (album.dtd, AlbumDTD.hs, album.xml)
-------------------
In this example, I did the following:

Convert the XML DTD for an album into a Haskell module:
    $ DtdToHaskell album.dtd AlbumDtd.hs

Edit the generated file (just to change the module name to match!)
    $ vi AlbumDtd.hs

Wrote the test application (App.hs) using AlbumDTD.hs, and compiled it:
    $ hmake App -I../lib

Running the test displays some progress messages, and outputs the original
document again, only with the album title changed.
    $ ./App album.xml new.xml

And that's it.


Haskell2Xml example  (Types.hs, DTypes.hs, Example.hs, subjdb.xml)
-------------------
The file Types.hs defines some data types for a mini-database.
Derive the Haskell2Xml apparatus using DrIFT:
    $ DrIFT Types.hs >DTypes.hs

The example program in Example.hs just writes some Haskell data to
an XML file.
    $ hmake Example -I../lib
    $ ./Example
    $ less subjdb.xml

I hope that's reasonably clear.


Bigger DtdToHaskell example
---------------------------
In directory SMIL, do
    $ DtdToHaskell SMIL20.dtd DTD_SMIL20.hs
and have a look at the resulting Haskell file.  This is a large
multi-part DTD for the Synchronised Multimedia Integration Language,
defined by the W3C.  As of 2000-11-16, our XML parser has been extended
to deal with the external subset as fully as possible.

DTDpp
-----
This little program is just a pretty-printer for an XML DTD - it
inlines any included files and expands all PE references.  Its main
use is to check that the HaXml parser can read a complicated DTD
without errors.

DebugLex
--------
Another little debugging program to help find errors in HaXml -
this time in the lexer.  It prints a stream of lexed tokens (and
their source positions) to stdout, so you can examine whether
some complicated piece of syntax has confused the lexer.