Re: text() children

Subject: Re: text() children
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 20 Dec 1999 16:15:52 GMT


]
]<div>Primary contributions by David Ornstein 
]   <a href="mailto:davido@xxxxxxxxxxxxx";>davido@xxxxxxxxxxxxx</a>
]      and Kai Matthews with scientific review by Dr. Karl M. Johnson. 
]<p>This document provides answers to common questions about Ebola. For
]more information about Ebola </p>
]</div>
]
]
]I want as output
]
]<p>Primary contributions by David Ornstein 
]   <a href="mailto:davido@xxxxxxxxxxxxx";>davido@xxxxxxxxxxxxx</a>
]      and Kai Matthews with scientific review by Dr. Karl M. Johnson. </p>
]<p>This document provides answers to common questions about Ebola. For
]more information about Ebola </p>
]
]The input tree is mixed pcdata and elements.

Is all your pcdata at the start, in which case it's fairly easy.


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0"
                >

<xsl:template match="div">
 <p>
 <xsl:apply-templates select="text()|*[not(self::p)]"/>
 </p>
 <xsl:apply-templates select="p"/>
</xsl:template>


<xsl:template match="*">
 <xsl:copy-of select="."/>
</xsl:template>


</xsl:stylesheet>

produces the above output modulo white space.

If you over simplified your example, and the content of div is
alternating stuff: p elements which you want to copy, and stuff not in p
which you want to wrap, then you do have to work a bit harder.

David


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread