W3C home > Mailing lists > Public > www-svg@w3.org > October 2003

SVG-based Template via javascript

From: Fred P. <fprog26@hotmail.com>
Date: Mon, 06 Oct 2003 05:14:52 -0400
To: www-svg@w3.org
Cc: svg-developers@yahoogroups.com
Message-ID: <BAY2-F113y3UiIMbhiv00018d09@hotmail.com>


    - A pure XML based template declaration

    - SVG Editor with simple ecmascript can 'understand' these templates
      by using them as objects with parameters (or attributes or properties)

    - Parameters type can be typesafe, declared, with min/max/default 
values, etc.

    - An editor can therefore design objects parameter "editor" dialog
      using such information like IDL have done for OOP language.

    - An editor can drag, resize, move, create, delete these objects.

    - Fully descriptive

    - No need to invent any new language

    - SVG 1.0/1.1 can be supported using a proper ecmascript translator:
      left as an exercise shouldn't be too complicated to implement 

    - Need an XML standard on which all SVG editor 1.2 can rely on
      for describing unknown objects/figures/entities...

<?xml version="1.0" encoding="iso-8859-1"?>
  width='1024' height='700' enableZoomAndPanControls='false'
  <template xmlns='http://xmlns.fred.com/'
    <param name='x'     type='Integer' min='0' max='100' default='0'  />
    <param name='y'     type='Integer' min='0' max='100' default='0'  />
    <param name='w'     type='Integer' min='0' max='20'  default='10' />
    <param name='h'     type='Integer' min='0' max='20'  default='10' />
    <param name='id'    type='String'  min='0' max='80'  default='fred' />
    <param name='drag'  type='Boolean'                   default='false' />
    <param name='child' type='NodeList' empty='true'     default='null' />

  <!-- Cannot be move or resize -->
  <template name='f:pizza' function='drawPizza(x,y)'>
    <param name='x'     type='Integer' min='0' max='100' default='0'  />
    <param name='y'     type='Integer' min='0' max='100' default='0'  />

<f:user  x='10' y='10' w='10' h='10'/>
<f:pizza x='30' y='30'/>

<script type='text/ecmascript'
function drawPizza(x,y) { return drawUser(x,y,10,10,'pizza',false,null); }

function resizeUser(node,w,h) { node.setAttribute( 'width', w ); 
node.setAttribute( 'height', h ); return node; }
function moveUser(node,w,h)   { node.setAttribute( 'x',     x ); 
node.setAttribute( 'y',      y ); return node; }

function drawUser(x,y,w,h,id,drag,child)
  var s = "<rect x='" + x + "' y='" + y + "' width='"+ w +"' height='"+ h 

  // Return an XML node
  return parseXML( s, document );

Comments, suggestions welcome.

Sincerely yours,

Tired of spam? Get advanced junk mail protection with MSN 8.  
Received on Monday, 6 October 2003 05:14:54 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:53:59 UTC