[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: text() children

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


]
]<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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.