plugin produces aXML code,
parser takes that aXML code and produces HTML code,
browser takes that HTML code and produces text.
You've misunderstood the flow.
parser takes aXML code,
parser discovers/executes valid aXML tags
plugins produce either aXML or HTML or mix of both (or other)
parser discovers/executes valid aXML tags
plugins produce either aXML or HTML or mix of both (or other)
....
parser can find no more valid aXML tags
parser exits, post processing occurs
browser takes finished resulting HTML and produces page
Here, I just got finished playing around with a question someone posted about processing some poorly formed HTML given that they don't know (or want to know) anything about regexs.
In aXML I would solve it like this :
(aXMLplugin name="TD")"$_[0]",(/aXMLplugin)
(aXMLplugin name="TR")
<db_write>INSERT INTO captured_rows VALUES
(<chop><strip_tws>$_[0]</strip_tws></chop>);
</db_write>
(/aXMLplugin)
(inc)path/to/htmldata(/inc)
The above primes two new plugins called TR and TD just for this job, then includes the html file specified and processes it adding any information it can correctly identify into a database as it goes.
The states it goes through during processing are:
State1
------
(aXMLplugin name="TD")"$_[0]",(/aXMLplugin)
(aXMLplugin name="TR")
<db_write>INSERT INTO captured_rows VALUES
(<chop><strip_tws>$_[0]</strip_tws></chop>);
</db_write>
(/aXMLplugin)
(inc)path/to/htmldata(/inc)
State2
------
(aXMLplugin name="TR")
<db_write>INSERT INTO captured_rows VALUES
(<chop><strip_tws>$_[0]</strip_tws></chop>);
</db_write>
(/aXMLplugin)
(inc)path/to/htmldata(/inc)
State3
------
(inc)path/to/htmldata(/inc)
State4
------
<TR>
<TD> Channel </TD>
<TD> Call Letters </TD>
<TD> Count </TD>
<TD> Percent </TD>
<TD> Title </TD>
</TR>
...
...
State5
------
<TR>
" Channel ",
" Call Letters ",
" Count ",
" Percent ",
" Title ",
</TR>
...
...
State6
------
<db_write> INSERT INTO captured_rows VALUES (<chop><strip_tws>
" Channel ",
" Call Letters ",
" Percent ",
" Title ",
</strip_tws></chop>);</db_write>
...
...
State7
------
<db_write> INSERT INTO captured_rows VALUES (<chop>
" Channel ",
" Call Letters ",
" Percent ",
" Title ",</chop>);</db_write>
...
...
State8
------
<db_write> INSERT INTO captured_rows VALUES (
" Channel ",
" Call Letters ",
" Percent ",
" Title ");</db_write>
...
...
As I'm sure you can see there are a couple of plugins there that are not in the standard set I sent to you earlier. I think it should be quite obvious to you how they would work and how you would go about adding them to the set.
Except maybe the "(aXMLplugin)" tag, which needs a little more explanation... the data it contains is returned interpolated. So:
(aXMLplugin name="greet")hello world(/aXMLplugin)
Would look like this in the plugin code it produces :
greet => sub {"hello world"},
The fact it's a one liner to be interpolated is taken as being implicit in the way I'm thinking about this plugin at the moment, such that :
(aXMLplugin name="foo")"hello world"(/aXMLplugin)
Would look like this in the code level :
foo => sub {"\"hello world\""},
And give this for output :
"hello world"