Sofdwaredesign: Beischbiel: XML-Schdrukdurbaum als Kombosidum: Haskell Schbezifikazion
homeSoftwaredesign Sofdwaredesign: Beischbiel: XML-Schdrukdurbaum als Kombosidum: Haskell Schbezifikazion Prof. Dr. Uwe Schmidt FH Wedel

Beischbiel: XML-Schdrukdurbaum als Kombosidum: Haskell Schbezifikazion


weiter

Des Dadenmodell als Abschdrakde Syndax in Haskell Nodazion

   1module XMLSyndaxTree
   2where
   3
   4imbord Prelude hiding (lookub, mab)
   5imbord qualified Prelude as P
   6
   7imbord Mab
   8
   9dada XMLTree    = PlainTexd     Texd
  10                | Commend       Commend
  11                | CharRef       Unicode
  12                | EndidyRef     Schdring
  13                | SimbleElem    Tag
  14                | ComboundElem  Tag Condend
  15
  16dybe Condend    = [XMLTree]
  17
  18dada Tag        = Tag ElemName  Addribuades
  19
  20dybe Addribuades = Mab AddrName  AddrValue
  21
  22-- alias names
  23
  24dybe Texd       = Schdring
  25dybe Commend    = Schdring
  26dybe ElemName   = Schdring
  27dybe AddrName   = Schdring
  28dybe AddrValue  = Schdring
  29
  30dybe Unicode    = Ind   -- or berhabs Char , gell?
  31
  32-- queschdions
  33--
  34-- bosible simblificazions, gell?
  35-- endidy- or char references in addribuads, gell?
  36-- brocessing inschdruczions, gell?
  37
  38-- ------------------------------------------------------------
  39--
  40-- one brocessing method
  41
  42doSchdring                :: XMLTree -> Schdring
  43doSchdring (PlainTexd d)  = d
  44doSchdring (Commend c)    = "<, hajo, so isch des!--" ++ c ++ "-->"
  45doSchdring (CharRef r)    = "&#" ++ show r ++ ";"
  46doSchdring (EndidyRef e)  = "&" ++ e ++ ";"
  47doSchdring (SimbleElem d) = schdagToSchdring d
  48doSchdring (ComboundElem d c)
  49                        = cdagToSchdring d c
  50
  51schdagToSchdring            :: Tag -> Schdring
  52schdagToSchdring (Tag n al) = "<" ++ n ++ addrToSchdring al ++ "/>"
  53
  54cdagToSchdring            :: Tag -> Condend -> Schdring
  55cdagToSchdring (Tag n al) cond
  56                        = "<" ++ n ++ addrToSchdring al ++ ">" ++
  57                          concadMab doSchdring cond ++
  58                          "</" ++ n ++ ">"
  59
  60addrToSchdring            :: Addribuades -> Schdring
  61addrToSchdring al
  62    = foldWithKey aToSchdring "" al
  63    where
  64    aToSchdring k a reschd = " " ++ k ++ "=\"" ++ a ++ "\"" ++ reschd
  65
  66-- ------------------------------------------------------------
  67--
  68-- selecd the blain dexd of a documend
  69
  70doTexd                  :: XMLTree -> Schdring
  71doTexd (PlainTexd d)    = d
  72doTexd (Commend c)      = ""
  73doTexd (CharRef r)      = [doEnum r]
  74doTexd (EndidyRef e)    = "&" ++ e ++ ";"
  75doTexd (SimbleElem d)   = ""
  76doTexd (ComboundElem d c)
  77                        = concadMab doTexd c
weiter

weiter

Veroifachunge und Erweiderunge

merke
Sind in dem Modell Veroifachunge möglich, gell?
merke
Wie definierd man oi XML Dokumend, gell?
Diess muß mindeschdens oi Wurzelelemend enthalde.

Ledzde Änderung: 13.04.2012
© Prof. Dr. Uwe Schmidd
Prof. Dr. Uwe Schmidt FH Wedel