swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
    Related Topics  

Attribute tests on items of the "attributes" shelf

All the tests that can usually be applied to attributes can be used with any identification of an attribute, where the attribute is identified by using the attribute's name, using an attribute alias name, or selecting an item of the attributes shelf.

Because all attributes of specified attributes are, by definition, specified, the is specified, is defaulted, and is implied tests don't make much sense when applied to it: is specified always succeeds, and is defaulted and is implied always fail.

For example, the following repeat over loop outputs only those attributes whose values are defaulted or specified (excluding those which are implied or unspecified) and whose values consist entirely of letters. The attributes are output in the order in which they are declared. This is accomplished by testing an attribute identified by an attribute alias name:

  element #implied
    output "<%q"
    repeat over attributes as this-attribute
      do when attribute this-attribute isnt implied and
          attribute this-attribute matches(letter+ value-end)
        output "%_" ||
               key of attribute this-attribute ||
               '="' || attribute this-attribute ||
               '"'    done
    again
    output ">%n%sc%sn</%q>%sn"
  
  process
    do sgml-parse document scan
        file "my-doc.sgm"
      output "%c"
    done

Running this program with the input file "my-doc.sgm", which contains the following:"

  <!doctype a [
  <!element a - - (b+)>
  <!element b - - (c+)>
  <!element c - - (#pcdata)>
  <!attlist a
     a1 nutoken #implied
     a2 cdata "strawberries"
  >   
  <!attlist c
     c1 cdata #implied
     c2 cdata "apples"
  >   
  <!attlist b
     c1 cdata "potato jam"
     c2 cdata "kiwi"
  >   
  ]>
  <a>
  <b>
  <c>Text
  </c>
  </b>
  </a>

produces this output:
  <A A2="strawberries">
  <B C2="kiwi">
  <C C2="apples">
  Text
  </C>
  </B>
  </A>

    Related Topics
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:35:14 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.