swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax    
operator  

ancestor is

 
 

Return type: Switch
Returns:       Returns true if the named element occurs in the element stack before the current or specified element, otherwise false.

Syntax

ancestor ancestry-qualifier (is | isnt)namespace-modifier? element-name


Purpose

The ancestor is element test returns true if the element indicated has any ancestor with the specified element name, and false otherwise. Replacing is with isnt will reverse these results. An element can be opened more than once, so its "name" can occur more than once in a set of opened elements. As a consequence, a specific element is typically identified by a "relationship" to another element, as well as or instead of by its name. ancestor refers to any element containing the specified element at any level. This is a very broad parameter, so care should be taken in its use.

If no element qualifiers are present, the test always starts searching for ancestors starting with the parent of the current element.

Instead of specifying only a single element name, the test allows the programmer to specify a parenthesized list of element names separated by or (or |). The test succeeds if the reference element is identified by any of the names in this element name list.

In OmniMark 8, you can specify the name dynamically by using the identity operator (~) followed by a string expression:

  ; Check for elements with an ancestor of the same name
  element #implied when ancestor is ~(name of element)
    suppress

Previously, this rule would have to be coded as:

  define switch function ancestor-has-same-name
    as
      repeat over current elements as e
        return True
          when name of current element e = name of element and not #last
      again
    return False
  
  element #implied when ancestor-has-same-name
    suppress

    Related Syntax
 
 
 

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

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

Copyright © Stilo International plc, 1988-2010.