[xsl] How to strip out a pair of <p> tag from xml data before putting out on an html page using XSL?

Subject: [xsl] How to strip out a pair of <p> tag from xml data before putting out on an html page using XSL?
From: "Govil, Anoop (Contractor)" <Anoop.Govil@xxxxxxxxxxxxxxxx>
Date: Tue, 3 Feb 2004 09:43:34 -0500
Hello,

I have an interesting problem. I am implementing a FAQ page which lists set
of question and answer and has an index of question on the top (pretty
standard FAQ page). Now, when the data for question and answer is input
through a template, there is a pair of <p> tags around the answer which
throws the content of answer to next line when transformed through XSL. I
will appreciate if someone out there could suggest how I can strip out this
extra pair of p tag befor putting out the content on html (through XSL). My
problem is that the data element that contains <p> tags will also contain
other html formatted text in it like ordered list, etc. as follows:

<p> some data here... </p><p>ordered list here:</p><ul><li><p>Bullet
1.</p></li></ul><p></p>

Now what I need to strip out is the first <p> tag pair so that when I align
the answer (A.) with its content, the content doesn't fall to next line due
to the <p> tag. like shown here:

Q. Question 1?
A.

some data here...

ordered list here:
....

Here is my XML and XSL that I implemented. Any help on fixing this will be
much appreciated. Thanks in advance.

XML :
------

<?xml version="1.0"?>
<PAGE>
	<Page_Instructions/>
	<Page_Title/>
	<Page_Text>Some Text paragraph here.</Page_Text>
	<FAQs>
		<Question>Question 1?</Question>
		<Answer><p>Answer 1</p></Answer>
	</FAQs>
	<FAQs>
		<Question>Question 2?</Question>
		<Answer><p>Answer 2</p></Answer>
	</FAQs>
	<FAQs>
		<Question>Question 3?</Question>
		<Answer>
		<p>
		Answer 3.
		</p>
		<p>
		Descriptive Text:
		</p>
		<ul>
		<li>
		<p>
		Bullet 1.
		</p>
		</li>
		</ul>
		<ul>
		<li>
		<p>
		Bullet 2.
		</p>
		</li>
		</ul>
		</Answer>
	</FAQs>
	<Content_Owner />
	<Content_Owner_Email />
	<Keywords />
</PAGE>

XSL :
-----

<?xml version="1.0"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="html" />

	<xsl:template match="/">
		<HTML>
		<BODY>
			
			<!-- beging list of questions -->
			<p>
				<table>
				   		<xsl:for-each
select="PAGE/FAQs">
							<tr><td><a
href="#{generate-id(Question)}"><span id="questionlist"><strong><xsl:copy-of
select="./Question" /></strong></span></a></td></tr>
						</xsl:for-each>
				</table>
			</p><br/>
			<!-- end list of questions -->

			<!-- begin FAQ question -->

			<xsl:if test="normalize-space(PAGE/FAQs)">
				<xsl:for-each select="PAGE/FAQs">
	    			<a name="#{generate-id(Question)}">
	    			<span id="question">
					<strong>Q. <xsl:value-of
select="./Question" /></strong></span></a><br />
					<!-- begin Answer part -->
					<strong>A. </strong><xsl:copy-of
select="./Answer" />
					<!-- end Answer part -->
					<br/><br/>
				</xsl:for-each>
			</xsl:if>

			<!-- end FAQ question -->

	
		</BODY>
		</HTML>
	</xsl:template>
</xsl:stylesheet>

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


Current Thread