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 |
- RE: text() children, (continued)
- Kay Michael - Fri, 17 Dec 1999 10:55:53 -0000
- Pawson, David - Fri, 17 Dec 1999 13:27:35 -0000
- Pawson, David - Fri, 17 Dec 1999 14:58:31 -0000
- Steve Tinney - Fri, 17 Dec 1999 18:35:15 -0500
- David Carlisle - Mon, 20 Dec 1999 16:15:52 GMT <=
- Kay Michael - Fri, 17 Dec 1999 17:13:06 -0000
- Pawson, David - Mon, 20 Dec 1999 08:56:41 -0000
- Pawson, David - Tue, 21 Dec 1999 07:35:10 -0000
|
|