xsl-list
[Top] [All Lists]

RE: How to strip out a pair of <p> tag from xml data befor e puttingout on an html page using XSL?

2004-02-03 08:25:02
Thanks for your reply Charles. Actually, these come in as a formatted html
blurb to me so I just put them out as it is inputed by the user. It may or
may not contain formatting so that was my problem as I can not expect any of
those elements to be always there to build them by hand. Could you elaborate
on your suggestion by hopefully an example? Thanks.

Anoop

-----Original Message-----
From: cknell(_at_)onebox(_dot_)com [mailto:cknell(_at_)onebox(_dot_)com]
Sent: Tuesday, February 03, 2004 10:07 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] How to strip out a pair of <p> tag from xml data
before puttingout on an html page using XSL?


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(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Govil, Anoop (Contractor) 
<Anoop(_dot_)Govil(_at_)usmint(_dot_)treas(_dot_)gov>
Sent:     Tue, 3 Feb 2004 09:43:34 -0500
To:       "'XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com'"
<XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject:  [xsl] 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

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



<Prev in Thread] Current Thread [Next in Thread>
  • RE: How to strip out a pair of <p> tag from xml data befor e puttingout on an html page using XSL?, Govil, Anoop (Contractor) <=