dbonerow.cd 1.88 KB
Newer Older
1
type Table = <table>[Row*]
2 3 4 5 6 7 8 9
type Row = <row> [
  <id>[PCDATA]
  <firstname>[PCDATA]
  <lastname>[PCDATA]
  <street>[PCDATA]
  <city>[PCDATA]
  <state>[PCDATA]
  <zip>[PCDATA]
10
]
11

12
(*
13
include "../../web/xhtml-strict.cd"
14 15
*)
type Xhtml = Any
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

let fun dbonerow (<table> x : Table) : Xhtml = 
<html>[
  <head>[<title>"Dbonerow test"]
  <body>
     (transform x with
       <row>[<_>("0432"&id) <_>fn <_>ln <_>st <_>city <_>state <_>zip ] -> 
         [<table border="0";style="background-color:#888888">[
            <tr>[
                 <td colspan="2";style="background-color:#000000; color:white">
                 (*<font color="#ffffff"> deprecated in Xhtml strict*)
                 ("personel record #" @ (id))                  
            ]
            <tr>[
               <td style="background-color:#888888"> "First Name:"
               <td style="background-color:#dddddd"> fn
            ]
            <tr>[
               <td style="background-color:#888888"> "Last Name: "
               <td style="background-color:#dddddd"> ln
            ]
            <tr>[
               <td style="background-color:#888888"> "Street: "
               <td style="background-color:#dddddd"> st
            ]
            <tr>[
               <td style="background-color:#888888"> "City: "
               <td style="background-color:#dddddd"> city
            ]
            <tr>[
               <td style="background-color:#888888"> "State: "
               <td style="background-color:#dddddd"> state
            ]
            <tr>[
               <td style="background-color:#888888"> "Zip: "
               <td style="background-color:#dddddd"> zip
            ]
          ]
        ]
     )
]

58 59
match (argv []) with
 (f,_) -> (*load_xml f*)
60 61 62 63
   (match load_xml f with
     | x & Table -> print_xml(dbonerow x)
     | _ -> raise "Ma che c%$#^# di file mi hai passato?")
| _ -> raise "Please specify input file on command line"