|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Getting variable yet most immediate parentNode
David Carlisle wrote:
me>(@value,@name,.)[1] And I always found XSLT 1.0 too verbose... this is nice and compact David! But when this list of options gets longer, it might be better to add normal template matching and make the precedence explicit: <xsl:apply-templates select="." mode="option-value" /> ....... <xsl:template match="option[@highervalue]" mode="option-value" priority="20"> <xsl:value-of select="@highervalue" /> </xsl:template> <xsl:template match="option[@value]" mode="option-value" priority="10"> <xsl:value-of select="@value" /> </xsl:template> <xsl:template match="option[@name]" mode="option-value" > <xsl:value-of select="@name" /> </xsl:template> <xsl:template match="option" mode="option-value"> <xsl:value-of select="." /> </xsl:template> The last two do not need a priority (generic match always has lower priority over a match with a predicate). Though this is by far more verbose then David statement, when you plan to add more and more xsl:if statements it will get messy (as you can see in your original post), using template matching you can keep the structure easy (i.e., not too nested) and you can focus on the rules instead of all possible scenarios. The scenarios are then automatically taken and chosen by the processor. The nice thing, also, is how easy and clear it gets now for applying different styles (colors, fonts) to each of the options. Cheers, -- Abel Braaksma
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Cast Your Vote
We need your help – Vote for DataDirect XML Products!
Winners and finalists announced at SOA World Conference in November. 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
|







