Web app customization - XSLT design and reuse
I have a simple BDBXML/PHP/XSLT web application. XML documents are stored in BDBXML, retrieved via PHP and transformed into HTML using XSLT 1.0 (LibXSLT).
I want the look to be customizable. Many things can be made look different using just CSS. However, I'd like to also reshuffle the HTML, whenever the need arises. There may be things to add or remove or rearrange.
I'm looking for the best strategy to do this. To me, the best strategy means: avoid redundancy, reuse your code, make adaptations with minimum textual changes.
Currently, I have a couple of PHP scripts each of which teams up with an XSLT stylesheet. All of them include common functionality in main.xsl, which contains the skeleton of my page layout.
Then, there are some stylesheets used for formatting data, which work together. I xsl:import fmt1.xsl for basic stuff; for a more complicated layout, I also xsl:import fmt2.xsl; and, for special occasions, also fmt3.xsl.
Now, I may want to serve different versions of my page layout. My idea is that whatever I may wish to override should go into xsl:template in a seperate file that is pulled in using xsl:import, so a later xsl:import on the same level can be used to override the definitions contained therein.
In this scenario, an xsl:template[@match] may have an advantage over xsl:template[@name] as xsl:apply-imports works only for match templates, not for named ones.
Is this the way to go or are there alternatives, maybe more suitable ones? Any comments welcome!
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format