[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Apply-templates - how to omit top level element ta
Mike,
At 07:32 PM 9/7/2005, you wrote: Also, why is it not possible to be able to output: It is possible. Where the XSL has this: You haven't shown us the template matching "Name". Combined with your template above, this template <xsl:template match="Name"> <xsl:apply-templates/> </xsl:template> will result in FooXXX but this template <xsl:template match="Name"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template> will result in <Name>FooXXX</Name> while <xsl:template match="Name"> <BANG> <xsl:apply-templates/> </BANG> </xsl:template> will result in <BANG>FooXXX</BANG> Why do I have to write a specific template to accomplish this? In the case above I want to output the value contained in <Name> that way only once, but I also want the write of the XML to be able to embed other references into it that I can parse with apply-templates. As near as I can understand it, you are asking the XSLT to do something it does quite naturally. But it's hard to determine what your actual criteria are from this description. Having to create a template for a single case is like having to write a function in Java called Add37(x) simply to add 37 to the variable "x" in only one place in the code. Why can't I just do it inline rather than have to worry about logic in two places and also worry about potential sideaffects or name collisions? Is it because XSL simply doesn't provide such a capability? Again, I'm not sure of the actual problem here. XSLT provides a "for-each" instruction to allow you to avoid writing templates that are only used once, in a single context. But I suspect that's actually a red herring in your case. If the problem isn't yet solved, could we trouble you to repost a demonstration? Cheers, Wendell
|
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
|