Help with passing xml tags within an xml file

T

Thierry

Let's say I have the following tags in an xml:


<World>
<Country>Canada</Country>
<Hemisphere>North</Hemisphere>
<Weather climate="cold" forecast="snow">
<CommandAction>$(HOME)\calculate.py Canada North
snow</CommandAction>
</Weather>
</World>

The CommandAction tag will invoke some python script which takes
Country Hemisphere and forecast as parameters. Is there a way to
generalize the CommandAction tag so that it can look something like the
following:

<CommandAction>$(HOME)\calculate.py <Country> <Hemisphere>
<forecast></CommandAction>

I'm not very experienced with xml and I would like to know if the above
is a proper way of doing what I want. Any help please?

Thanks
Thierry
 
P

Peter Flynn

Thierry said:
Let's say I have the following tags in an xml:


<World>
<Country>Canada</Country>
<Hemisphere>North</Hemisphere>
<Weather climate="cold" forecast="snow">
<CommandAction>$(HOME)\calculate.py Canada North
snow</CommandAction>
</Weather>
</World>

The CommandAction tag will invoke some python script which takes
Country Hemisphere and forecast as parameters. Is there a way to
generalize the CommandAction tag so that it can look something like the
following:

<CommandAction>$(HOME)\calculate.py <Country> <Hemisphere>
<forecast></CommandAction>

I'm not very experienced with xml and I would like to know if the above
is a proper way of doing what I want. Any help please?

A more manipulable construction might look something like:

<World>
<Country>Canada</Country>
<Hemisphere>North</Hemisphere>
<Weather climate="cold" forecast="snow">
<CommandAction location="home">
<script>calculate.py</script>
<param value="Country"/>
<param value="Hemisphere"/>
<param value="Weather/@forecast"/>
</CommandAction>
</Weather>
</World>

Then you can write some XSLT to create output which some processor
(Python) can execute. XML itself can't run programs, because it is
not itself a programming language.

(In fact, you'd need to write XSLT to write XSLT. The double
indirection is needed because XSLT is not dynamic and cannot re-rig
itself internally during execution to reflect a value it has only
just come across (like the XPath syntax implied in my <param>
elements.)

///Peter
 
P

Philippe Poulard

Peter said:
A more manipulable construction might look something like:

<World>
<Country>Canada</Country>
<Hemisphere>North</Hemisphere>
<Weather climate="cold" forecast="snow">
<CommandAction location="home">
<script>calculate.py</script>
<param value="Country"/>
<param value="Hemisphere"/>
<param value="Weather/@forecast"/>
</CommandAction>
</Weather>
</World>

Then you can write some XSLT to create output which some processor
(Python) can execute. XML itself can't run programs, because it is
not itself a programming language.

XML is used for anything, it can be used like a programming language as well

-don't you think that XSLT is itself a kind of programming language ?
(it reads an input, processes it, and produces an output, even if the
input must be XML)

-I designed myself a general purpose language :)
have a look here :
http://disc.inria.fr/perso/philippe.poulard/xml/active-tags/
and here :
http://reflex.gforge.inria.fr/
(this is the engine that implement all that stuff)

a nice toy ;)
(In fact, you'd need to write XSLT to write XSLT. The double
indirection is needed because XSLT is not dynamic and cannot re-rig
itself internally during execution to reflect a value it has only
just come across (like the XPath syntax implied in my <param>
elements.)

///Peter


--
Cordialement,

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

Joseph Kesselman

Philippe said:
XML is used for anything, it can be used like a programming language as
well

Not exactly. XML itself is pure syntax. You can use that syntax to
express any kind of data, including program stucture. Think of XML as a
toolkit for writing languages.
-don't you think that XSLT is itself a kind of programming language ?

XSLT is very explicitly a nonprocedural rule-based programming language.
 
P

Philippe Poulard

Joseph said:
Not exactly. XML itself is pure syntax. You can use that syntax to
express any kind of data, including program stucture. Think of XML as a
toolkit for writing languages.

This is exactly what I meant
XSLT is very explicitly a nonprocedural rule-based programming language.

You said it ;)

No comment about Active Tags ?

--
Cordialement,

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

Peter Flynn

Philippe said:
Peter Flynn wrote: [...]
XML itself can't run programs, because it is
not itself a programming language.

XML is used for anything, it can be used like a programming language as
well

Read what I wrote. Yes of course XML syntax can be used to represent
programming language constructs -- as you say, XSLT is a programming
language -- but XML *itself* is not a programming language: it's just
a specification for a markup syntax that can be used to identify lots
of different things.

///Peter
 

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,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top