    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class xm.xm_AttToChildConverter

    java.lang.Object
       |
       +----xm.xm_NodeFormatter
               |
               +----xm.xm_AttToChildConverter

public class xm_AttToChildConverter
extends xm_NodeFormatter

To create a child node for each of an xg_Node's attributes (and for those of all its descendants). The motivation for this is to make it easier to apply an XSL stylesheet to an XML document: it enables attribute values to be included in the results without resorting to the use of a scripting language. (This class has, however, been included in the xg package since it is not XSL-specific per se, and could conceivably be of use for other purposes.)

It applies the following rules:

- Apply these rules to each child element (ie. any node which is not an xg_Element is left unchanged), which will apply them to its children in turn. (Note that this is done before turning our attention to the node's attributes, to save us the trouble of applying these rules to the new child nodes which will result.)
- For each of the node's attributes, create a new child element whose type is the name of the attribute, and whose content is the value of the attribute. The new children are placed at the beginning of the element's content. The preceding whitespace of each of these new children is set to be the same as that of its parent.

  Note that while this class implements the xg_NodeFormatter interface (because it is a convenient interface), this is not strictly just a formatter, because it makes significant changes to the structure of the node (typically a document) on which it is invoked.

  ##

  xm_AttToChildConverter()

  ##

  format(xg_Node, int)
    Convert the given node, and its children.
  getPrependParentNameFlag()
    Get the value of the flag which determines whether elements generated from attributes have their parent's type prepended.
  setPrependParentNameFlag(boolean)
    Set the value of the flag which determines whether elements generated from attributes have their parent's type prepended.

  ##

  xm_AttToChildConverter

       public xm_AttToChildConverter()

  ##

  format

       public void format(xg_Node InputNode,
                          int InputOpeningDepth)

    Convert the given node, and its children.

    Parameters:
      InputNode - The node to convert
      InputOpeningDepth - The depth of the node in the hierarchy. This is ignored, and is present purely for compatibility with xg_NodeFormatter.
    Overrides:
      format in class xm_NodeFormatter
  setPrependParentNameFlag

       public void setPrependParentNameFlag(boolean InputPrependParentNameFlag)

    Set the value of the flag which determines whether elements generated from attributes have their parent's type prepended.

    Parameters:
      PrependParentNameFlag - true if the parent's type is to be prepended; false if not
  getPrependParentNameFlag

       public boolean getPrependParentNameFlag()

    Get the value of the flag which determines whether elements generated from attributes have their parent's type prepended.

    Returns:
      true if the parent's type is prepended; false if not

      All Packages  Class Hierarchy  This Package  Previous  Next  Index