White Paper from the ex-owner of Witango - found in my archiv...
Sorry for the bad formating
Regards
Daniel
XML in Witango
Overview
Witango provides the Witango programmer with an exciting, and extremely powerful, new
abstraction based on XML in the form of "DOM variables". This article explores how to use DOM
variables, and why they are going to change the way you create Witango applications. [Please note that,
as this is being written, some of the features described are still in development. The exact syntax of
tags may be different as shipped.]
What are "DOM variables?"
A DOM variable is a new data type available to the Witango programmer for holding hierarchical,
structured, data. In common parlance, this type of data is often referred to as a "tree." With Witango
, you have the ability to create, manipulate, and navigate these data structures, as well as export
them as XML. By way of example, consider the following XML snippet:
<portfolio>
<stocks>
<stockposition ID="PVSW">1000</stockposition>
<stockposition ID="ORCL">-1000</stockposition>
</stocks>
<bonds />
<cash>
<USD>100000</USD>
</cash>
</portfolio>
If you are not familiar with XML and the letters "DOM" aren�t familiar, don�t worry because it�s all pretty
simple (see Sidebar). The XML "document" given above is simply saying that there is a structure
called a "portfolio," that consists of "stocks," "bonds," and "cash". It also says that the portfolio has two
stockpositions, which are children of the node, or element, called "stocks," and that there are no
children of "bonds," and finally that there is US$100,000 in cash.
As you can see, there is a clear parent-child relationship between the elements of this tree, and the
beauty of DOM variables is that this entire structure, no matter how complex it may be, can be put into
a single variable that you can then use.
Why should I care?
The big question, of course, is why you ever want to keep structured data like the above in variables.
Well, there are two very good reasons.
Programmer meets artist � and communicates! Team productivity follows.
The first reason for using DOM variables is to enable you to separate business logic from
presentation. Let�s say that you are doing an electronic trading system, and that you want provide the
ability for users to see their portfolio at a glance. Well, if you were writing a small system, you could do
the whole thing yourself and you might not need DOM variables at all. But consider that you might
have a couple of systems people doing the database backend, and some creative types doing the
funky HTML interface stuff. While Witango makes it easy to interface to the backend, and (through
Witango�s awesome DreamWeaver integration) easy to create your interface, it is tough to keep
the two operations separate enough to allow multiple individuals to work on them independently.
DOM variables change that by providing a rich interface between the people working on the business
logic (who are concerned with generating the data values for the portfolio) and the designers working
on the presentation logic (who are focussed on giving the portfolio a compelling look and feel). As
long as the two groups can share a common structure that represents the portfolio, and they each
have ways to access it, then the business logic programmers can create arbitrarily complex logic to
build the tree without affecting how the presentation logic programmers decide to present that tree to
the user. XML and the DOM variables are ideal for this purpose because the plain-text, selfdescribing
nature of XML and the familiar tag structure of DOM variables is easy for both logic
programmers and HTML presentation designers to understand.
Web EDI in a hurry
Another reason to use DOM variables is to create Witango solutions that interact with remote processes
and systems using XML. If you are familiar with EDI (Electronic Data Interchange), XML is fast
becoming the EDI of the Web, and many business systems are using this flexible data format for all
types of data interchange. DOM variables work seamlessly with XML, because (a) XML is used to
create them, and (b) DOM variables can be streamed out as XML by merely referencing them in your
HTML.
To truly appreciate the power of this abstraction, let�s say that your electronic trading system
interfaces to a backend system that processes trades, and that backend supports an XML trade
"document":
<trade>
<buy>
<ticker>PVSW</ticker>
<exchange>NASDAQ</exchange>
<limit>20</limit>
<quantity>1000</quantity>
</buy>
<sell>
<ticker>ORCL</ticker>
<exchange>NASDAQ</exchange>
<quantity>1000</quantity>
</sell>
</trade>
By holding this trade in a DOM variable, you can create a front end that allows the user to manipulate
the trades arbitrarily before actually committing them. The DOM variable can be used to store the bits
and pieces of the trades while they are being constructed, which is considerably simpler than, say,
saving the intermediate trade information in regular text variables or a database. Once the trade is
constructed to the user�s satisfaction, placing the trade then merely involves streaming the DOM
variable to the backend process.
So, how do they work?
For all of their power, using DOM variables is quite simple. The <@DOMINSERT>, <@DOMREPLACE>
and <@DOMDELETE> tags take care of the creation, modification and deletion of the variables. Note
5
that inserting, or replacing, structural elements is done using XML (and that is why they are referred to
as "DOM" variables � they take their name from the W3C XML API for accessing structured
documents, which may be found at http://www.w3.org/TR/REC-DOM-Level-1/). So, for example:
<@DOMINSERT OBJECT=foo>
<portfolio>
<stocks />
<bonds />
<cash />
</portfolio>
</@DOMINSERT>
would create a new variable, "foo," that was a bare-bones portfolio structure with no stocks, bonds or
cash (the "<name />" convention of XML indicating empty tags that contain no data).
Of course, you can also insert XML into an existing structure, or you can replace elements with other
elements. To do either of those operations, you need to be able to refer to elements in a unique way.
Witango uses the XPointer syntax (http://www.w3.org/TR/WD-xptr/) to reference elements in the
tree. This syntax is an English-like recipe for navigating from the root element down to a particular
element, and can be used to affect how <@DOMINSERT>, <@DOMREPLACE> and <@DOMDELETE>
modify an existing DOM structure. [At the time of this writing, the XPointer syntax is the only way to
refer to elements. By the time Witango ships, the syntax used by XSL (http://www.w3.org/TR/WDxslt)
may also be supported in addition to, or in place of, XPointer.]
If you just want to access the information in a DOM variable (in presentation logic, for example), then
you use the element access tags that are provided:
_ <@ELEMENTNAME>, to get the name of a particular element or elements,
_ <@ELEMENTVALUE>, to get the content of a particular element or elements,
_ <@ELEMENTATTRIBUTE>, to get value of a named attribute of a particular element or elements,
_ <@ELEMENTATTRIBUTES>, to get an array of attribute values of a particular element or
elements.
Again, element references are made using the XPointer syntax. Since the syntax for selecting
elements may select a single element, or multiple ones, these tags can return scalar values or arrays.
Of course, these return values can be further manipulated using other Witango tags. If a tag returns an
array, then the values may be iterated over using the familiar <@ROWS> tag. A nice trick to know is
that, when using <@ELEMENTATTRIBUTES>, the columns of the array are the attribute values which
can be accessed by name:
<@ASSIGN attribs VALUE=<@ELEMENTATTRIBUTES OBJECT=portfolio
ELEMENT="root().descendant(1,stockposition)">>
<@VAR attribs["ID"]>
The above example shows how to retrieve the ticker symbol for the first "stockposition" element in the
"portfolio" tree described at the beginning of this article. The result of the <@VAR> should be "PVSW",
the data content of that element. Another useful thing to know is that the Witango <@VAR> tag now
supports an ELEMENT attribute that will allow you to select elements from a DOM variable, usually to
assign them to another DOM variable:
<@ASSIGN justCash VALUE=<@VAR portfolio ELEMENT="child(1,cash)">>
Streaming DOM variables as XML is trivially simple: just reference them with <@VAR> (or @@) in your
HTML and Witango looks after the rest. In some cases, you may need to specify the TYPE=TEXT
attribute to <@VAR> to ensure that text conversion always occurs (as in the example above, if
"justCash" was intended to be XML text instead of a new DOM variable).
Conclusions
This article has provided an altogether too brief introduction to DOM variables in Witango.
While relatively easy to use, DOM variables provide a powerful abstraction (based around an industry
standard, XML) that should make writing many complex applications considerably easier. By providing
a data type that is considerably richer than simple scalars or arrays, productivity on large projects
should be substantially increased as the division between business and presentation logic is
simplified.
And, since XML forms the foundation on which these variables are built, entirely new classes of EDIlike
applications can be easily constructed, allowing Witango developers to ride the wave of this
emerging, but very high profile, Web technology.
Sidebar � What is XML?
XML is conceptually simple, a way of inserting descriptive markup into data to describe a tree
structure with arbitrary linkages. Most data can be modeled using such markup. XML is humanreadable
text which passes optimally through IP networks and firewalls. XML files are self-describing
and self-contained, but a descriptive schema called a Document Type Declaration (DTD) can be
included or externalized optionally. The DTD can be used by tools such as parsers or applications to
validate data or to constrain operations on the data in such applications as syntax directed editors.
Any computer that supports an HTTP client browser or an HTTP server likely already has an XML
parser included which presents a standard Java or COM object interface as an API to the parsed data
(Microsoft�s Internet Explorer 5, for example). This standard API to parsed XML is called the
Document Object Model or DOM. Expressing data in XML allows re-use of a single universally
available parser and a familiar API for many different types of data.
XML is used to describe data. A constellation of related standards are emerging from the World Wide
Web Consortium (W3) to allow further processing of data in XML format. For instance, the XML Style
Language (XSL) is used to transform XML documents into different forms, particularly into
presentation formats. XPointer (XPtr) provides a standard syntax for addressing nodes in an XML
data tree. For more information on these, and other XML-related standards, see
http://www.w3.org/XML/
, http://www.xml.com/, or Robin Cover�s excellent survey at http://www.oasisopen.org/cover/
.----- Original Message -----
From: "Dan Stein" <
[EMAIL PROTECTED]>To: "Multiple recipients of list witango-talk" <
[EMAIL PROTECTED]>Sent: Friday, November 15, 2002 3:44 AM
Subject: Witango-Talk: XML Books and witango
> Looking for suggestions for books that might help my understanding
of XML
> and expanding WiTango.
>
>
> --
> Dan
Stein
> Digital Software Solutions
> 799 Evergreen Circle
>
Telford PA 18969
> Land: 215-799-0192
> Mobile: 610-256-2843
>
Fax 413-410-9682
> FMP, WiTango, EDI,SQL 2000
>
> www.dss-db.com
>
>
> ________________________________________________________________________
> TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
> with unsubscribe witango-talk in the message body
