contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
built-in variable   attributes    
  Related Syntax   Related Concepts  

Purpose

The keyword attributes treats the set of all declared attributes of an element as a shelf. The name of the attribute is used as the key, and the value of the attribute is obtained from the value of the item.

To reference the attributes of a specific element, the element can be qualified in all of the same ways as attribute references. The attributes shelf doesn't really have a name, so aliases are used to identify items in the set of attributes. There is no default current item in a set of attributes, and one must be defined by the programmer with using or repeat over.

The attributes shelf is indexed as follows:

For example, the following output action gives the value of the first attribute declared for the current element, no matter what its name or where its value is specified in a start tag. The following is an error if there are no attributes declared for the currently opened element, or if the first declared attribute doesn't have a specified (or defaulted) value:

  output attributes item 1

In the following output action, however, the value of the first attribute specified in the start tag is output, no matter where it appears in the order of declarations. This action is an error if no attributes are specified in the start tag, even if there are declared attributes and they all have default values.

  output specified attributes item 1

Applying the has key test to the attributes shelf determines whether an element has a declared attribute. Note, however, that just because an attribute is declared, it does not necessarily have a value.

The number of attributes declared for an element can be determined by applying number of to attributes.

The following example shows how the of element element qualifier can be used to refer to an attribute of the currently opened element:

  output attribute this-one of element

The following down-translate program uses the attributes shelf to add "id" attributes to elements that can have them:

  down-translate

  global counter id-count

  element #implied
     output "<%q"
     do when attributes has key 'id'
        do when attribute id is cdata
           output " id='%q/%d(id-count)'"
        else
           output " id='%d(id-count)'"
        done
        increment id-count
     done
     output ">%c"
     output "</%q>" when element isnt empty

  Related Syntax
   attribute
   using attributes
 
Related Concepts
   Attribute aliases
   Attribute tests on items of the "attributes" shelf
   Attributes: order of indexing
   XML/SGML parser: locking input
 
----  

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:01:02 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.