[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Help with creating Task child of Task
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. ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx 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 ======================================================================
|
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
|