Don't you need an XML Virtual Machine ?

P

Philippe Poulard

Hi Oliver,

Oliver said:
I don't know about the others, but you can also run PHP from the
command line. Also, from my understanding, RefleX programs always emit
XML documents as output. Is this correct? If not, you may wish to update
the tutorial (or "Hello World" example) on your site to clarify this.

RefleX can emit zero or several XML documents as output
</groupOfFeatures>

I've grouped the above features together because, to me, they are
abstract, hard to understand, and it's not clear to me why they would
help me write programs faster. I think you should provide a concrete
scenario that a programmer might find themselves in, and then show what
they might do if they were using Java (if posting to a Java group;
replace with some other language if posting to a different group), and
then compare what they would do in RefleX, to show why RefleX is better.

For example, when you write "Try to define a schema language with any
of them", I think "Gee, when was the last time I was coding this Java
application, and I *really* wished I could define my own schema
language?" and the answer seems to be very rarely. So when I read about
this "feature" in RelaX,
^^^^^ it's RefleX, RelaX is something else ;)

I'm thinking "It looks like this product solves
a problem that I don't have".

XML is good for designing a language that can achieve specific tasks ;
if you do it declaratively, you will be able to express big complex
ideas very concisely ; there are lots of examples in this world today,
for example a web.xml deployment descriptor is such a language, an XML
catalog language is another, and W3C XML Schema yet another.
But all declarative grammar has its intrinsic limits ; it is still
possible to add a new tag, but you just go a little step further, the
limit is not so far, and sooner or later, reached.
Each tag is like a component that uses sub-tags, that is to say a
sub-component ; an XML document is just a hard-coded description of the
way one need to plug the components.
With Active Tags, you have means to design powerfull declarative
dialects that can be mixed with imperative instructions ; this is very
usefull to use a simple if-then-else statement just to switch from one
component to another. Then the components assembly becomes dynamic.
That's also why it's called *Active* Tags.

It's certainly difficult to understand, that's why I demonstrate all
that stuff with a declarative language that people should easily
understand : a schema language.
Example.
"My <foo> element is a sequence of <bar> then <foo>, optional"
To define this content model, the following declaration may be used :
<element name="foo">
<sequence>
<element ref="bar">
<element ref="foo" minOccurs="0">
</sequence>
</element>
....which is something that you can design in W3C XML Schema or Relax NG
(the syntaxic questions are ignored here).
Both are declarative languages design to express constraints on XML
documents. Now, if in fact my constraints are :
"My <foo> element is a sequence of <bar> then <foo> (optional) except if
the age of the captain is greater than 22, then the sequence is <FOO>
then <BAR> (optional)", you can write it like this :
<element name="foo">
<if test="$age-of-the-captain > 22">
<then>
<sequence>
<element ref="bar">
<element ref="foo" minOccurs="0">
</sequence>
</then>
<else>
<sequence>
<element ref="FOO">
<element ref="BAR" minOccurs="0">
</sequence>
</else>
</if>
</element>
But you can't do it with W3C XML Schema neither Relax NG, you can do it
with the Active Schema Language

at runtime, the content model will be resolved to this one :
<element name="foo">
<sequence>
<element ref="bar">
<element ref="foo" minOccurs="0">
</sequence>
</element>

or this one :
<element name="foo">
<sequence>
<element ref="FOO">
<element ref="BAR" minOccurs="0">
</sequence>
</element>
and each time the conditional branch is reached, it will be evaluated to
a possible different content model

Now, consider that your problem is not to design a schema language, but
to design a software where different parts can be assembled according to
a configuration file ; you may think that XML is suitable for this
purpose, like other people think it was for a web.xml deployment
descriptor, an XML catalog language, and the W3C XML Schema language.
The paradigm of the hard-coded XML file will apply to your application :
one day, you'll find that on a given branch in the XML configuration
file, you would like to use a simple if-then-else statement to select a
component or another.

So, when I ask : is it possible to design a schema language, I'm sure
it's not your need, but it demonstrates that :
-a declarative grammar can be considered with Active Tags, whereas the
other competitors are not design for this purpose
-you can implement it in the dynamic way
This is a great strength in Active Tags.

Thus, if you have to expose your Java code as tags, do it as active
tags, it's worth to use RefleX.
BTW, I'm not trying to be argumentative for the sake of arguing;
rather, I'm just trying to point out why the features of RelaX,
RefleX ;)

as they
have been presented so far, might not be so appealing. I'm doing this
because if RelaX actually does turn out to be a decent time-saving tool,
I'd like to know about it. So I'm trying to give you a chance to
illustrate all the strengths of RelaX.



This is somewhat a weak argument, because we might suspect you of
just being a sloppy Java programmer. The example you posted in another
branch of this thread (recursively list all text files in a subdirectory
which is not in /WEBINF/) was a very good one, as it does seem shorter
in Active Tags than in Java. You should stick to concrete examples like
these whenever possible.

There are some here :
http://disc.inria.fr/perso/philippe.poulard/xml/active-tags/active-tags/active-tags.html#N40041D
Certainly more suitable for a step by step understanding than using the
tutorials.
Okay, this sounds handy. I saw you gave an "XML-like" view of the OS
file system. What other kind of objects can you provide an XML-like view
of?

I don't think that *all* objects have to be accessible with XPath, it
would be somewhat useless although easily possible with introspection.

I prefer to focus on those that are really usefull ; for example, I find
convenient for an HTTP response to expose some of its properties as XML
attributes.
However, there are no restriction on which object have to be and which
mustn't be XML-friendly. Design it like you want (there is an interface
for this purpose).
This claim is also weak, after having looked at your sample code. I'm
fairly comfortable with Computer Science, XML and XPath, but I had a lot
of difficulty understanding the code posted on your site. It actually
looks like there's some other language embedded within the attributes
and contents of the XML, and THAT'S the programming language in which
the behaviour of the application is encoded, rather than in the XML itself.

For example, when you have a node like:

<rdbms:connect name="db" url="{ string(
$web:application/@web:init-param/@db-url ) }"/>

I'm wondering how many of those are keywords that I have to memorize,
and how many of them are names that were defined elsewhere (perhaps in
some external/included file?). Your tutorial needs a lot of work in this
direction. Right now it's almost "copy and paste these programs, and
you'll see these results", rather than "here's the structure of an
ActivePage program, and here's what all the instructions do".

There are comments in the code, and links below the code ; if you read
the tutorial step by step, there is a link and an explanation for each
new item <rdbms:connect>, $web:application etc. If you don't find any,
it is because it was done before, or because I miss it :(

Moreover, there is a link to the material reference at the top of the
tutorial, which will lead you here :
http://disc.inria.fr/perso/philippe.poulard/xml/active-tags/_/references.html
This might be best for someone transitioning from Java to RefleX. Can
you show some concrete examples of these as well? Maybe given an example
scenario of where a Java programmer can write, say, 99% of his or her
application in Java, but then use a bit of RefleX to handle the cases
where RefleX excels at?

I will think about it, but making tutorials and how-to is
time-consuming, and I do my best !

For the moment, there is only the "how-to" section :
http://reflex.gforge.inria.fr/how-to.html

If you really want to try RefleX with your own Java app, please let me
know, I'll try to help you ;)

The AspectJ tutorials that are out there take a
similar approach: They show how a cautious Java programmer can "test the
waters" with AspectJ, before diving in completely.

- Oliver

Thanks for your comments.

--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top