Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl:if test=

Status
Not open for further replies.

hawley

Programmer
Dec 16, 2002
37
US
I have just gotten thrown into html, xml and xsl code so please ignore my basic knowledge. I have a content management system that creates html, xml and xsl code.

It is a tool where a user will enter data into fields and then an html page will be created. When they enter data and enter nothing in the body field I get

<div xmlns:st1="urn: xmlns:eek:="urn: class="rxbodyfield" xmlns:x="urn: xmlns:w="urn:<p></p>
</div>

If there enter something in the body field I get

<div xmlns:st1="urn: xmlns:eek:="urn: class="rxbodyfield" xmlns:x="urn: xmlns:w="urn:<p>this is just a test</p>
</div>

On my style sheet I currently have
<!-- start XSL -->
<xsl:eek:utput method="xml" omit-xml-declaration="yes" />
<xsl:variable name="body_txt" select="whitebox/shared/body/node()" />
<!-- end XSL -->
<!-- begin XSL -->
<xsl:if test="$body_txt">
<!-- end XSL -->
<tr>
<td><span psxedit="body" psxshow="psx-shared/body">This section maybe blank.</span><hr></td>
</tr>
<!-- begin XSL -->
</xsl:if>
<!-- end XSL -->

I need to modify it to say if nothing is in the paragraph tag skip putting the body field and divider line on the output html page. How would I do this?

It was originally the way it was because those div tags were not there if there was no text or picture in the body field. If they didn't enter anything in the body field we use to get.
<p></p>
but now because of another issue we get the div tags everytime which now makes our if statement in the xsl always true.

If you need more info of if this is confussing please let me know.
 
You keep mentioning div and p tags, but not a trace in your xsl. In any case, try this.
> <xsl:if test="$body_txt">
[tt] <xsl:if test="not(string-length(normalize-space($body_txt))=0)">[/tt]

 
Thanks for your help but I am a little confused. I am just starting on xsl so I am not sure what you mean by a trace.

I will always have this code in the body text..

<div xmlns:st1="urn: xmlns:eek:="urn: class="rxbodyfield" xmlns:x="urn: xmlns:w="urn:<p></p>
</div>

I am trying to create an if statement to see if anything is in the paragraph tag.

Thanks!
 
You don't seem to notice I gave you an answer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top