SGMLXML.net A place for SGML and XML application developers.

September 1, 2021

ACL

Filed under: — cangione @ 7:15 am

Arbortext Command Language

ACL is a structured programming language with over 400 functions and commands. It is flexible enough for you to perform simple operations and develop complex applications.

The defining characteristics of ACL are:

  • platform independence
  • interpreted language
  • perl-like syntax
  • textbased
  • designed for use with SGML/XML

ACL can be used to:

  • write simple “macros” that increase user productivity
  • map specific keys to work in specific windows or classes of windows
  • redesign the Arbortext menu system
  • build and control new panels and windows
  • change the behavior of events in the Arbortext application
  • communicate with other applications

oid_xpath_string { .section}

oid_xpath_string(oid, expr[, nsOid])

This function evaluates an XPath expression with respect to an OID and returns the result of expr converted to a string.

  • oid — The object to use as the context node.

  • expr — A valid XPath expression.

  • nsOid (optional) — The node used for resolving namespace prefixes in the XPath expression.

    Note:

    The nsOid parameter is useful when you need to evaluate the same XPath expression against many XML documents. Those documents might use a different namespace prefix than the XPath expression. If you provide an OID where the namespace prefix is declared, its URI can be matched up with the document instances regardless of the namespace prefixes they used. For example, you might have a configuration file that uses XPath expressions to specify naming rules with namespace prefixes declared on its root element.

Non-string results are converted to strings using standard XPath rules:

  • Boolean expressions are converted to the string “true” or “false”

  • Node set expressions return the string value of the first node, or an empty string if the node set is empty.

  • Numbers are not specially formatted.

To handle errors, call this function from within a catch.

eval oid_xpath_string(oid_root(), "//title")

oid_xapth_nodeset { .section}

oid_xpath_nodeset(oid, arr, expr[, nsOid])

This function evaluates an XPath expression in the context of an OID and returns the result as an array of OIDs. This function can be used to identify a group of elements to be iterated through. It can also be used for navigation, for example, by passing one of the returned OIDs to goto_oid.

  • oid — The object to use as the context node.

  • arr — An unordered array of OIDs returned by expr.

  • expr — A valid XPath expression that evaluates to a node set containing only XPath nodes that have associated OIDs.

  • nsOid (optional) — The node used for resolving namespace prefixes in the XPath expression.

This function fills the array arr with the first OID of each XPath node returned by expr. The return value is the number of OIDs stored in arr. Duplicate OIDs may be returned if more than one XPath node resolves to the same OID. oid_null is returned for any XPath node that cannot be converted to an OID (for example, namespace nodes and attributes).

#======================================================================
# File:     gotoXPATH.acl
#
# Content:  Open an XML document and scroll to the given XPATH String 
#
# Author:   Charles Angione
#
# Version:  1.0
#
# Invocation: 
# -C2 "XPATH('[document path]\test.dita' , '//taskbody/steps/step[5]')"
#======================================================================

function main::XPATH(file,xpathstring) {
    doc_id = doc_open(file);
    doc_show($doc_id,1);    
    status = oid_xpath_nodeset(oid_root(),$arr,$xpathstring);
    if ($status == 0){
        message "could not find xpath location"
    }
    else{
        goto_oid($arr[1]);
        scroll_to_oid($arr[1]);
    }   
}

oid_xpath_integer { .section}

oid_xpath_integer(oid, expr[, nsOid])

This function evaluates an XPath expression in the context of an OID. This function evaluates expr as a floating-point number, rounds to the nearest integer, and returns that integer.

  • oid — The object to use as the context node.

  • expr — A valid XPath expression that can be represented as an integer.

  • nsOid (optional) — The node used for resolving namespace prefixes in the XPath expression.

Non-numeric results are converted to numbers using standard XPath rules:

  • Strings are parsed as floating-point numbers.

  • Boolean expressions are converted to 1 or 0.

  • Node set expressions are first converted to strings, then parsed. A run-time error occurs if the result cannot be represented as an integer.

oid_xpath_boolean { .section}

oid_xpath_boolean(oid, expr[, nsOid])

This function evaluates an XPath expression in the context of an OID and returns 1 (true) if expr is true, otherwise it returns 0 (false).

  • oid — The object to use as the context node.

  • expr — A valid XPath expression.

  • nsOid (optional) — The node used for resolving namespace prefixes in the XPath expression.

A typical boolean expression will use one of the XPath boolean operators (=, !=, <, , =, <=). For example,

count(sect1)=0

Non-boolean results are converted to boolean using standard XPath rules:

  • The numbers zero (0) and NaN (not a number) are converted to false. Other numbers are converted to true.

  • Node set expressions returning at least one node are converted to true. Empty node sets are converted to false.

  • Strings are converted to true if they contain at least one character (including white space). Empty strings are converted to false.

    Note:

    Because non-empty strings are converted to true, the string “false” and the expression “string(false())” are both converted to true.

Write out XML file for Web Browser

To display an XML document in a web browser use the write command:

`write -noheader -flatten both -nonasciichar numref filename.xml`

Hooks

Remember the PREPEND paramater when using in custom applications.

Packages

Adding main:: infront of a function in any package makes it part of the core functions within Arbortext.

Change Tracking

Arbortext Function for evaluating the current state of change tracking:
option('changetracking');

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress