[xsl] Copy Child Elements

Subject: [xsl] Copy Child Elements
From: "Rick Quatro" <frameexpert@xxxxxxxxxxxx>
Date: Fri, 25 Jan 2008 21:50:00 -0500

Here is my input XML:

<?xml version="1.0" encoding="utf-8"?>
<title>Author Job Title</title>
<p id="Field_ShowAuthorJobTitle">Author Job Title</p>
<p id="Desc_ShowAuthorJobTitle">Setting that indicates...</p>
<p id="AppTo_ShowAuthorJobTitle">Review Definitions, Section Item</p>
<p id="Hdr_ShowAuthorJobTitle">Author Settings</p>
<title>Type (of definition)</title>
<p id="Field_Typeofdefinition">Type (of definition)</p>
<p id="Desc_Typeofdefinition">Type of the performance...
<p><b>Focal</b>- A focal review is the most typical type...</p>
<p id="AppTo_Typeofdefinition">Review Definitions, Section Item, Performance Review</p>
<p id="Hdr_Typeofdefinition">Properties</p>

Here is my desired output, except for the problem described below the output.

<?xml version="1.0"?>
<dt>Author Job Title</dt>
<dl>Setting that indicates...</dl>
<dt>Type (of definition)</dt>
<dl>Type of the performance... Focal- A focal review is the most typical type...</dl>

For the <dt> and <dl> elements, I want to include any contents from the original content; for example the <ul> element in the second <section> element, etc.

Here is my stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" />
<xsl:template match="/">
<xsl:apply-templates />

 <xsl:template match="reference">
   <xsl:apply-templates select="//section">
     <xsl:sort select="title" />

 <xsl:template match="section">
   <xsl:for-each select="p[position()&lt;=2]">
     <xsl:if test="position()=1">
         <xsl:apply-templates />
     <xsl:if test="position()=2">
         <xsl:apply-templates />


Any help is appreciated.

Rick Quatro
Carmen Publishing

Current Thread