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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Making a Global Change in xref

ptc-2903760
1-Newbie

Making a Global Change in xref

Hi All:

I need to make a global change in my cross references for figures.

In the xref element, for the xrefid attributeI have: DGS-2:NTOF:D43. I need to change the colon (:) to a hyphen (-) in order for the cross reference to work. The problem is, I have several hundred instances of the colon. Is there a way to make a global change without opening each element and changing the attribute?

Thanks for the help.

Jeanette Buenger

2 REPLIES 2

Hi Jeanette,

This is easy to do with the Arbortext Command Language (ACL). You
just need to grab all the xref elements and loop through each one
modifying its xrefid attribute as you go. You can write a function
and save it to a file and then load and execute it, or you can
actually do something like this at the command line by typing one line
to save the xref elements to a variable and another line line to cycle
through them all.

Specifically for your needs, you would do it like this:

oid_find_children(oid_null(), $a, "xref");
# this fills $a with all the xref elements in your current file

for ($i in $a)
{$val=oid_attr($a[$i],"xrefid");gsub(":","-",$val);oid_modify_attr($a[$i],"xrefid",$val)}
# This next line says that for every element $i in the list of xrefs,
set $val to the value of the xrefid attribute, then replace any ":"
characters with a "-"; then set the value of the xrefid to this new
value. If you want to run this at the command line, then enter the
first line and hit enter, then enter the entire second line and hit
enter once again.

If you want to reuse it then you can put it into a function like this:

function ChangeColonToHyphen()
{
oid_find_children(oid_null(), $a, "xref");
for ($i in $a) {
$val=oid_attr($a[$i],"xrefid");
gsub(":","-",$val);
oid_modify_attr($a[$i],"xrefid",$val)
}
}

But you would have to save the function to a file and then source the
file before using it.

Cheers,

Dugald

Quoting Jeanette Buenger <->:

> Hi All:
> I need to make a global change in my cross references for figures.
> In the xref element, for the xrefid attribute I have:
> DGS-2:NTOFSmiley Very Happy43. I need to change the colon (Smiley Happy to a hyphen (-) in
> order for the cross reference to work. The problem is, I have
> several hundred instances of the colon. Is there a way to make a
> global change without opening each element and changing the attribute?
> Thanks for the help.
>
> Jeanette Buenger
>
>

Here's an ACL file I did several years ago that will allow you to globally change or delete a specified attribute.

I haven't used it in a while, but it should do the trick. You may have to go into the 'attr_chng' function to and remove the first prompt line (to find a specific element). Then the script will just go looking for the attribute you need to change.

Hope it works and helps.

Lynn

---- Dugald Topshee <lists@phrontisterion.com> wrote:
> Hi Jeanette,
>
> This is easy to do with the Arbortext Command Language (ACL). You
> just need to grab all the xref elements and loop through each one
> modifying its xrefid attribute as you go. You can write a function
> and save it to a file and then load and execute it, or you can
> actually do something like this at the command line by typing one line
> to save the xref elements to a variable and another line line to cycle
> through them all.
>
> Specifically for your needs, you would do it like this:
>
> oid_find_children(oid_null(), $a, "xref");
> # this fills $a with all the xref elements in your current file
>
> for ($i in $a)
> {$val=oid_attr($a[$i],"xrefid");gsub(":","-",$val);oid_modify_attr($a[$i],"xrefid",$val)}
> # This next line says that for every element $i in the list of xrefs,
> set $val to the value of the xrefid attribute, then replace any ":"
> characters with a "-"; then set the value of the xrefid to this new
> value. If you want to run this at the command line, then enter the
> first line and hit enter, then enter the entire second line and hit
> enter once again.
>
> If you want to reuse it then you can put it into a function like this:
>
> function ChangeColonToHyphen()
> {
> oid_find_children(oid_null(), $a, "xref");
> for ($i in $a) {
> $val=oid_attr($a[$i],"xrefid");
> gsub(":","-",$val);
> oid_modify_attr($a[$i],"xrefid",$val)
> }
> }
>
> But you would have to save the function to a file and then source the
> file before using it.
>
> Cheers,
>
> Dugald
>
> Quoting Jeanette Buenger <->:
>
> > Hi All:
> > I need to make a global change in my cross references for figures.
> > In the xref element, for the xrefid attribute I have:
> > DGS-2:NTOFSmiley Very Happy43. I need to change the colon (Smiley Happy to a hyphen (-) in
> > order for the cross reference to work. The problem is, I have
> > several hundred instances of the colon. Is there a way to make a
> > global change without opening each element and changing the attribute?
> > Thanks for the help.
> >
> > Jeanette Buenger
> >
> >
>
Top Tags