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 BlockContext
blockContext
protected XMLBuilder
xmlBuilder
-
Constructor Summary
Constructors Constructor Description XmlRendererBlockVisitorENF(BlockContext blockContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
getBlockInListElementName(Block block)
Returns the element name to use for a Block in a List.protected java.lang.String
getDocumentElementName(Block rootBlock)
Returns the element name to use for the document element.protected java.lang.String
getNestedListElementName()
Returns the element name to use for a BlockList which appears nested inside another BlockList.java.lang.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.-
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:BlockVisitor
Invoked for each Block before any of its properties are visited.- Specified by:
visitBlockStart
in interfaceBlockVisitor
- Overrides:
visitBlockStart
in classDefaultBlockVisitor
- Parameters:
block
- TheBlock
being visited.parent
- TheBlockTarget
that 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:BlockVisitor
Invoked for each Block after all of its properties are visited.- Specified by:
visitBlockEnd
in interfaceBlockVisitor
- Overrides:
visitBlockEnd
in classDefaultBlockVisitor
- Parameters:
block
- TheBlock
being visited.parent
- TheBlockTarget
that contains the supplied Block.
-
visitScalarProperty
public void visitScalarProperty(BlockProperty blockProperty, Block parent, boolean firstAssignedProperty)
Description copied from interface:BlockVisitor
Invoked 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:
visitScalarProperty
in interfaceBlockVisitor
- Overrides:
visitScalarProperty
in classDefaultBlockVisitor
- Parameters:
blockProperty
- TheBlockProperty
that has an assigned value.parent
- TheBlock
that 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:BlockVisitor
Invoked for each composite (Block or BlockList) Block Property. In particular, it is only invoked for BlockProperty instances whose value is non-null
.- Specified by:
visitCompositeProperty
in interfaceBlockVisitor
- Overrides:
visitCompositeProperty
in classDefaultBlockVisitor
- Parameters:
blockProperty
- TheBlockProperty
that has an assigned value.parent
- TheBlock
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.
-
visitListStart
public boolean visitListStart(BlockList blockList, BlockTarget parent)
Description copied from interface:BlockVisitor
Invoked at the beginning of a BlockList.- Specified by:
visitListStart
in interfaceBlockVisitor
- Overrides:
visitListStart
in classDefaultBlockVisitor
- Parameters:
blockList
- TheBlockList
that we are visiting.parent
- TheBlockTarget
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.
-
visitListEnd
public void visitListEnd(BlockList blockList, BlockTarget parent)
Description copied from interface:BlockVisitor
Invoked at the end of a BlockList.- Specified by:
visitListEnd
in interfaceBlockVisitor
- Overrides:
visitListEnd
in classDefaultBlockVisitor
- Parameters:
blockList
- TheBlockList
that we are visiting.parent
- TheBlockTarget
that 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.
-
-