[Home] [By Thread] [By Date] [Recent Entries]


On Sat, 2002-03-02 at 10:22, Niels Peter Strandberg wrote:
> I want XML in Java! 

While poking around on some other projects this morning, I found:
http://java.sun.com/j2se/1.4/docs/api/java/beans/XMLEncoder.html

It seems to be running the opposite direction from what Niels wants, but
it's interesting in its own way.  I'm not used to seeing "void" in
markup.

-------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.0" class="java.beans.XMLDecoder">
<object class="javax.swing.JFrame">
<void property="name">
<string>frame1</string>
</void>
<void property="bounds">
<object class="java.awt.Rectangle">
<int>0</int>
<int>0</int>
<int>200</int>
<int>200</int>
</object>
</void>
<void property="contentPane">
<void method="add">
<object class="javax.swing.JButton">
<void property="label">
<string>Hello</string>
</void>
</object>
</void>
</void>
<void property="visible">
<boolean>true</boolean>
</void>
</object>
</java>

 The XML syntax uses the following conventions:

    * Each element represents a method call.
    * The "object" tag denotes an expression whose value is to be used
as the argument to the enclosing element.
    * The "void" tag denotes a statement which will be executed, but
whose result will not be used as an argument to the enclosing method.
    * Elements which contain elements use those elements as arguments,
unless they have the tag: "void".
    * The name of the method is denoted by the "method" attribute.
    * XML's standard "id" and "idref" attributes are used to make
references to previous expressions - so as to deal with circularities in
the object graph.
    * The "class" attribute is used to specify the target of a static
method or constructor explicitly; its value being the fully qualified
name of the class.
    * Elements with the "void" tag are executed using the outer context
as the target if no target is defined by a "class" attribute.
    * Java's String class is treated specially and is written
<string>Hello, world</string> where the characters of the string are
converted to bytes using the UTF-8 character encoding.

-----------------------
 
-- 
Simon St.Laurent
Ring around the content, a pocket full of brackets
Errors, errors, all fall down!
http://simonstl.com


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member