By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,426 Members | 1,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,426 IT Pros & Developers. It's quick & easy.

Help with passing xml tags within an xml file

P: n/a
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

Feb 14 '06 #1
Share this Question
Share on Google+
5 Replies

P: n/a
Thierry wrote:
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
--
XML FAQ: http://xml.silmaril.ie/
Feb 15 '06 #2

P: n/a
Peter Flynn wrote:
Thierry wrote:
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.


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....l/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 |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
Feb 15 '06 #3

P: n/a
Philippe Poulard wrote:
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.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Feb 15 '06 #4

P: n/a
Joseph Kesselman wrote:
Philippe Poulard wrote:
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.


This is exactly what I meant
-don't you think that XSLT is itself a kind of programming language ?

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


You said it ;)

No comment about Active Tags ?

--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
Feb 15 '06 #5

P: n/a
Philippe Poulard wrote:
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
--
XML FAQ: http://xml.silmaril.ie/
Feb 15 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.