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

RE: How to strip out a pair of <p> tag from xml data

Subject: RE: How to strip out a pair of <p> tag from xml data before puttingout on an html page using XSL?
From: cknell@xxxxxxxxxx
Date: Tue, 03 Feb 2004 10:07:12 -0500
strip out
You don't get rid of them by striping them out. You get rid of them by not putting them in. It looks like they are getting in by using xsl:copy-of to take them from the source and put them in the output. Try building these elements by hand.
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Govil, Anoop (Contractor) <Anoop.Govil@xxxxxxxxxxxxxxxx>
Sent:     Tue, 3 Feb 2004 09:43:34 -0500
To:       "'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'" <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Subject:   How to strip out a pair of  <p> tag from xml data before puttingout on an html page using XSL?

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




 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.