xml-xsp-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Sergeant <m...@sergeant.org>
Subject Proposal: Attribute value interpolation
Date Wed, 09 Jul 2003 22:16:59 GMT
Hi core XSP developers...

This is a proposal to support attribute value interpolation (called 
"attribute value templates" in XSLT) in XSP. We have an implementation 
of this in AxKit now, and it really makes a huge difference in code 
size in place of using <xsp:attribute> all over the place in order to 
get dynamic attribute values.

Basically it works like this:

<xsp:page>
   <page>
     <xsp:logic>
       my $tomorrow = localtime(time + 86400);
     </xsp:logic>
     <foo bar="{$tomorrow}"/>
   </page>
</xsp:page>

Here the output is something like:

   <page>
     <foo bar="Thu Jul 10 23:11:35 2003"/>
   </page>

If you need a curly bracket inside you have to escape it. This is a bit 
of a pain for Java and Perl - being curly bracket based languages, but 
it's that way to be similar to XSLT:

   <foo bar="{$a->{{dir}}}/{$a->{{file}}}"/>

Which is equivalent to the regular XSP:

   <foo>
     <xsp:attribute name="bar">
     <xsp:expr>$a->{dir}</xsp:expr>/<xsp:expr>$a->{file}</xsp:expr>
     </xsp:attribute>
   </foo>

(there you can really see the verbosity in play!)

Finally, this is so useful we're going to make this the default 
behaviour in the next release of AxKit, but you can turn it off on a 
page-by-page basis with the top level <xsp:page> attribute:

   <xsp:page attribute-value-interpolation="no">

We'd like to consider making this a part of the spec, as if not, it'll 
be an AxKit-only extension.

Matt.


Mime
View raw message