This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: HTML within an element
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] HTML within an element
- From: David Carlisle <davidc at nag dot co dot uk>
- Date: Mon, 23 Jul 2001 17:58:32 +0100
- References: <20010723163251.87529.qmail@web9801.mail.yahoo.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
This isn't an XSL question
External DTD declaration:
<!ELEMENT SubSectionText (#PCDATA)>
so SubSectionText can only have text (not elements)
which means that your input
<SectionText>Conduct basic and applied research to
support human
exploration of <em>space</em>
is not valid. However XSL does not require valid input, mearly well
formed, so you are OK so long as you use a non-validating parser.
<xsl:template match="SectionText">
<xsl:if test="string-length(text()) >
0"><p><xsl:copy-of select="text()" /></p></xsl:if>
</xsl:template>
That is legal but not what you want to do, it just selects the text
nodes which are children of SectionText
<SectionText>Conduct basic and applied research to
support human
exploration of <em>space</em> and to take advantage of
the <strong>space environment</strong> as a
laboratory for <a href="test.htm">scientific</a>,
technological, and commercial
research.</SectionText>
there are five text node children of SectionText so the p you generate
is the concatenation of those, namely:
Conduct basic and applied research to
support human
exploration of and to take advantage of
the <strong>space environment as a
laboratory for ,
technological, and commercial
research.
Probably you want
<xsl:template match="SectionText">
<xsl:if test="string(.)">
<p><xsl:copy-of select="."/></p>
</xsl:if>
</xsl:template>
David
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list