swirl
Guide to OmniMark 7   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
    Related Syntax  

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 Syntax
   attributes
   is defaulted
   is implied
   is specified
 
 

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

OmniMark 7.1.2 Documentation Generated: June 28, 2005 at 5:44:33 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © Stilo Corporation, 1988-2005.