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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Retrieving XREF Value from ACL

GarethOakes
16-Pearl

Retrieving XREF Value from ACL

Hi all,

I have another question 🙂

Does anyone know if it's possible to retrieve the text of a
cross-reference from an ACL script called via attloc="system-func"?

I have tried the piece of code below in my ACL, but Arbortext complains
that it cannot retrieve the value:

$value = fosivar_value($window, 'c001-ref5#bibr.xref', $oid);

The "bibr.xref" is being stored for all e-i-c's that have an ID on them,
and "c001-ref5" is the actual ID of the target element I need to pull
the cross-reference text from.

In a <savetext> I can get the value I need using #XREF(target,bibr.xref)
in the conrule, but I do need to get the values in ACL. This is because
as I'm iterating over a bunch of xrefs and resolving them in order to
output a list, and "range" the numbering as required, eg. "1-3,15"
instead of "1,2,3,15". I don't think <savetext> supports automatic
"ranging" of #XREFs ..

I can probably get around this using XPath, as the actual
cross-reference text I need to pull in is quite simple, but just wanted
to know if there was an easier way.

Cheers,
Gareth
3 REPLIES 3

Hi Gareth,

I'm not sure if you need to retrieve the FOSI variable itself or if you can afford to create the cross-reference text entirely in ACL. If it's the latter situation, then this may be helpful. When I've had to build really sophisticated cross-references, I've used ACL functions called by system-loc and have found the following code:

$idref = oid_attr($oid,'idref');

if (oid_find_child_attrs(oid_null(), $oids, 'id', $idref, 16)) {
$targetOid = $oids[1];
}

to be very efficient even in large documents especially if you specify the ID attribute bitmask. You can process the target however you want and supply an error message if an appopriate target isn't found.

I've used it to determine if an id is present in the open document and have the FOSI automatically create a cross-reference or an external link based on the result and it was able to handle some pretty large documents; if you're just constructing text for a cross-reference it should work efficiently enugh for you.

Cheers,

Dugald

Hi Dugald,

This is really good input, thanks a lot. I had considered something like
that but wasn't sure of performance (and also how long to implement).
This seems like a really neat way for DIY cross-references.

I did manage to get my code working the XPath way now, but if the
cross-refs become more complex I will probably need to go with your method.

Cheers,
Gareth

Dugald Topshee wrote:
> Hi Gareth,
>
> I'm not sure if you need to retrieve the FOSI variable itself or if you
> can afford to create the cross-reference text entirely in ACL. If it's
> the latter situation, then this may be helpful. When I've had to build
> really sophisticated cross-references, I've used ACL functions called by
> system-loc and have found the following code:
>
> $idref = oid_attr($oid,'idref');
>
> if (oid_find_child_attrs(oid_null(), $oids, 'id', $idref, 16)) {
> $targetOid = $oids[1];
> }
>
> to be very efficient even in large documents especially if you specify
> the ID attribute bitmask. You can process the target however you want
> and supply an error message if an appopriate target isn't found.
>
> I've used it to determine if an id is present in the open document and
> have the FOSI automatically create a cross-reference or an external link
> based on the result and it was able to handle some pretty large
> documents; if you're just constructing text for a cross-reference it
> should work efficiently enugh for you.
>
> Cheers,
>
> Dugald

Hi Dugald,

While we're on this topic, one more thing just occurred to me - did you
figure out a good way to pull in the formatted page number for the
cross-reference target using your method?

Cheers,
Gareth

Dugald Topshee wrote:
> Hi Gareth,
>
> I'm not sure if you need to retrieve the FOSI variable itself or if you
> can afford to create the cross-reference text entirely in ACL. If it's
> the latter situation, then this may be helpful. When I've had to build
> really sophisticated cross-references, I've used ACL functions called by
> system-loc and have found the following code:
>
> $idref = oid_attr($oid,'idref');
>
> if (oid_find_child_attrs(oid_null(), $oids, 'id', $idref, 16)) {
> $targetOid = $oids[1];
> }
>
> to be very efficient even in large documents especially if you specify
> the ID attribute bitmask. You can process the target however you want
> and supply an error message if an appopriate target isn't found.
>
> I've used it to determine if an id is present in the open document and
> have the FOSI automatically create a cross-reference or an external link
> based on the result and it was able to handle some pretty large
> documents; if you're just constructing text for a cross-reference it
> should work efficiently enugh for you.
>
> Cheers,
>
> Dugald
Top Tags