[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

Subject: Re: How to avoid applying templates several times to the same descendant
From: Joakim Norlov <jn@xxxxxxxxxxxxxx>
Date: Thu, 10 May 2001 12:28:01 +0900
joakim norlov
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.