close

Filter

loading table of contents...

Site Manager Developer Manual / Version 2210

Table Of Contents

2.1 The BeanParser

The XML files used to configure CoreMedia CMS components are processed by the BeanParser, which is a basic part of the system. As such, it is used to

  • configure document views,

  • configure editor.

The BeanParser processes the XML files as follows:

  • For each XML element it tries to instantiate an object of a class, which is determined by a factory or via the class attribute. The object is created via Java Reflection and a zero-argument constructor.

  • If the XML element occurs inside another XML element, it tries to set the object created by the inner element on the object created by the outer element. For this, it calls a setter method and passes the object. The setter method may be named set<Element Name>(), add<ElementName>() or simply set() or add().

  • For each attribute of an element it calls a setter method on the object that was created when parsing the element start tag. The setter method may be named set<AttributeName>(), add<AttributeName>() or simply set() or add().

Example:

Assume the following XML file:

        <FirstElement class="com.example.FirstElement" attribute1="Ho">
    <SecondElement class="com.example.SecondElement" 
      attribute="Hi"/>
</FirstElement>
      

Example 2.1. Example of a BeanParser XML file


The BeanParser will execute the following steps:

  1. Create an instance of class com.example.FirstElement.

  2. Call setAttribute1("Ho") on that instance.

  3. Create an instance of class com.example.SecondElement.

  4. Call setAttribute("Hi") on that second instance.

  5. Call firstElement.setSecondElement(secondElement), that is, set the object created in step 3 on the object created in step 1.

Advanced features:

The class attribute has a special meaning as it determines the name of the class to instantiate objects from. For this attribute, no setter methods has to be defined inside the class.

The BeanParser works without an XML Document Type Definition (DTD), but in connection with a DTD, it makes use of ID and IDREF feature of the XML Parsers. The object, that has been created by the element with the IDREF attribute, is substituted by the object that is defined the corresponding ID attribute. Again, no setter methods have to be defined inside the involved classes.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.