public class

XmlRendererBlockVisitorENF

extends DefaultBlockVisitor
java.lang.Object
   ↳ com.microstrategy.web.blocks.DefaultBlockVisitor
     ↳ com.microstrategy.web.blocks.renderers.XmlRendererBlockVisitorENF
Known Direct Subclasses

Class Overview

This class renders a Block tree in XML format, specifically Element Normal Form, where the scalar properties are not represented as attributes, but as elements (with the name of the property defining the name of the element). This renderer does not generate any XML attributes whatsoever.

Here are the rules for converting an arbitrary Block tree into an XML structure:

  1. The name of the root element is determined by calling the method getDocumentElementName(Block). The default implementation returns "root". The root element has no attributes.
  2. Each of the properties defined for the root Block is evaluated in this manner:
    1. Scalar-based properties use the name of the BlockProperty as the element name. A new child element is created and it has a single text node. The value of this text node is the value of the BlockProperty.
    2. Block-based properties use the name of the BlockProperty as the element name (as in the case of scalar-based properties). However, instead of a text node, the properties of this child Block become child elements of this element (using the same rules described above).
    3. List-based properties use the name of the BlockProperty as the element name (as in all cases). However, as the elements of a list have no names (and are only listed one after another), the name of the element that is used for this list element is found by calling getBlockInListElementName(Block). The default implementation returns "block".

Summary

Fields
protected BlockContext blockContext
protected XMLBuilder xmlBuilder
Public Constructors
XmlRendererBlockVisitorENF(BlockContext blockContext)
Public Methods
String getXML()
Gets the XML generated as a String.
void visitBlockEnd(Block block, BlockTarget parent)
Invoked for each Block after all of its properties are visited.
boolean visitBlockStart(Block block, BlockTarget parent)
Invoked for each Block before any of its properties are visited.
boolean visitCompositeProperty(BlockProperty blockProperty, Block parent, boolean firstAssignedProperty)
Invoked for each composite (Block or BlockList) Block Property.
void visitListEnd(BlockList blockList, BlockTarget parent)
Invoked at the end of a BlockList.
boolean visitListStart(BlockList blockList, BlockTarget parent)
Invoked at the beginning of a BlockList.
void visitScalarProperty(BlockProperty blockProperty, Block parent, boolean firstAssignedProperty)
Invoked for each scalar (non-Block, non-BlockList) Block Property.
Protected Methods
String getBlockInListElementName(Block block)
Returns the element name to use for a Block in a List.
String getDocumentElementName(Block rootBlock)
Returns the element name to use for the document element.
String getNestedListElementName()
Returns the element name to use for a BlockList which appears nested inside another BlockList.
[Expand]
Inherited Methods
From class com.microstrategy.web.blocks.DefaultBlockVisitor
From class java.lang.Object
From interface com.microstrategy.web.blocks.BlockVisitor

Fields

protected BlockContext blockContext

protected XMLBuilder xmlBuilder

Public Constructors

public XmlRendererBlockVisitorENF (BlockContext blockContext)

Public Methods

public String getXML ()

Gets the XML generated as a String.

Returns
  • The String representation of the XML generated.

public void visitBlockEnd (Block block, BlockTarget parent)

Invoked for each Block after all of its properties are visited.

Parameters
block The Block being visited.
parent The BlockTarget that contains the supplied Block.

public boolean visitBlockStart (Block block, BlockTarget parent)

Invoked for each Block before any of its properties are visited.

Parameters
block The Block being visited.
parent The BlockTarget that contains the supplied Block.
Returns

public boolean visitCompositeProperty (BlockProperty blockProperty, Block parent, boolean firstAssignedProperty)

Invoked for each composite (Block or BlockList) Block Property. In particular, it is only invoked for BlockProperty instances whose value is non-null.

Parameters
blockProperty The BlockProperty that has an assigned value.
parent The Block that contains this BlockProperty.
firstAssignedProperty Whether or not this is the first assigned property of the Block.
Returns
  • True if the Block Property should traverse the composite value of this property. If false, there is no traversal.

public void visitListEnd (BlockList blockList, BlockTarget parent)

Invoked at the end of a BlockList.

Parameters
blockList The BlockList that we are visiting.
parent The BlockTarget that contains the supplied BlockList.

public boolean visitListStart (BlockList blockList, BlockTarget parent)

Invoked at the beginning of a BlockList.

Parameters
blockList The BlockList that we are visiting.
parent The BlockTarget that contains the supplied BlockList.
Returns
  • True if the Block List should traverse each of the elements of its list. If false, the list elements are not traversed.

public void visitScalarProperty (BlockProperty blockProperty, Block parent, boolean firstAssignedProperty)

Invoked for each scalar (non-Block, non-BlockList) Block Property. In particular, it is only invoked for BlockProperty instances whose value is non-null.

Parameters
blockProperty The BlockProperty that has an assigned value.
parent The Block that contains this BlockProperty.
firstAssignedProperty Whether or not this is the first assigned property of the Block.

Protected Methods

protected String getBlockInListElementName (Block block)

Returns the element name to use for a Block in a List.

Parameters
block The block being converted to XML.
Returns
  • The element name to use.

protected String getDocumentElementName (Block rootBlock)

Returns the element name to use for the document element.

Parameters
rootBlock The root block being converted to XML.
Returns
  • The element name to use.

protected String getNestedListElementName ()

Returns the element name to use for a BlockList which appears nested inside another BlockList.

Returns
  • The element name to use.