No it wouldn't. Your clutching at straws now.

Lets say you want to output the following XML file;

<artists> <artist> <name>Aerosmith</name> <genre>Rock &amp; Roll</genre> </artist> <artist> <name>Abba</name> <genre>Pop</genre> </artist> </artists>

And you want to generate that using aXML. The code would be :

<artists> <db_select> <query> SELECT * FROM artists</query> <mask> <artist> <name><d>name</d></name> <genre><d>genre</d></genre> </artist> </mask> </db_select> </artists>

Now if the & in the data has been encoded to &amp; prior to being stored in the database then when you pull it out it's ready to go, if on the other hand it's stored in the database as the single char &, then your going to want to convert it (and any other examples in the data) before output.

You can do that by simply creating a plugin called something like <convert_amps>. The code of which will look like:

$plugins->{'convert_amps'} = sub { my $data = $_[1]; $data =~ s@\&@\&amp;@gs; return $data; };

Now you just wrap the above aXML code with the new tag.

<convert_amps> <artists> <db_select> <query> SELECT * FROM artists</query> <mask> <artist> <name><d>name</d></name> <genre><d>genre</d></genre> </artist> </mask> </db_select> </artists> </convert_amps>

Now obviously if the & is encoded in the database your going to end up with &amp;amp;, but then you could just code the plugin to be a bit smarter than the above example, or you could make sure your data is clean to begin with.

Your actually already using something similar to aXML on this very site when you wrap your code in <code> tags!


In reply to Re^16: aXML vs TT2 by Logicus
in thread aXML vs TT2 by Logicus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.