18.4 Populating Repeating Attributes using Automatic Property Extraction

Let us create a template file that allows content creators to enter names of multiple books as well as the names of their authors in a repeating block.

We will develop a custom XML Application that will populate the authors multi-valued repeating property of a document with the names of authors entered in the Template file.

  1. Create and import a template in Web Publisher (say Second_XMLApp_Template.xml) and attach it to dm_document object type with Default Lifecycle. The Template file Second_XMLApp_Template.xml follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <BOOK>
    <REPEATBLOCK>
    <BOOKNAME/>
    <AUTHORNAME/>
    </REPEATBLOCK>
    </BOOK>
    

    Create a Rules file (say Second_XMLApp_TemplateRule.xml) for the above template and associate the Template file with this Rules file. The Rules file Second_XMLApp_TemplateRule.xml follows:

    <?xml version="1.0" encoding="UTF-8"?>
    <rules>
    <tagcontent tag_name="BOOKNAME">
    <textline charlength="100" instruction="Please provide the name of the
    book" label="Book Name">
    </textline>
    </tagcontent>
    <tagcontent tag_name="AUTHORNAME">
    <textline charlength="100" instruction="Please provide the name of the
    author" label="Author Name">
    </textline>
    </tagcontent>
    <repeatdef instruction="Provide as many values as you want"
    label="repeating block for books and authors" tag_list="REPEATBLOCK">
    </repeatdef>
    </rules>
    
  2. Create an XML configuration file SecondXMLApp.xml and provide the name of the XML configuration file (without the .xml) in the Category field of the template Second_XMLApp_Template.xml. This sets the a_category attribute of the template.

    The SecondXMLApp.xml file is shown below:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application SYSTEM "config_5.2.dtd">
    <application>
    <name>SecondXMLApp</name>
    <app_pattern>
    <element>BOOK</element> <!-- Specifying the XML Root element BOOK-->
    </app_pattern>
    <map_rules>
    <xml_content_rule>
    <element_selection_pattern>
    <element>BOOK</element>
    </element_selection_pattern>
    <variables> <!-- Defining variable to map values in object attribute authors-->
    <variable>
    <name>authorName</name> <!--Getting the value of AUTHORNAME template element -->
    <content_of_element>
    <element_selection_pattern>
    <element>AUTHORNAME</element>
    </element_selection_pattern>
    </content_of_element>
    </variable>
    </variables>
    <object_type>dm_document</object_type> <!-- Specifying the object type -->
    <metadata>
    <dctmattr_repeating>
    <name>authors</name> <!-- Saving value in authors repeating attribute-->
    <template><var name="authorName"/></template>
    </dctmattr_repeating>
    </metadata>
    <make_entity/>
    </xml_content_rule>
    </map_rules>
    </application>
    

    <dctmattr_repeating>: Sets the value of a multi-valued (repeating) Documentum object property.

    Here, we have set the value of the authors multi-valued property through the variable authorName.

    The variable authorName captures the multiple values entered by content creators in the AUTHORNAME repeating element in the Template file.

  3. Complete all the required steps for configuring this XML Application, exactly the same way that we did for our first XML Application.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.142.141