Pennington / Example

XTRAN Demonstration:  Analyzing XML Tag & Attribute Usage

XTRAN treats XML as a computer language, in which each "statement" is a tag, a line or segment of nonmarkup text, or an end tag.  Each attribute of a tag is a "statement attribute".



* Rules:

The following is an English paraphrase of the XTRAN rules used for this example.  These rules comprise 110 (net) lines of XTRAN's rules language.

    For each XML tag occurrence
        Tally tag occurrence
        For each of tag's attributes if any
            Tally attribute occurrence for tag
    Sort tags
    For each XML tag seen, alphabetically
        Report tag tally
        Sort attributes for tag
        For each attribute seen for this tag, alphabetically
            Report attribute tally


* XML input:

<tag1><tag2/><tag3 att1="att1v" att2="att2v">
This is the first line of text, followed by a comment.<!-- comment 1 -->
This is the second line of text, with no comment.
</tag3>
<!-- comment 2 -->
This is the third line of text, preceded by a comment.
<tag3>Some text in a "tag3".</tag3>
<tag4 attb="attbv1" atta/>
This is more nonmarkup text.<tag4 attb="attbv2"/>
</tag1>


* Output:

Running the rules shown above on the XML input shown above generated the following XTRAN analysis output:

                          XML Tag and Attribute Usage

tag1                1
tag2/               1
tag3                2
    att1        1
    att2        1
tag4/               2
    atta        1
    attb        2

Note how each "empty" tag is indicated with a trailing /.



COPYRIGHT 2008; reproduction prohibited without permission.  Revised 2006-11-27

XTRAN is a trademark of Pennington Systems Incorporated.

Pennington Systems Incorporated
8655 East Via de Ventura, Suite G200
Scottsdale, Arizona 85258-3321

Phone:  +1(480)626-5503
Fax:  +1(480)626-7618
Email:  Info@Pennington.com
Web:  http://WWW.Pennington.com

[home] Home