Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: XML Dialect

From: al:bri:xtra at: 25-Apr-2002 21:17

Andrew wrote:
> Here's my first try at an XML dialect for Rebol.
And here's my second try. It does HTML as well, and is smaller. Plus it incorporates the SVG MIME correction from Adobe's FAQ. Comments and suggestions gratefully appreciated. Andrew Martin Rebolios ANZAC... ICQ: 26227169 http://valley.150m.com/ -><- [ Rebol [ Name: 'XML Title: "XML" File: %XML.r Author: "Andrew Martin" eMail: [Al--Bri--xtra--co--nz] Date: 25/Apr/2002 ] make object! [ set 'XML function [Dialect [block!] ] [ String Values Properties Value Tag ] [ String: make string! 10000 Values: make block! 10 Properties: [ none [ set Value any-type! ( Tag: at Tag 3 if word? Value [Value: to-string Value] insert Tag Value Value: none ) ] ] parse Dialect [ any [ set Value tag! (append String Value) | set Tag [path! | word!] ( Tag: to-block get 'Tag Properties/1: -1 + length? Tag ) Properties opt [set Value [block! | string!]] ( Tag: head Tag repend String either none? Value [ [join build-tag Tag " /"] ] [ [ build-tag Tag either block? Value [XML Value] [Value] to-tag join "/" first Tag ] ] Properties/1: none ) ] end ] String ] ] File: %Test.svg write File XML [ <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> svg/width/height 300 300 [ desc "Several rectangles" rect/x/y/width/height/style 80 53 189 52 { fill:rgb(39,44,231); stroke:rgb(0,0,128); stroke-width:1 } rect/x/y/width/height/style 0 0 189 152 { fill:olive; stroke:pink; stroke-width:5; fill-opacity:0.1 } g/id/fill Group1 red [ rect/x/y/width/height 10 10 30 40 rect/x/y/width/height 30 30 30 40 ] text/x/y/font-family/font-size/fill 20 15 "Verdana" 12 green "Hello from Rebol SVG dialect!" ] ] File: %Test.html write File XML [ html [ head [ title "Test" ] body [ h1 "Test" p/class "Initial" "Test paragraphs" p {Now is the time for all good men to come to the aid of the party.} hr embed/src/name/type/pluginspage "Test.svg" "Test" "image/svg+xml" http://www.adobe.com/svg/viewer/install/ ] ] ] browse File ]