|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] alternative for modes
Hello all, I'm having a problem with doing something on a more proper way, I hope you help me with this one. Imagine you have a template which can be used on several places in your stylesheet, let's call it 'generalTemplate' <xsl:template name="generalTemplate> do some calculations here, but stay in current node context (so no for-each, ... - see below) <xsl:apply-templates> ... </xsl:apply-templates> </xsl:templates> Imagine this function can be called on a tag <root> and <child> is a child of that tag. So each time when 'generalTemplate' is called, a template which matches the tag 'child' will be called too: <xsl:template match="child"> ... </xsl:template> As I mentioned above, 'generalTemplate' can be called on several places in the template, because everytime I need the same calculations, ... on the 'root'-tag. But each time (in every other place), I actually need different manipulations on the 'child'-tag. A nice way to accomplish would be this, but this doesn't work since mode should be a qname, and not an xpath expression: <xsl:template name="generalTemplate> <xsl:param name="p"/> <xsl:apply-templates mode="$p"> ... </xsl:apply-templates> </xsl:templates> <xsl:template match="child" mode="situation1">...</> <xsl:template match="child" mode="situation2">...</> ... Then I came up with the following: <xsl:template name="generalTemplate> <xsl:param name="p"/> <xsl:apply-templates> <xsl:with-param name="p" select="$p"/> ... </xsl:apply-templates> </xsl:templates> <xsl:template match="child"> <xsl:if test="$p = 'situation1'> ... <xsl:if test="$p = 'situation2'> ... ... </xsl:template> Actually, this works perfect, but I don't like it. So my question is now: are there any other outcomes for this situation, which do this on a more generic way? Thanks for your time, Peter XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|

Cart








