XSLT FAQ
How to perform an xsl transformation over a layout output?
I would like to perform an XSL transformation over placeholder's content and their inner function calls, how can I do that?
Answer:
Firstly, you should create an xslt function, that accepts an "XElement" argument, you can use the following one, as a template:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:in="http://www.composite.net/ns/transformation/input/1.0" xmlns:x="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xsl in"> <xsl:variable name="root" select="/in:inputs/in:param[@name='XHTML']/x:html"/> <xsl:template match="/"> <xsl:variable name="xhtml" select="/in:inputs/in:param[@name='XHTML']" /> <html> <head> <xsl:copy-of select="$root/x:head"/> </head> <body> <xsl:copy-of select="$root/x:body"/> </body> </html> </xsl:template> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()" /> </xsl:copy> </xsl:template> <!-- Put your transformation templates here --> </xsl:stylesheet>
NOTE: In the example the function has a parameter named "XHTML" with the type of "XElement"
The next step - is to change the layout:
<f:function name="Composite.Example.Layout" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://www.composite.net/ns/function/1.0" xmlns:rendering="http://www.composite.net/ns/rendering/1.0"> <f:param name="XHTML"> <!-- Layout content --> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://www.composite.net/ns/function/1.0" xmlns:lang="http://www.composite.net/ns/localization/1.0" xmlns:rendering="http://www.composite.net/ns/rendering/1.0" xmlns:asp="http://www.composite.net/ns/asp.net/controls"> <head> <!-- ... --> </head> <body> <!-- ... --> </body> </html> </f:param> </f:function>