logo       


r9948 - trunk/libraries/koala/sources/examples/buddha: msg#00007

Subject: r9948 - trunk/libraries/koala/sources/examples/buddha
Author: hannes
Date: Fri Sep  2 23:29:25 2005
New Revision: 9948

Added:
   trunk/libraries/koala/sources/examples/buddha/xml.dylan
Modified:
   trunk/libraries/koala/sources/examples/buddha/buddha.dylan
   trunk/libraries/koala/sources/examples/buddha/buddha.lid
   trunk/libraries/koala/sources/examples/buddha/library.dylan
Log:
Bug: 7257
xml-builder macro


Modified: trunk/libraries/koala/sources/examples/buddha/buddha.dylan
==============================================================================
--- trunk/libraries/koala/sources/examples/buddha/buddha.dylan  (original)
+++ trunk/libraries/koala/sources/examples/buddha/buddha.dylan  Fri Sep  2 
23:29:25 2005
@@ -528,5 +528,30 @@
 end;
 
 begin
-  main();
+  main3();
 end;
+
+define method main3()
+let foo =
+with-xml-builder()
+  html {
+    head {
+      title("foo")
+    },
+    body {
+      div(id => "foobar",
+          class => "narf") {
+        a("here", href => "http://www.foo.com";),
+        text("foobar"),
+        ul {
+          li("foo"),
+          br,
+          li("bar"),
+          br
+        }
+      }
+    }
+  }
+end;
+  format-out("%=\n", foo);
+end;
\ No newline at end of file

Modified: trunk/libraries/koala/sources/examples/buddha/buddha.lid
==============================================================================
--- trunk/libraries/koala/sources/examples/buddha/buddha.lid    (original)
+++ trunk/libraries/koala/sources/examples/buddha/buddha.lid    Fri Sep  2 
23:29:25 2005
@@ -3,6 +3,7 @@
 files: library
        util
        html-utils
+       xml
        config
        network
        vlan

Modified: trunk/libraries/koala/sources/examples/buddha/library.dylan
==============================================================================
--- trunk/libraries/koala/sources/examples/buddha/library.dylan (original)
+++ trunk/libraries/koala/sources/examples/buddha/library.dylan Fri Sep  2 
23:29:25 2005
@@ -11,6 +11,7 @@
   use network;
   use system, import: { file-system };
   use xml-rpc-common;
+  use xml-parser;
   export buddha;
 end;
 
@@ -29,4 +30,5 @@
   use sockets, import: { <tcp-socket>, <internet-address> };
   use file-system;
   use xml-rpc-common, import: { base64-encode, base64-decode };
+  use xml-parser;
 end;

Added: trunk/libraries/koala/sources/examples/buddha/xml.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/koala/sources/examples/buddha/xml.dylan     Fri Sep  2 
23:29:25 2005
@@ -0,0 +1,86 @@
+module: buddha
+
+/*
+with-xml-builder()
+  html {
+    head {
+      title("foo")
+    },
+    body {
+      div(id => "foobar",
+          class => "narf") {
+        a("here", href => "http://www.foo.com";),
+        text("foobar"),
+        ul {
+          li("foo"),
+          br,
+          li("bar"),
+          br
+        }
+      }
+    }
+  }
+end;
+
+generates:
+
+<html>
+  <head>
+    <title>foo</title>
+  </head>
+  <body>
+    <div id="foobar" class="narf">
+      <a href="http://www.foo.com";>here</a>
+      foobar
+      <ul>
+        <li>foo</li>
+        <br/>
+        <li>bar</li>
+        <br/>
+      </ul>
+    </div>
+  </body>
+</html>
+*/
+
+define macro with-xml-builder
+  { with-xml-builder ()
+      ?element
+    end }
+   => { begin
+          let doc = make(<document>,
+                         children: list(?element));
+          transform-document(doc, state: make(<add-parents>));
+          doc;
+        end; }
+
+  element:
+   { ?:name } => { make(<element>, name: ?"name") }
+   { text ( ?value:expression ) } => { make(<char-string>,
+                                            text: ?value) }
+   { ?:name { ?element-list } }
+    => { make(<element>, children: list(?element-list), name: ?"name") }
+   { ?:name ( ?attribute-list ) { ?element-list } }
+    => { make(<element>,
+              children: list(?element-list),
+              name: ?"name",
+              attributes: vector(?attribute-list)) }
+   { ?:name ( ?value:expression ) }
+    => { make(<element>,
+              children: list(make(<char-string>, text: ?value)),
+              name: ?"name") }
+   { ?:name ( ?value:expression, ?attribute-list ) }
+    => { make(<element>, name: ?"name", attributes: vector(?attribute-list)) }
+   //{ comment ( ?value:expression ) } =>  { make-comment(?value) }
+
+  element-list:
+   { } => { }
+   { ?element, ... } => { ?element, ... }
+
+  attribute-list:
+   { ?key:expression => ?value:expression }
+                 => { make(<attribute>, name: ?"key", value: ?value) }
+   { ?key:expression => ?value:expression, ... }
+                 => { make(<attribute>, name: ?"key", value: ?value), ... }
+
+end;
\ No newline at end of file
-- 
Gd-chatter mailing list
Gd-chatter@xxxxxxxxxxxxxxxx
https://gauss.gwydiondylan.org/mailman/listinfo/gd-chatter



Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
Search:
Java, servers, webhosting, windows, cisco ...
more...
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe