Apache-ASP

 view release on metacpan or  search on metacpan

site/xml.html  view on Meta::CPAN


		</tr>
		
		<tr>
		<td bgcolor=white><font size=-2 face="verdana" color=#993399><b><nobr>&nbsp;</nobr></b></font></td>

		<td bgcolor=white ><font face="verdana,helvetica" size=-1><b><nobr><a href="todo.html" style="text-decoration:none"><font color=#063678>TODO</font></a></nobr></b></font></td>		

		</tr>
		
		<tr>
		<td bgcolor=white><font size=-2 face="verdana" color=#993399><b><nobr>&nbsp;</nobr></b></font></td>

		<td bgcolor=white ><font face="verdana,helvetica" size=-1><b><nobr><a href="changes.html" style="text-decoration:none"><font color=#063678>CHANGES</font></a></nobr></b></font></td>		

		</tr>
		
		<tr>
		<td bgcolor=white><font size=-2 face="verdana" color=#993399><b><nobr>&nbsp;</nobr></b></font></td>

		<td bgcolor=white ><font face="verdana,helvetica" size=-1><b><nobr><a href="license.html" style="text-decoration:none"><font color=#063678>LICENSE</font></a></nobr></b></font></td>		

		</tr>
		<tr><td colspan=2><hr size=1></td></tr>
		<tr>
		<td bgcolor=white><font size=-2 face="verdana" color=#993399><b><nobr>&nbsp;</nobr></b></font></td>

		<td bgcolor=white ><font face="verdana,helvetica" size=-1><b><nobr><a href="eg/index.html" style="text-decoration:none"><font color=#063678>EXAMPLES</font></a></nobr></b></font></td>		

		</tr>
		
	</table>

	</td></tr>
	</table>

		<br>
		<center>
		<a href=http://www.apache-asp.org/><img src="powered_by_apache_asp.jpg" width="88" height="31" alt="Powered by Apache::ASP" border="0"></a>
		<br>
		<a href=http://perl.apache.org><img src="powered_by_modperl.gif" width="88" height="31" alt="Powered by ModPerl and Apache" border="0"></a>
		<br>
		<a href=http://www.perl.com><img src="rectangle_power_perl.gif" width="88" height="31" alt="Powered by Perl" border="0"></a>


</center>

</td>



<td valign=top bgcolor=white>
<font size=+0 face=verdana,arial>

<font face=verdana><font class=title size=+1 color=#555555><b>XML/XSLT</b></font>
</font>

	<hr size=1>
	<table width=100% border=0 cellpadding=1 cellspacing=3>
	<tr>
	<td valign=top><font face="lucida console" size=-1>
	
		<tr>
		
			<td valign=top >
			<font face="lucida console" size=-1>
			<a href=#Custom%20Tags%20343d11d8>Custom Tags with XMLSubsMatch</a>
			</font>
			</td>
		
			<td valign=top >
			<font face="lucida console" size=-1>
			<a href=#References>References</a>
			</font>
			</td>
							
		</tr>
		
		<tr>
		
			<td valign=top >
			<font face="lucida console" size=-1>
			<a href=#XSLT%20Tranfor41f72a4d>XSLT Tranformations</a>
			</font>
			</td>
		<td>&nbsp;</td>					
		</tr>
			
	</table>
	<hr size=1>
	<p>

	<p>
	<a name=Custom%20Tags%20343d11d8></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>Custom Tags with XMLSubsMatch</b></font>
<font face="courier new" size=3><pre>
</pre></font>Before XML, there was the need to make HTML markup smarter.
Apache::ASP gives you the ability to have a perl
subroutine handle the execution of any predefined tag,
taking the tag descriptors, and the text contained between,
as arguments of the subroutine.  This custom tag
technology can be used to extend a web developer&#39;s abilities
to add dynamic pieces without having to visibly use 
&lt;% %&gt; style code entries.
<font face="courier new" size=3><pre>
</pre></font>So, lets say that you have a table that 
you want to insert for an employee with contact 
info and the like, you could set up a tag like:
<font face="courier new" size=3><pre>
 &lt;my:new-employee name=&quot;Jane&quot; last=&quot;Doe&quot; phone=&quot;555-2222&quot;&gt;
   Jane Doe has been here since 1998.
 &lt;/my:new-employee&gt;
</pre></font>To render it with a custom tag, you would tell 
the Apache::ASP parser to render the tag with a 
subroutine:
<font face="courier new" size=3><pre>
  PerlSetVar XMLSubsMatch my:new-employee
</pre></font>Any colons, &#39;:&#39;, in the XML custom tag will turn
into &#39;::&#39;, a perl package separator, so the my:employee
tag would translate to the my::employee subroutine, or the 
employee subroutine in the my package.  Any dash &quot;-&quot; will 
also be translated to an underscore &quot;_&quot;, as dash is not valid
in the names of perl subroutines.
<font face="courier new" size=3><pre>
</pre></font>Then you would create the my::employee subroutine in the my 
perl package or whereever like so:
<font face="courier new" size=3><pre>
  package my;
  sub new_employee {
    my($attributes, $body) = @_;
    $main::Response-&gt;Include(&#39;new_employee.inc&#39;, $attributes, $body);
  }
  1;

  &lt;!-- # new_employee.inc file somewhere else, maybe in Global directory --&gt;
  &lt;% my($attributes, $body) = @_; %&gt;
  <table>
  &lt;% for('name', 'last', 'phone') { %&gt;
    <tr>
      <td><b>&lt;%=ucfirst $_ %&gt;</b>:</td>
      <td>&lt;%= $attributes->{$_} %&gt;</td>
    </tr>



( run in 0.633 second using v1.01-cache-2.11-cpan-39bf76dae61 )