Search
Sunday, September 07, 2008 ..:: Forum ::.. Register  Login
 
  Forum  Templates  Tags & Template...  Counting the number of characters/lines in a tag
Previous Previous
 
Next Next
New Post 5/26/2008 1:08 PM
Resolved
  peteryen
3 posts
No Ranking


Counting the number of characters/lines in a tag 
I wanted to know if there was a way to determine the number of characters or lines inside a specific tag. If this is not possible, maybe someone could offer another solution to the following dilemna: I have a section in this document that prints a large paragraph-style tag. However, if the number of lines causes this tag to spill onto another page, then I need to replace this tag with 'Refer to Schedule A' and append this tag to the very end of the document. Let me know if anyone has any possible workarounds. Thanks, Peter
 
New Post 5/27/2008 2:01 PM
  wwcadmin
1 posts
No Ranking


Re: Counting the number of characters/lines in a tag 

Peter,

This can be done but will require programming on your part.  You will need to write a Java Bean in order to do this.  In our Java Engine installation there is an example that shows how to manipulate text to red or black depending if the text is positive or negative.  It is called the RedBlack Bean Example.  Use this as a guide when writing your own bean.  We have written a bean for a client that does determine the number of characters and if it is too long it changes the font size.  This bean could be modified to do what you are asking which is if the text is too long then replace with a default value of text.  You could then use an IF tag directly following to test if the default text has been placed and then output your long text on the next page if that IF tag evalutates TRUE.

 

Red Black bean example is located here on the 'Ohana website:  ohana.windwardreports.com/Wiki/tabid/57/topic/Using%20beans%20in%20your%20template/Default.aspx

Our bean guide is located under the DOCS section of this site, it will assist you in writing your own bean:  ohana.windwardreports.com/LinkClick.aspx

Please e-mail support@windward.net if you want access to the font changing bean to assist you in writing your own.

    --Ryan

 
New Post 5/29/2008 2:46 PM
  peteryen
3 posts
No Ranking


Re: Counting the number of characters/lines in a tag 

Ryan,

I may use your suggested programming approach as a last resort as I would prefer not having to add any new attributes to the Windward tags. I thought of another solution which was to use the XPath function: string-length(). However, I can't seem to get this to work properly with a statement.

I am able to do <wr:out select="str-length(/Data/field)"/>....however, I tried doing <wr:query select="str-length(/Data/field)" var="fieldLength"/> which doesn't work .... as well <wr:set select="str-length(/Data/field)" var="fieldLength"/> along with <wr:if test="${fieldLength}=10"/>...which doesn't evaluate to a boolean.

Am I doing something wrong or does string-length not work too well with Windward.

Thanks,

 
New Post 6/24/2008 5:11 PM
  tomasr
9 posts
No Ranking


Re: Counting the number of characters/lines in a tag 
Modified By tomasr  on 6/24/2008 5:12:48 PM)

Hi, Peteryen

Here's the deal with the string-length xpath funciton.

string-length won't work in the query tag because the query tag requires a record set,
but you can select the record using the query tag and then use string-length in a different tag that uses that query's variable:

<wr:query select="/data/field" var="field"/>
<wr:out select="string-length(${field})" />

The set tag is not a datasource enabled tag, it only uses hard-coded values or variables thar are in scope (like ${field}), and so it doesn't use xpath functions, but you can carry a variable through it and use the string-length function on a datasource enabled tag like out tag.

- Tomas

 
Previous Previous
 
Next Next
  Forum  Templates  Tags & Template...  Counting the number of characters/lines in a tag
Membership Membership:
Latest New User Latest: louisedean
New Today New Today: 0
New Yesterday New Yesterday: 0
User Count Overall: 55

People Online People Online:
Visitors Visitors: 36
Members Members: 0
Total Total: 36

Online Now Online Now:
All contents copyright (c) 2002 - 2008 by Windward Studios, Inc. All Rights Reserved.   Terms Of Use  Privacy Statement