• Arbortext Editor, Tip

    Posted on January 16th, 2010

    Written by JeffStein

    Arbortext Editor Tip – Identifying Text Entities

    In Arbortext Editor, a text entity is a named piece of content. For example, you could create a text entity called Product Name with the content Widget Analyzer 2010. Text entities help you to achieve consistency both within and across documents. Simple enough, right?

    Let’s assume that you have an SGML file open and you know that a particular phrase or sentence is already a text entity — but you don’t know the unique name of the text entity. How can you easily figure out the name?

    One of my co-workers said that she goes to the View menu and selects Text Entities. The content of the text entity is replaced by a tag that displays the name.

    text entity tag

    Then I told her my approach. Place your cursor inside the phrase or sentence and choose Entities > Text. The Text Entities dialog box appears with the entity highlighted.

    Text Entities Dialog Box

    My co-worker said that she liked my approach better. Sweet!

  • PubWright Podcast

    My friend Liz Fraley of Single-Sourcing Solutions asked to interview me in a podcast. We have chatted over the last few months on how we wanted to do this. I knew I want to, I needed to learn that medium. So, we played with some technology, and using Skype, and recorders on both ends and we hammered out the first podcast.

    Liz took the raw recordings and enhanced them and the conversation sounded good. The podcast collection is called PubWright Podcasts; it is mostly about the Arbortext community. The PubWright podcast interviews Arbortext implementers, customers, and experts in an attempt to share knowledge with the greater Arbortext community. The first podcast featured me. I wanted few more episodes to be released, before I mentioned anything,  (the quality of the guest can only go up). So check out the podcast.

    This is a Podcast series available here and on iTunes here.

    http://podcast.single-sourcing.com

  • Wiki Help Files

    One thing that I think about all the time is how to improve documentation. One thing I would like to have is documentation that is context sensitive in Arbortext and collaborative.  At work we have a style guide which determines “what” we are to do but rather than “how” to do it.  Many years ago, I placed all of the “how to” documentation into Microsoft Word, saved it out as PDF, yet I struggled with this. Next, I desired to work more in XML, so I adopted Docbook. All the Microsoft documents were converted to Docbook which I pushed out, HTML pages, PDF files, and Microsoft Help (.chm) files.

    The biggest issue was that I was the single bellybutton to all the documentation. I strived for a collaborative solution. I worked with Wiki’s and set out to install one. Our corporate structure would not allow me to install one. The company had just created one, and they only wanted one in the company culture. I was not sure that I wanted all my documentation out there for all to see. Because I work for a large aerospace company. However, I got over it; it was more important to have collaborative tools rather than my pride. I imported all the docbook information into our Wiki.

    The biggest complaint of the wiki was its weak search. I wanted a way for a writer who is authoring in a SGML/XML file, to hit the help button and go to an exact area in the documentation. The Arbortext Editor has the Shift-F1 to present a customized help. I played with it trying to add hyperlinks to those files. With the help of the adepters mailing list and Clay Helberg (a Arbortext guru), he mentioned a few things, one being of which is remapping the Shift-F1 key. The other is how to open a file. So, I used the browse_url function which launches a HTML page, in my case a Wiki page. I needed to add more information in the URL based on the two things: the DTD name and element name. In the Wiki, I am using subpages which are like a collection. All pages will be a subpages grouped in “Structured-Elements” and also “38784″ (the DTD name) followed by the tag name. The tag is found using the ACL functions of oid_name(oid_caret()). The oid_caret is the cursor position and oid_name is the name of the element. So below is the code snippet: I placed it inside my ACL file located at  (<arbortext-home>/custom/editinit) which gets sourced when a document is opened.

    $dtd = public_id();
    if (match($dtd,"38784" )) {
         map shift-f1 { browse_url("http://wiki.yourcompany.com/wiki/Structured-Elements/" .  "38784/" . oid_name(oid_caret()) ) }
    }

    When the writers place the cursor inside an element, for example,  <title>, and then does a Shift-F1, the Arbortext Editor will open to a Wiki page by element and DTD name.

    That was the easy part, now is the hard part; populating the Wiki with content on the elements. With Mil-Spec DTD’s (some of our work uses them), we have a TDT file (it contains all the element names and attributes with descriptions). My co-worker, Joe, our other Software Engineer, wrote a Perl script to convert each element to a Wiki page. I will import a couple of hundred new Wiki pages here in the next few days.

    The final part is adding extra links in these new pages to the established Wiki pages, therefore linking the entire project together.

  • Removing Unused Graphics

    In SGML files graphics are declared. Once they are declared they can be referenced in elements such as <graphic> or whatever your DTD declares. Often during the development of the files, some graphic declarations are created but never used. It is a good practice to remove graphic declarations that are not required.

    I came across this ACL file from Karl Johan Kleist (original code by Rune Kallhovd) on Adepters website, listed below.

    I named that code below as removeUnusedGraphics.acl and placed it in <arbortext home>/custom/scripts folder. I tied it to a menu on init ACL file (<arbortext home>/custom/editinit) that runs when a document is opened. It has these items added in the menu. First, the file is sourced. second, call the function, clean_unused_gfxents() when the menu item is selected.

    Remove Unused Graphic Menu Pick

    Remove Unused Graphic Menu Pick

    Items to add to the Menu*

    source removeUnusedGraphics.acl
    menu_add ".TechData." "Remove all unused graphic entities" -cmd { clean_unused_gfxents() }

    Code File

    # Rune Kallhovd and Karl Johan Kleist
    # Posted 2006-06-18 to adepters.org

    function clean_unused_gfxents(doc,op) {

        local entArr[], gfxArr[];
        local entArrlen = 0;
        local gfxCnt = 1;

        if (op != 2) {
            return 0;
        }

    # Building an Array of declared entities:

        entArrlen = graphic_entity_names(entArr, doc);

    # Building an Array of used entities:

        for (o = oid_first(doc); oid_valid(o); o = oid_forward(o)) {

            # Do we have a Graphic tag?

            if (graphic_tag(oid_name(o))) {

                # Get the attribute name holding the ENTITY

                local gfxentnam = graphic_entity_attr_name(oid_name(o));

                if (gfxentnam != "") {
                    gfxArr[gfxCnt] = oid_attr(o, gfxentnam);
                    gfxCnt++;
                }
            }
        }

    # Iterate over declared entities, and delete unused ones:

        for (i = 1; i <= entArrlen; i++) {

            local found = 0;

            ent = entArr[i];

            for (gfx in gfxArr) {
                if (gfxArr[gfx] == ent) {
                    found = 1;
                }
            }

            if (!found) {
                undeclare_entity $ent;  # NOTE: dollar sign needed here / kjk
            }
        }
    }

    # Add the following to e.g. a init() function:
    doc_add_callback(0, ’save’, ‘cor_utils::clean_unused_gfxents’, ‘PREPEND’);

    * Menu article coming soon…

  • Starting with Arbortext’s ACL Language – Part 4

    ACL, Arbortext’s Command Language, it is similar to Perl which is the programming language I prefer. See Part 1, Part 2 and Part 3.

    Arrays

    Arrays are special variables with multiple “compartments”. Each compartment holds a value. Arrays consist of names and indexes. ACL has two types of one-dimensional arrays:

    Normal arrays are indexed by integers subscripts.

    $array[1] = "tester";

    Associative arrays are indexed by arbitrary strings or keys.

    $array["tester"] = "debug";

    Declaring Arrays

    Arrays can be defined as local or global. Define them like a variable, ($) name, square brackets, semicolon. Arrays can be set to a dimension such as having ten values, $array[10].  The square brackets [ ] are used to address or retrieve the elements of an array.

    Accessing Array

    Accessing the keys of an array, use the for loop, as in: for (key in array).
    For example, the code below iterates over the two elements of the associative array color twice, once with Associative and once with Normal:

    #– Associative Array
    $color["red"] = "red";
    $color["blue"] = "blue";
    for ($hue in $color) {
     response("the color is " . $color[$hue]);
    }

    unsetvar color; #– the color array undeclared

    #– Normal Array
    $color[1] = "red";
    $color[2] = "blue";
    for ($hue in $color) {
     response($color[$hue]);
    }

  • Starting with Arbortext’s ACL Language – Part 3

    ACL is Arbortext’s Command Language. It is similar to Perl, which I really like. See Part 1 and Part 2.

    Variables

    A variable is a keyword or phrase that is linked to a “value” stored in memory or an expression that can be evaluated. For instance, a variable might be called “total_count” and contains a number. Variables are usually defined in ACL beginning with a dollar sign ($), they do not have to, but it is very good practice. The variable is on the left side and the value is on the right of the assignment operator (=). When assigning variables, it best to read right to left.  For example, assigning the string or text, “red” with the equal sign (=), to a variable “color”. It is a good practice to end your assignments with a semi-colon (;).

    $color = red;

    Some common variable assignments using expressions.

    #— Machine Name
    $machine = $main::ENV[‘COMPUTERNAME’];

    #— User’s Name
    $user = username();

    Variable Scope

    Variables exist in two locations or scopes, Global and Local.

    The default is Local. It is a good practice to define the minimum amount of scope needed or limiting your variables. This is helpful in maintaining the code and debugging it. For example, it may be confusing if a variable is a Global $A and a Local variable called $A are both being used in a For-Each loop.

    Global variables are accessible anywhere in the ACL code.

    Tip: If defining a Global Variable, pick a naming convention such as all caps. This will be helpful when mixing Local and Global variables in code. For Local variables, choose, for example, Camel Case.

    global $DEBUG = 1;
    local $UserName ="Tester";

    Local variables can be limited by a block of code (code inside the { }). When variables are assigned, inside blocks are local or limited just to that block. Blocks can be found in functions and items inside conditionals, such as an if statement.

    function findTMnumberName () {
       mark -select end
       $tmname = $selection #local variable
       gsub(‘^P’, $tmname);
       gsub(‘^V’, $tmname);
       $TMnumber = $TM_NAME[$tmname]; #local variables, global $TM_NAME
       response($TMnumber);
       caret 0,"<title>" -t
       is -pd "$TMnumber";
    }

    Shortcut Assignments

    If using a number variable as a counter, and the counter needs to increment by one, you could do:

    $lineNumber = $lineNumer +1;

    A shortcut using the (+=) means increment and assign the value to itself.

    $lineNumber += 1;

    If using a string variable using the dot operator (.) to concatenate or stitch together strings.

    $message = "File " . doc_name() . " sent to be published!";

    The variable $message resolves as “File Chapter 2 sent to be published!” if doc_name() was equivalent to “Chapter 2″.

    Variable Evaluation

    Variables inside double quotes will be evaluated, and variables inside single quotes are not evaluated.

    $username = "Tester";
    $message = "Hello $username!";

    Returns “Hello Tester!”

    $username = "Tester";
    $message = ‘Hello $username!’;

    Returns “Hello $username!”

    Comparative

    Using variables for comparison. In a “if” statement, you may want the variable, if true, then do something with it. Comparisons can be strings equaling or not equaling other strings. As well as, numbers equaling (==), not equaling (!=), greater (>), lesser (<), greater or equal (>=) or less than or equal (<=) to other numbers.

    String comparisons (==):

    if ($machine == "Dell")  {
       response("machine is a Dell");
    } else if (match($machine ,"HP*" )   {
       response("machine is not a Dell, but some HP Model");
    }

    Number comparison (==, >, <, !=, <=, >=)

    if  ($status !=0) {
        message "You must select something first”; #Not equal to zero
    }
  • Arbortext Editor Tip – Easy Column Selection

    Using Arbortext Editor, selecting a column can take some time. This tip is a quick and easy way to select the entire column. As well as, performance will be better when the table is collapsed or in view markup mode.

  • Arbortext Editor Tip – Multiple Paste

    A tip showing how to paste a single object like a cross reference from one cell into multiple cells of a table in Arbortext Editor.

  • Structured Authoring, XSLT

    Posted on August 13th, 2009

    Written by douglaspaulwade

    XSLT – Converting a Document to Change All Text

    Using XSLT, I want to display some examples, however, not show you the original text. My sample file is a real-world example, but the content is a distraction. This simple transformation will convert all of the text nodes (document text) to x’s. During the transformation, the XSLT stylesheet will convert, all the capital, lowercase letters and the numbers to the lower case ‘x’. It will leave the punctuation alone, and the elements’ attributes are left unchanged.

    Here is a sample snippet of the input file of S1000D Issue 3, XML:

    <?xml version="1.0" encoding="UTF-8"?>

    <dmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:dc="http://www.purl.org/dc/elements/1.1/"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xsi:noNamespaceSchemaLocation="http://www.s1000d.org/S1000D_3-0/xml_schema_master/dm/faultSchema.xsd">

     <idstatus>
     <dmaddres>
     <dmc>
     <avee>
     <modelic>AAA</modelic>
     <sdc>B</sdc>
     <chapnum>28</chapnum>
     <section>0</section>
     <subsect>0</subsect>
     <subject>00</subject>
     <discode>00</discode>
     <discodev>A</discodev>
     <incode>421</incode>
     <incodev>A</incodev>
     <itemloc>A</itemloc>
     </avee>
     </dmc>
     <dmtitle>
     <techname>FUEL LEAK IN FORWARD COMPARTMENT AREA</techname>
     <infoname>OBSERVED FAULT PROCEDURE</infoname>
     </dmtitle>
     <issno issno="001" type="new"/>
     <issdate day="01" month="01" year="2009"/>
     </dmaddres>
     <status>
     <security/>
     <rpc/>
     <orig/>

    Here is the transformation stylesheet:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     exclude-result-prefixes="xs"
     version="2.0">

     <!– Use indent yes for development, no for production –>
     <xsl:output method="xml" indent="yes"/>

     <!–
     Template match all items, except
     SGML Notations and Entities e.g., illustrations.
     –>

     <xsl:template match="@*|element()|comment()|processing-instruction()" mode="#all">
     <xsl:copy>
     <xsl:apply-templates select="@*|node()" mode="#current"/>
     </xsl:copy>
     </xsl:template>

     <!– Using the replace function,
     context is: string, pattern, replacement string–>

     <xsl:template match="text()">
     <xsl:value-of select="replace(.,’[a-zA-Z0-9]‘,’x')"/>
     </xsl:template>
    </xsl:stylesheet>

    Here is the result.s tree (a snippet).

    <?xml version="1.0" encoding="UTF-8"?>
    <dmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:dc="http://www.purl.org/dc/elements/1.1/"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xsi:noNamespaceSchemaLocation="http://www.s1000d.org/S1000D_3-0/xml_schema_master/dm/faultSchema.xsd">

     <idstatus>
     <dmaddres>
     <dmc>
     <avee>
     <modelic>xxx</modelic>
     <sdc>x</sdc>
     <chapnum>xx</chapnum>
     <section>x</section>
     <subsect>x</subsect>
     <subject>xx</subject>
     <discode>xx</discode>
     <discodev>x</discodev>
     <incode>xxx</incode>
     <incodev>x</incodev>
     <itemloc>x</itemloc>
     </avee>
     </dmc>
     <dmtitle>
     <techname>xxxx xxxx xx xxxxxxx xxxxxxxxxxx xxxx</techname>
     <infoname>xxxxxxxx xxxxx xxxxxxxxx</infoname>
     </dmtitle>
     <issno issno="001" type="new"/>
     <issdate day="01" month="01" year="2009"/>
     </dmaddres>
     <status>
     <security/>
     <rpc/>
     <orig/>

  • XSLT

    Posted on August 10th, 2009

    Written by douglaspaulwade

    XSLT – A Starting Point

    I recently returned from an XSLT class taught by G. Ken Holman of Crane Softwrights. The class was five days training on XSLT, XQuery, and XPath. The class took place in Walnut Creek, California, August 3-7th, 2009. This was very intense. It was like trying to get a drink of water out of a fire hose. Ken covered every aspect of the specifications. The class was so over whelming that Joe (my co-worker) and I, being newbies, were clearly out classed. Most of the students had taken the class before, and one gentlemen just took it a month ago.

    Being a newbie, I am going to post items on transformations that are not about covering everything in the specification; there are plenty of books that cover that. I want to give easy-to-follow examples which can be used in converting documents from one flavor of XML to another. I will not cover creating HTML pages or other outputs from these transformations.

    I am no expert, but posting about a subject will help me improve upon writing XSLT. Being that I have a publishing background, I favor XSLT over XQuery (used more for machine-to-machine conversions).

    From my IDE, I will be using <oXygen/>. I prefer it because it has a XSLT debugger, and boy, do I need it. It has several XSLT processors, like Xalan, and Saxon and Saxon-SA (Schema Aware) built in. For my source file, I will be using a S1000D Schema document, which all of the text node (words) have been changed to “x”s. That transformation will be posted in upcoming post. This is to protect the data and not display the content, so it does not take on any significance or meaning. If you are interested, <oXygen> has a 30 day free trial version, and/or you can purchase the Academic or Non-Commercial version for $64.

    XSL stands for EXtensible Stylesheet Language and is a style sheet language for XML documents. XSLT stands for XSL Transformations. You can use XSLT to transform XML documents into other formats such as other XML documents, HTML, XHTML, and using XSLT-FO (format objects) transform XML to PDF, for example.

    The specification is at version 2.0 (2.1 is coming soon), but not all vendors fully support 2.0, as of yet. The specification version 1.0 has been around for some time, and since I am new all of my examples will be in version 2.0, why learn version 1.0 when 2.0 is clearly more verbose.

    XSLT is an XML (version 1.0) document. It must be well formed and valid. Below is an example of XSLT stylesheet used to transform an XML document. While it is valid, the stylesheet does not do much; its only output is: <?xml version=”1.0″ encoding=”UTF-8″?>.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     exclude-result-prefixes="xs"
     version="2.0">

     <xsl:template match="/" />

    </xsl:stylesheet>

  • Older Posts Yeah! There are more posts, check them out.