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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with XSLT - counting Number of characters in the previous para 1

Status
Not open for further replies.

noyes99

Programmer
Jun 25, 2002
38
IN
XSLT newbie here. I want to accomplish the following. If paragraph is the second one, and it has less than 200 characters, i want to display the next one.

Here is what I have

<xsl:if test="count(preceding-sibling::p) = 2">
<p>
<xsl:apply-templates />
</p>
</xsl:if>

How do i add the condition for the preceeding para to have less than 200 characters. What would that condition look like?

Any help would be appreciated.

Thanks
 
Try using the string-length function like this:

"string-length(preceding-sibling::p) &lt; 200"


you'll need to "and" it with the statement if you can.

Rgds,

Matt

 
Thanks, this is helpful. Another question, how do I find the length of current paragraph.

ie, what replaces string-length(XXX).

 
so did you figure it out? (the "what replaces string-length(xxx)" question?) or should I try to elloborate?

If you need me to go into it, some more of your code would be good to see what context you are in when the condition executes.

Cheers

Matt

 
Thanks Matt I was able to figure it out. For the records, I needed to use something like

string-length(preceding-sibling::p[1]) &lt; 200

to make sure I was going the the immediately preceeding sibling.

Thanks

-N
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top