2 users online. Create an account or sign in to join them.Users
Use exsl to get attribute value template from source xml
This is an open discussion with no replies, filed under XSLT.
Search
Create an account or sign in to comment.
2 users online. Create an account or sign in to join them.Users
This is an open discussion with no replies, filed under XSLT.
Create an account or sign in to comment.
Symphony • Open Source XSLT CMS
--with-xsl)
I had read this oldie-but-goodie article a while ago about using xsl to create your own template language, but I'm just getting around to implementing it. Using exslt, this idea is even easier. Here is how to process attribute value templates you've put in your source xml using the evaulate() function.
So source xml element like this:
<html class='{$current-page}'> <!-- insert awesome --> </html>will output as
First, be sure to add the appropriate @s in your xsl stylesheet/transform element:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dyn="http://exslt.org/dynamic" extension-element-prefixes="dyn">Then you can create a catch-all template match on attributes:
<xsl:template match ="@*[starts-with(., '{$')]"> <xsl:param name='value' select="dyn:evaluate(substring-before(substring-after(., '{'), '}'))" /> <xsl:attribute name='{local-name()}'> <xsl:value-of select="$value" /> </xsl:attribute> </xsl:template>Keep in mind this will be checking all your attributes, so I guess it would be more efficient to add another xpath predicate to specify a namespace or other context.