[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to avoid applying templates several times to t
I want to start by thanking both Jeni and Jarno for your help. In Jeni's last post, she adviced me to use Jarno's solution instead. But Jarno's solution won't work either in special cases when specific templates have to be applied to descendants of the ATLAS node. To show a special case, I have expanded my example code to this: Remember the specific template for CARE (see earlier post), that adds wrapping tags around the CARE element: <xsl:template match="CARE"> <!-- adding wrap tags --> <CAREWRAP> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </CAREWRAP> </xsl:template> So what if a CARE element would be the parent (or ancestor) of one of the elements with an ATTR attribute? <ATLAS> <CARE> <PAR ATTR="Subject III"> Blabla 1 </CARE> <CARE> Blabla 0 </CARE> </PROC> <PROC ATTR="Subject I"> Blabla 2 </PROC> <PAR ATTR="Subject II"> Blabla 3 </PAR> <PROC> <PAR ATTR="Subject II"> Blabla 4 </PAR> </PROC> </ATLAS> should turn out to be <ATLAS ATTR="Subject III"> <CAREWRAP> <CARE> <PAR ATTR="Subject III"> Blabla 1 </PAR> <CAREWRAP> <CARE> Blabla 0 </CARE> </CAREWRAP> </CARE> </CAREWRAP> <PROC> </PROC> </ATLAS> <ATLAS ATTR="Subject I"> <CAREWRAP> <CARE> <CAREWRAP> <CARE> Blabla 0 </CARE> </CAREWRAP> </CARE> </CAREWRAP> <PROC ATTR="Subject I"> Blabla 2 </PROC> <PROC> </PROC> </ATLAS> <ATLAS ATTR="Subject II"> <CAREWRAP> <CARE> <CAREWRAP> <CARE> Blabla 0 </CARE> </CAREWRAP> </CARE> </CAREWRAP> </PROC> <PAR ATTR="Subject II"> Blabla 3 </PAR> <PROC> <PAR ATTR="Subject II"> Blabla 4 </PAR> </PROC> <PROC> </PROC> </ATLAS> The tags are starting to get a bit messy. Sorry about that. I just want to illustrate the difficulties I'm facing here. Both Jeni's and Jarno's solutions will not work with the specific templates that are needed in my document. In Jeni's case, I would need to add copies of ALL my templates in a "copy" mode. In Jarno's case, I would need to add parameters and parameter passing to ALL my templates to handle the parameter testing. Well, I don't like doing any of this. Is there not any other way? /Joakim Norlov 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
|