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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

ACL - Find All Instances of a Tag in an XML file

RobertWilliams
1-Newbie

ACL - Find All Instances of a Tag in an XML file

I know, I know.... noob question - but I'm not an ACL person, and I'm about crazed out- on trying to find a simple way to lift/extract all of the 'figure' tag contents in an XML file (Mil-Std Tech Manual DTD - Need to create a list of figs by id with titles and graphic boardnos).

Was trying the REGEX route, problematic (too many 'workarounds' required - remove all line returns), then looked to XML parsers, (too hard, too long to learn it). It's a long walk down the google rabbit hole to not find a really easy solution to this...

Then I thought... "HEY" (I actually said this out loud in the office, disturbed some folks)... With all of you Arbortext Wizards (capital W) out there, doing magical ACL stuff; someone's got to have an ACL command in their pocket to simply 'find' all instances of an XML tag - so that I can 'mark' them, and copy/paste them out somehow, no?

Lastly (related Q), is there a 'cheatsheet' out there in Arbortext land of commonly used/abused ACL commands/command strings? Can someone drop a breadcrumb to a lowly tech writer that knows not the ways of the ACL lore?

Thanks in advance for all reads/replies/laughter/quiet mirthful musings.

Regards,

Bob W.

Bristol RI, US

1 ACCEPTED SOLUTION

Accepted Solutions

Hey Bob,

ACL is a pretty simple language to pick up and would actually be a good place to start if you aren't familiar with programming or scripting. For a rough idea of the syntax, you can look at some Perl tutorials online. The two languages are similar. I was a Perl guy for many years before I picked up ACL and transitioned pretty easily.

One difference is that ACL is specially designed for traversing and working with XML in Arbortext. There are loads of commands and functions that make ACL handy for cerrtain tasks. You can also use ACL to alter Editor's behavior based on your environment. PTC offers an ACL Reference Guide that I've used almost exclusively with my ACL work.

That being said, this forum is also a great resource when you get "stuck" (as we all do).

In ACL, you'll see the acronym "oid" often. This means object identifier and is simply how ACL knows where things are in an XML file. There are many functions around "oid" to help you move around and find things in XML.

For your particular question, I think the following shoud help you:

local FIGS[];

local i=1;

oid_find_children(oid_root(),FIGS,"figure");

for(i in FIGS){

eval oid_content(FIGS[i],0x1) output=>*;

}

I didn't run this myself to debug, but the concept is that an array called FIGS is created. Using the function oid_find_children will fill FIGS with a list of all of the object identifiers (oids) of all of the figures in the document. Then you can loop through FIGS and output the contents of each figure tag to the screen.

You can modify as you need to, but hopefully this will get you started.

-Jeff

View solution in original post

3 REPLIES 3

If you want an ASCII file like the following:

FIGURE ID=abc

TITLE=Figure Title 1

BOARDNO=moonrove.tif

FIGURE ID=def

TITLE=Figure Title 2

BOARDNO=satellite.tif

created from input such as this:

<figure id="abc">

<title>Figure Title 1</caption>

<graphic boardno="moonrove.tif">

</figure>

...

<figure id="def">

<title>Figure Title 2</caption>

<graphic boardno="satellite.tif">

</figure>

you can use the attached FOSI to format the document, which will create a file named doc.exp. If the top tag in the document is not <doc>, make the change in the FOSI and re-compile it, then re-format the document. The name of the .exp file will change accordingly. If you need to change the .exp extension, there is a way to do that.

Hope this helps!

Hello.

A good way could be to use xpath functions from ACL.

For instance, the xpath_nodeset function fills an array of elements (oids) corresponding to xpath request.

Regards,

S.Sauvage

Hey Bob,

ACL is a pretty simple language to pick up and would actually be a good place to start if you aren't familiar with programming or scripting. For a rough idea of the syntax, you can look at some Perl tutorials online. The two languages are similar. I was a Perl guy for many years before I picked up ACL and transitioned pretty easily.

One difference is that ACL is specially designed for traversing and working with XML in Arbortext. There are loads of commands and functions that make ACL handy for cerrtain tasks. You can also use ACL to alter Editor's behavior based on your environment. PTC offers an ACL Reference Guide that I've used almost exclusively with my ACL work.

That being said, this forum is also a great resource when you get "stuck" (as we all do).

In ACL, you'll see the acronym "oid" often. This means object identifier and is simply how ACL knows where things are in an XML file. There are many functions around "oid" to help you move around and find things in XML.

For your particular question, I think the following shoud help you:

local FIGS[];

local i=1;

oid_find_children(oid_root(),FIGS,"figure");

for(i in FIGS){

eval oid_content(FIGS[i],0x1) output=>*;

}

I didn't run this myself to debug, but the concept is that an array called FIGS is created. Using the function oid_find_children will fill FIGS with a list of all of the object identifiers (oids) of all of the figures in the document. Then you can loop through FIGS and output the contents of each figure tag to the screen.

You can modify as you need to, but hopefully this will get you started.

-Jeff

Top Tags