Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^5: aXML vs TT2

by ikegami (Pope)
on Oct 21, 2011 at 21:13 UTC ( #932981=note: print w/replies, xml ) Need Help??

in reply to Re^4: aXML vs TT2
in thread aXML vs TT2

Ok then, we add a new sub called something like <no_parse>

That wouldn't work.

Oh and regarding shortend tags like <inc name="header"/>

It wasn't shortened. It's actually three characters longer. It just seems clearer to me for inc

however supporting those sort of tags as well as the standard ones

I wasn't suggesting that you handle both <inc>header</inc> and <inc name="header"/>, just one of them. Supporting both would be confusing.

Replies are listed 'Best First'.
Re^6: aXML vs TT2
by Logicus on Oct 21, 2011 at 23:52 UTC

    >That wouldn't work

    But it does work, I've used this technique before and will be implementing it on the new parser when I get round to it.

    Perhaps you had some other case in mind which is different to what I'm thinking?

    About the tags, your right giving both standards would be confusing (and processor costly) so I'm only going to be supporting the regular tag types on my version. If anyone using it wants to change it to do both that's entirely upto them.

      It doesn't work because it can't be used in practice. It renders all "d" inert, not just the ones that aren't aXml directives. It can't be used with your very own example, for one. db_select and d doesn't work in the following:

      <inc title="User Info">header</inc> <no_parse> <table border=0 width="100%"> <tr> <th>User ID</th> <th>Name</th> <th>Email</th> </tr> <db_select> <query> SELECT * FROM user ORDER BY id </query> <mask> <tr> <td><d>id</d></td> <td>[hlink action="user_profile" user_id="<d>id</d>"]<d>name</d> +[/hlink]</td> <td><d>email</d></td> </tr> </mask> </db_select> </table> </no_parse> <inc>footer</inc>

      About the tags, your right giving both standards would be confusing (and processor costly) so I'm only going to be supporting the regular tag types on my version. If anyone using it wants to change it to do both that's entirely upto them.

      What are you talking about? I'm talking about using an attribute instead of a text node for inc, but you keep using plural... Wait, are you saying that aXml requires you to write

      <foo bar="moo"></foo>
      instead of
      <foo bar="moo"/>

      wtf! And because you think it would be less costly to process a whole additional tag? double wtf!

        Ok,first off, <d> is not an aXML tag, it's merely markup used by the <db_select> tag. If you attempted to introduce a separate plugin called "d", you would get errors if you didn't use the precedence operators correctly. Having said that there are plenty of ways of putting bad data into any given parser/compiler and causing errors so that in and of itself is not a valid objection to aXML.

        It is as unreasonable as saying that Perl cannot be any good because you can't call a sub "die" without interfering with the built in function "die". The given set of abstractions which I have built all work together, and can be changed as the programmer wishes, but there is a difference between extending them logically and deliberately causing conflicts between them by giving them names which interfere with each others markup space.

        Secondly, yes the parser as it works right now would require that you write a tag as :

        <foo><bar>moo</bar></foo> or, the preferred; <foo bar="moo"></foo>

        This is a direct consequence of how the parser I have written works rather than any actual necessity of the syntax/language itself.

        A compiler written as Corion suggested would allow for the use of those and of the tag schema your talking about, however as I have already mentioned all attempts I have made to write such a thing have failed miserably and I consider the task "too difficult for me", and more recenly I have come to consider the issue a waste of my time considering the technique is no longer needed for the sake of efficiency thanks to running on top of Plack.

        The current code of the parser is as follows, it is a little rough around the edges at the moment because it is still under development, however it does work and it is fast.

        package aXML::Parser; use Modern::Perl; use aXML::Engine; my ( $aXML,$env,$qd,$session,$cookie,$conf,$dbh,$debug_trace ); sub process { $aXML = $_[0]; $env = $_[1]; $qd = $_[2]; $session = $_[3]; $cookie + = $_[4]; $conf = $_[5]; $dbh = $_[6]; $aXML =~ s@`@<backtick>@g; my $plugins = aXML::Engine::init( $env,$qd,$session,$cookie,$conf,$ +dbh ); $aXML::Engine::scan_more = 1; my $tag_found; while ($aXML::Engine::scan_more) { $aXML::Engine::scan_more = 0; $aXML::Engine::redo = 0; $tag_found = 0; $aXML =~ s@\(([^/\s\)]+)([^\)]*?)\)@ do { if (defined $plugins +->{ $1 }) { $tag_found = 1; +"(`$1$2)" } else { "($1$2)" } } @egs; if ( $tag_found ) { while($aXML =~ s@\(`([^`\s]+)([^`\)]*?)\)([^`]*?)\(/\1\)@ d +o { my $command_args = +aXML::Engine::parse_args( "$1$2" ); my $data = $3; $data =~ s/<null>// +gs; $plugins->{ $comman +d_args->{'tag_name'} }->( $data,$command_args ); } @egs ){} } unless ( $aXML::Engine::redo ) { $tag_found = 0; $aXML =~ s@<([^/\s>]+)([^>]*?)>@ do { if (defined $plugins->{ $1 }) { $tag_found = 1; "<`$1$2>" } else { "<$1$2>" } } @egs; if ( $tag_found ) { while($aXML =~ s@<`([^`\s]+)([^`\>]*?)>([^`]*?)</\1>@ do + { my $command_args = + aXML::Engine::parse_args( "$1$2" ); my $data = $3; $data =~ s/<null>/ +/gs; $plugins->{ $comma +nd_args->{'tag_name'} }->( $data,$command_args ); } @egs ){} } } unless ( $aXML::Engine::redo ) { $tag_found = 0; $aXML =~ s@\[([^/\s\]]+)([^\]]*?)\]@ do { if (defined $plug +ins->{ $1 }) { $tag_found = 1; " +[`$1$2]" } else { "[$1$2]" } } @egs; if ( $tag_found ) { while($aXML =~ s@\[`([^`\s\]]+)([^`\]]*?)\]([^`]*?)\[/\1 +\]@ do { my $command_args + = aXML::Engine::parse_args( "$1$2" ); my $data = $3; $data =~ s/<null +>//gs; $plugins->{ $com +mand_args->{'tag_name'} }->( $data,$command_args ); } @egs ){} } } } $aXML =~ s@`@@gs; $aXML =~ s@<backtick>@`@gs; $aXML =~ s@<null>@@gs; return "$aXML $debug_trace" if $debug_trace; return $aXML; } 1;

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://932981]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2021-10-16 10:59 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (69 votes). Check out past polls.