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/