[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] A few odd thoughts on XML and Perl



Note: Although I did a quick scan of the list of XML-related modules
on the CPAN, I may well have missed something relevant (In fact, I'm
almost sure to have done so :-).  So, let me know!


XML is generally presented as an extensible, standardizable, self-
defining data structuring metalanguage (or some such :-).  This is a
useful way to look at it, but there are others.

For instance, one can think of XML as a declarative language.  Like
make (another declarative language), a combination of XML files and
style sheets can be used to specify the processes that must be done
to "publish" a set of documents.

Given that the processing and output format are totally arbitrary
(e.g., screen display, printing, or executable images) and flexible
(e.g., through late binding), this is a powerful interpretation.


Now, let's add in the notion of language pre-processing (e.g., by
some variation on "use" or in the manner of Damian Conway's recent
Latinization of Perl syntax :-).  If mock-Latin can be translated
into Perl code and executed, surely XML can be!

So, assuming we can import XML and interpret it into Perl, what
should the resulting Perl look like?  Given the simplicity of XML
syntax, defining a direct translation should be easy.  Here, for
example, is one possible translation of XML into Perl:

XML:   <foo var="val" ...>arg</foo>

Perl:  XMLoad(type => 'foo', var => "val", arg);

The only problem with this, really, is that Perl is not a declarative
language.  This means that a conversion must take place, somewhere,
to the programming style.  I see two possibilities:

  * Some form of XML-to-XML processing, before the conversion

  * Some way of interpreting declarative functions, in Perl

Peculiarly, neither of these are impossible, given current XML and
Perl technology.

So, could this be an interesting facility to have?  What other mappings
should we consider?

-r
--
Rich Morin:          rdm@cfcl.com, +1 650-873-7841, http://www.cfcl.com/rdm
Prime Time Freeware: info@ptf.com, +1 408-433-9662, http://www.ptf.com
MacPerl: http://www.macperl.com, http://www.ptf.com/ptf/products/MPPE
MkLinux: http://www.mklinux.org, http://www.ptf.com/ptf/products/MKLP

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe