Property mapping script example

The following code listings of an XML document and XML property mapping script illustrate the scenario of mapping incoming XML values to properties of a Content Engine document class. The XML document to be stored in the Content Engine will have the "Email" document class applied to it. In the XML document, the e-mail-related data is labeled with "Sender", "Recipient", and "Subject" tags. In the "Email" document class, the same information is stored in properties with symbolic names of "From", "To", and "EmailSubject". The XML property mapping script extracts the incoming XML values and labels them with XML tags that correspond to the properties in the "Email" document class, as shown in the mapped output listing. The Content Engine transparently stores the XML output values as property values in the object store.

Note that in the input XML document, the "FileNetDocClass" processing instruction has the "Email Transform" value. In order for the XML property mapping script to be invoked, the administrator would have to create an XML Property mapping script object that has an XML Document Type property value of "Email Transform".

Input XML document

  <?xml version="1.0" encoding="UTF-8"?>
  <?FileNetDocClass Email Transform ?>
  <Email>
    <Sender>arafaelle@dalia.com</Sender>
    <Recipient>fevans@slateroofs.com</Recipient>
    <Subject>Request for Proposal</Subject>
  </Email>

XML property mapping script

  <xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform version="1.0">
    <!-- Output method -->
    <xsl:output method="xml" indent="yes"/>

    <!-- Match root element  -->
    <xsl:template match="/">
      <Email><xsl:apply-templates/></Email>
    </xsl:template>

    <xsl:template match="/Email/Sender">
      <From><xsl:value-of select="."/></From>
    </xsl:template>       

    <xsl:template match="/Email/Recipient">
      <To><xsl:value-of select="."/></To>
    </xsl:template> 

    <xsl:template match="/Email/Subject">	  
      <EmailSubject><xsl:value-of select="."/></EmailSubject>
    </xsl:template> 
  </xsl:stylesheet>

Mapped output

  <?xml version="1.0" encoding="UTF-8"?>
  <Email>
    <From>arafaelle@dalia.com</From>
    <To>fevans@slateroofs.com</To>
    <EmailSubject>Request for Proposal</EmailSubject>
  </Email>