Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - [xsl] Help with creating Task child of Task [Thread Next] Re: [xsl] Help with creating Task child of TaskTo: 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...>
--~--
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
