RE: Alternative for XML
- Posted by Tommy Carlier <tommy.carlier at pandora.be> Oct 20, 2003
- 482 views
Derek Parnell wrote: > I realize that things can be seen in multiple ways, and I can see that > you are expressing the hierarchical nature of the form here, but I can > see that there will be discussions about 'is such-and-such an "element" > or an "attribute"?' Maybe you need to give us a guide as to what the > differences between elements and attributes are? > > Also, I really think that numeric values can be expressed as such and > not as strings. Also, as attributes are delimited by a comma, only > strings that contain commas need to have quotes. Another issue is how > can we express nested data in attributes? I suggest that instead of > quotes, we use the braces characters. > > <smel version='1.0'> > form > { > /* First we encode the attributes of 'form' */ > control(type=Window, > caption={Hello, World!}, > at={12,10}, > size={300,300}, > flags={WS_VISIBLE,WS_DLGFRAME}) > /* And now the elements in 'form' */ > { > /* the child-controls can be defined in the body of the parent-control > */ > control(type=EditText, > name=UserId, > left=5, top=5, > width=20ch); /* 20ch = 20 chars: unit as part of the value */ > control(type=Button, > caption=Close, > flags=autoclose, > left=UserId+2, > bottom=5); > } > } > -- > Derek The current version of SMEL is inspired on XML and behaves a lot like XML. That means: "attribute values are always string and need quotes." In your code I can see sequences as attribute values. This is an extremely nice feature. However, to implement this I'll have to totally redesign SMEL, and rewrite the parser. But, because these features will make SMEL much more powerful, and because SMEL is still just a work-in-progress, I'll just do that: I'll first create a specification for SMEL, I'll throw it on the Internet and wait for reactions and new ideas, and when the specification is kind of solid, I'll begin to make a new parser. The difference between elements and attributes? Elements can be compared to objects, and attributes are the properties of an object. Or, when you know object-oriented programming, elements are classes and attributes are class members/properties. Example: apple(color="green", taste="sweet"); Example: form(name="Form1", width="300", height="200", text="Form 1"); You could also use child-elements instead of attributes: apple { color { "green" } taste { "sweet" } } form { name { "Form1" }, width { "300" }, height { "200" }, text { "Form 1" } } But I think this is a bad design. Nested data in attributes? In the current version of SMEL, this isn't possible. This is just because SMEL is inspired by XML, and XML also doesn't allow nested data in attributes. I'm starting a new website (tommy online), with Euphoria-stuff and a SMEL-section. Because I've just started, very little pages are online and a lot of links don't work yet. You can find 'tommy online' at http://users.pandora.be/tommycarlier