Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Help with creating Task child of Task

From: Wendell Piez <wapiez@------------.--->
To: xsl-list@-----.------------.---
Date: 1/2/2009 9:50:00 PM
Hi Charles,

Alternatively, do this with modes.

The first time through the document, remove the reference-content by 
matching it with an empty template.

Then, from the template that directs this traversal from the top, 
select the reference-content for processing again, matching it in a 
special-purpose mode to create the new element.

So, something like:

<xsl:template match="task">
   <xsl:copy>
     <xsl:copy-of select="@*"/>
     <!-- going to copy the taskbody -->
     <xsl:apply-templates/>
     <!-- now going to make any reference-content into a new task -->
     <xsl:apply-templates select="taskbody/reference-content" mode="new-task"/>
   </xsl:copy>
</xsl:template>

<xsl:template match="reference-content"/>
<!-- dropping reference-content when we see it inside the old taskbody -->

<xsl:template match="reference-content" mode="new-task">
   <task>
     <title/>
     <taskbody>
       <context>
         <xsl:apply-templates/>
       </context>
     </taskbody>
   </task>
</xsl:template>

... plus the identity template to copy everything else.

Keep in mind that while it may appear that you are "opening" and 
"closing" elements, what you're really doing is grafting stuff onto 
the result tree. Using a second mode gives you a way of saying "don't 
attach it here" in one place and "attach it here" in another place.

Cheers,
Wendell

At 02:00 PM 12/31/2008, you wrote:
>I'm creating an XML to XML transform. Transforming a kluged DITA 
>model into standard DITA. I have to transform something called 
><reference-content> into a <task> child of the root task.
>
>I can easily transform <reference-content> to <task>. Where I'm 
>stuck is making the new task a sibling of the currently containing 
><taskbody>. Currently <reference-content> is a child of <taskbody>. 
>Once <reference-content> is tranformed to <task>, I need to close 
>the containing <taskbody> and make the new <task> a sibling of that <taskbody>.


======================================================================
Wendell Piez                            mailto:wapiez@m...
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent