Class XmlRendererBlockVisitorENF
- java.lang.Object
-
- com.microstrategy.web.blocks.DefaultBlockVisitor
-
- com.microstrategy.web.blocks.renderers.XmlRendererBlockVisitorENF
-
- All Implemented Interfaces:
BlockVisitor
- Direct Known Subclasses:
XmlRendererBlockVisitorANF
public class XmlRendererBlockVisitorENF extends DefaultBlockVisitor
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:
- 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. - Each of the properties defined for the root Block is evaluated in this
manner:
- 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.
- 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).
- 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".
- Since:
- MicroStrategy Web 9.0.0
-
-
Field Summary
Fields Modifier and Type Field Description protected BlockContextblockContextprotected XMLBuilderxmlBuilder
-
Constructor Summary
Constructors Constructor Description XmlRendererBlockVisitorENF(BlockContext blockContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringgetBlockInListElementName(Block block)Returns the element name to use for a Block in a List.protected java.lang.StringgetDocumentElementName(Block rootBlock)Returns the element name to use for the document element.protected java.lang.StringgetNestedListElementName()Returns the element name to use for a BlockList which appears nested inside another BlockList.java.lang.StringgetXML()Gets the XML generated as a String.voidvisitBlockEnd(Block block, BlockTarget parent)Invoked for each Block after all of its properties are visited.booleanvisitBlockStart(Block block, BlockTarget parent)Invoked for each Block before any of its properties are visited.booleanvisitCompositeProperty(BlockProperty blockProperty, Block parent, boolean firstAssignedProperty)Invoked for each composite (Block or BlockList) Block Property.voidvisitListEnd(BlockList blockList, BlockTarget parent)Invoked at the end of a BlockList.booleanvisitListStart(BlockList blockList, BlockTarget parent)Invoked at the beginning of a BlockList.voidvisitScalarProperty(BlockProperty blockProperty, Block parent, boolean firstAssignedProperty)Invoked for each scalar (non-Block, non-BlockList) Block Property.-
Methods inherited from class com.microstrategy.web.blocks.DefaultBlockVisitor
visitUnassignedProperty
-
-
-
-
Field Detail
-
xmlBuilder
protected XMLBuilder xmlBuilder
-
blockContext
protected BlockContext blockContext
-
-
Constructor Detail
-
XmlRendererBlockVisitorENF
public XmlRendererBlockVisitorENF(BlockContext blockContext)
-
-
Method Detail
-
visitBlockStart
public boolean visitBlockStart(Block block, BlockTarget parent)
Description copied from interface:BlockVisitorInvoked for each Block before any of its properties are visited.- Specified by:
visitBlockStartin interfaceBlockVisitor- Overrides:
visitBlockStartin classDefaultBlockVisitor- Parameters:
block- TheBlockbeing visited.parent- TheBlockTargetthat contains the supplied Block.- Returns:
- True if the Block should continue its traversal downward. If false,
then no properties are visited and traversal proceeds to
BlockVisitor.visitBlockEnd(Block, BlockTarget).
-
visitBlockEnd
public void visitBlockEnd(Block block, BlockTarget parent)
Description copied from interface:BlockVisitorInvoked for each Block after all of its properties are visited.- Specified by:
visitBlockEndin interfaceBlockVisitor- Overrides:
visitBlockEndin classDefaultBlockVisitor- Parameters:
block- TheBlockbeing visited.parent- TheBlockTargetthat contains the supplied Block.
-
visitScalarProperty
public void visitScalarProperty(BlockProperty blockProperty, Block parent, boolean firstAssignedProperty)
Description copied from interface:BlockVisitorInvoked for each scalar (non-Block, non-BlockList) Block Property. In particular, it is only invoked for BlockProperty instances whose value is non-null.- Specified by:
visitScalarPropertyin interfaceBlockVisitor- Overrides:
visitScalarPropertyin classDefaultBlockVisitor- Parameters:
blockProperty- TheBlockPropertythat has an assigned value.parent- TheBlockthat contains this BlockProperty.firstAssignedProperty- Whether or not this is the first assigned property of the Block.
-
visitCompositeProperty
public boolean visitCompositeProperty(BlockProperty blockProperty, Block parent, boolean firstAssignedProperty)
Description copied from interface:BlockVisitorInvoked for each composite (Block or BlockList) Block Property. In particular, it is only invoked for BlockProperty instances whose value is non-null.- Specified by:
visitCompositePropertyin interfaceBlockVisitor- Overrides:
visitCompositePropertyin classDefaultBlockVisitor- Parameters:
blockProperty- TheBlockPropertythat has an assigned value.parent- TheBlockthat 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.
-
visitListStart
public boolean visitListStart(BlockList blockList, BlockTarget parent)
Description copied from interface:BlockVisitorInvoked at the beginning of a BlockList.- Specified by:
visitListStartin interfaceBlockVisitor- Overrides:
visitListStartin classDefaultBlockVisitor- Parameters:
blockList- TheBlockListthat we are visiting.parent- TheBlockTargetthat 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.
-
visitListEnd
public void visitListEnd(BlockList blockList, BlockTarget parent)
Description copied from interface:BlockVisitorInvoked at the end of a BlockList.- Specified by:
visitListEndin interfaceBlockVisitor- Overrides:
visitListEndin classDefaultBlockVisitor- Parameters:
blockList- TheBlockListthat we are visiting.parent- TheBlockTargetthat contains the supplied BlockList.
-
getXML
public java.lang.String getXML()
Gets the XML generated as a String.- Returns:
- The String representation of the XML generated.
-
getDocumentElementName
protected java.lang.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.
-
getBlockInListElementName
protected java.lang.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.
-
getNestedListElementName
protected java.lang.String getNestedListElementName()
Returns the element name to use for a BlockList which appears nested inside another BlockList.- Returns:
- The element name to use.
-
-