Class 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:

    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".

    Since:
    MicroStrategy Web 9.0.0
    • Constructor Detail

      • XmlRendererBlockVisitorENF

        public XmlRendererBlockVisitorENF​(BlockContext blockContext)
    • Method Detail

      • 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 interface BlockVisitor
        Overrides:
        visitScalarProperty in class DefaultBlockVisitor
        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.
      • 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 interface BlockVisitor
        Overrides:
        visitCompositeProperty in class DefaultBlockVisitor
        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.
      • 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.