Skip to main content
1-Visitor
October 19, 2017
Solved

How to count the number of characters in a tag ?

  • October 19, 2017
  • 2 replies
  • 4055 views

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.

Best answer by ClayHelberg

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.

2 replies

1-Visitor
October 24, 2017

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.

18-Opal
November 21, 2017

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

18-Opal
October 25, 2017

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.

benk781-VisitorAuthor
1-Visitor
October 26, 2017

Thank you Clay

I will try it asap

Regards.

Benjamin