Examples for processing orders in an XML file

This topic contains examples of XML input files, XPath expressions, XSLT style sheets, and RICOH ProcessDirector overrides files produced by the XSLT style sheets. These examples work with the usage scenario for processing orders in an XML file.

XML input file

<?xml version="1.0" encoding="utf-8"?>
<seller id="000364">
  <order number="00060310">
      <customername>Metropolis Real Estate</customername>
      <shipto>
           <address1>100 Main St</address1>
           <address2>></address2>
           <city>Metropolis</city>
           <state>OH</state>
           <zip_code>45416</zip_code>
      </shipto>
      <item number="001">
            <printfile>http://www.metropolishomeexperts.com/brochures/br096.pdf</printfile>
            <quantity>10</quantity>
      </item>
      <item number="002">
            <printfile>http://www.metropolishomeexperts.com/posters/po014.pdf</printfile>
            <quantity>5</quantity>
      </item>
      <item number="003">
            <stock number="mug036"></stock>
            <quantity>5</quantity>
      </item>
  </order>
  <order number="00060311">
      <customername>Town Point Realty</customername>
      <shipto>
           <address1>450 Broadway</address1>
           <address2>Suite 12</address2>
           <city>Parkview</city>
           <state>IL</state>
           <zip_code>60404</zip_code>
      </shipto>
      <item number="001">
           <printfile>http://http://www.townpointrealty.com/print/0196.pdf</printfile>
           <quantity>20</quantity>
      </item>
      <item number="002">
            <stock number="cap0342"></stock>
            <quantity>10</quantity>
      </item>
  </order>
</seller>

Note: To keep the sample XML input file from causing errors in the DownloadFile step, substitute URLs to print files at your website for the URLs in the sample.

First Xpath expression

/seller/order

XML files created for jobs

Order number 00060310
<?xml version="1.0" encoding="UTF-8"?>
<order number="00060310">
      <customername>Metropolis Real Estate</customername>
      <shipto>
           <address1>100 Main St</address1>
           <address2>></address2>
           <city>Metropolis</city>
           <state>OH</state>
           <zip_code>45416</zip_code>
      </shipto>
      <item number="001">
            <printfile>http://www.metropolishomeexperts.com/brochures/br096.pdf</printfile>
            <quantity>10</quantity>
      </item>
      <item number="002">
            <printfile>http://www.metropolishomeexperts.com/posters/po014.pdf</printfile>
            <quantity>5</quantity>
      </item>
      <item number="003">
            <stock number="mug036"/>
            <quantity>5</quantity>
      </item>
  </order>
Order number 00060311
<?xml version="1.0" encoding="UTF-8"?>
<order number="00060311">
      <customername>Town Point Realty</customername>
      <shipto>
           <address1>450 Broadway</address1>
           <address2>Suite 12</address2>
           <city>Parkview</city>
           <state>IL</state>
           <zip_code>60404</zip_code>
      </shipto>
      <item number="001">
           <printfile>http://www.impactonthenet.com/buildsales.pdf</printfile>
           <quantity>20</quantity>
      </item>
      <item number="002">
            <stock number="cap0342"/>
            <quantity>10</quantity>
      </item>
  </order>

XSLT style sheet for first ApplyXSLTransform step

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0">
    <xsl:output method="text" encoding="UTF-8"/>
    <xsl:template match="/">
        <xsl:variable name="var1_initial" select="."/>
        <xsl:for-each select="order">
            <xsl:variable name="var2_current" select="."/>
            <xsl:value-of select="concat('Job.Info.Attr1=', @number, '&#10;', 'Job.CustomerName=', customername)"/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Overrides files created by first ApplyXSLTransform step

Order number 00060310
Job.Info.Attr1=00060310Job.CustomerName=Metropolis Real Estate
Order number 00060311
Job.Info.Attr1=00060311Job.CustomerName=Town Point Realty

Second XPath expression

/order/item/printfile/ancestor::item

XML files created for print item jobs

When the XML input file contains order number 00060310, RICOH ProcessDirector creates these XML files.

Item 001
<?xml version="1.0" encoding="utf-8"?>
<item number="001">
     <printfile>http://www.metropolishomeexperts.com/brochures/br096.pdf</printfile>
     <quantity>10</quantity>
</item>
Item 002
<?xml version="1.0" encoding="utf-8"?>
<item number="002">
     <printfile>http://www.metropolishomeexperts.com/posters/po014.pdf</printfile>
     <quantity>5</quantity>
</item>

Third XPath expression

/order/item/stock/ancestor::item

XML file created for promotional item job

When the XML input file contains order number 00060310, RICOH ProcessDirector creates this XML file.

<?xml version="1.0" encoding="utf-8"?>
<item number="003">
     <stock number="mug036"/>
     <quantity>5</quantity>
</item>

XSLT style sheet for second ApplyXSLTransform step (print items)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0">
    <xsl:output method="text" encoding="UTF-8"/>
    <xsl:template match="/">
        <xsl:variable name="var1_initial" select="."/>
        <xsl:for-each select="item">
            <xsl:variable name="var2_current" select="."/>
            <xsl:value-of select="concat('Job.DownloadFile=', printfile, '&#10;', 'Job.Copies=', quantity)"/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Overrides files created by second ApplyXSLTransform step

Item 001
Job.DownloadFile=http://www.metropolishomeexperts.com/brochures/br096.pdfJob.Copies=10
Item 002
Job.DownloadFile=http://www.metropolishomeexperts.com/posters/po014.pdfJob.Copies=5

XSLT style sheet for third ApplyXSLTransform step (promotional items)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0">
    <xsl:output method="text" encoding="UTF-8"/>
    <xsl:template match="/">
        <xsl:variable name="var1_initial" select="."/>
        <xsl:for-each select="item">
            <xsl:variable name="var2_current" select="."/>
            <xsl:value-of select="concat('Job.Info.Attr2=', stock/@number, '&#10;', 'Job.Copies=', quantity)"/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Overrides file created by third ApplyXSLTransform step

Job.Info.Attr2=mug036Job.Copies=5