cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to count the number of characters in a tag ?

SOLVED
Highlighted
Level 6

How to count the number of characters in a tag ?

Hello,

We are using Arbortext Editor 5.4 for authoring some newsletter in SGML.

My editors need to know the number of characters in their title.

I know we can count the number of words... but it's not relevant for them.

So I'm guessing if it's possible to count the numbers of chars in a tag with a macro or something else...

Thanks for your help.

Regards.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to count the number of characters in a tag ?

A simple approach would be something like this (typed in the Arbortext command window):

response(length(oid_xpath_string(oid_caret(),".")))

It gets a little more complicated if there can be embedded tags inside the element you're interested in. This particular version will string together all text nodes inside the current tag (where the caret is), ignoring nested markup.

 

If this works for you, you could hook it up to a menu item using menu_add to make it easy for your authors to use.

7 REPLIES 7

Re: How to count the number of characters in a tag ?

I have a question here. Do they want to know the input characters (not counting tags) or the ouput characters printed on the documents.We have a lot of generated text by the FOSI which displays on the document (like Table of contents, company name and address, Figrure name in the text for example Figure 9. The gear shift.

 

What values do they wnat, what is the purpose fo the count.

Re: How to count the number of characters in a tag ?

A simple approach would be something like this (typed in the Arbortext command window):

response(length(oid_xpath_string(oid_caret(),".")))

It gets a little more complicated if there can be embedded tags inside the element you're interested in. This particular version will string together all text nodes inside the current tag (where the caret is), ignoring nested markup.

 

If this works for you, you could hook it up to a menu item using menu_add to make it easy for your authors to use.

Re: How to count the number of characters in a tag ?

Thank you Clay

I will try it asap

Regards.

Benjamin

Re: How to count the number of characters in a tag ?

Hello Clay,

To keep you in touch, your code is working great.

Thank you very much.

Benjamin

Re: How to count the number of characters in a tag ?

Hi Benjamin--

 

Great, I'm glad to hear it's working for you. In that case, would you mind taking a momemt to mark my reply as "Answer"? Thanks.

 

--Clay

Re: How to count the number of characters in a tag ?

done !

Thanks again.

Benjamin

Re: How to count the number of characters in a tag ?

Hi Ray--

 

I'm not the OP, so I can't address your question about this use case directly, but they seemed to be satisfied with my suggestion, so I assume they aren't trying to include generated text or other markup artifacts.

 

If someone did have a use case where they needed to include gentext, they'd have to smarten up the script a bit, probably by walking the OID tree for the selected OID and using a combination of oid_gentext() and oid_content() in lieu of the simple oid_xpath_string() expression.

 

--Clay