Esempi per l'elaborazione di ordini in un file XML

Questo argomento contiene esempi di file di input XML, espressioni XPath, fogli di stile XSLT e file di sovrascrittura di RICOH ProcessDirector prodotti dai fogli di stile XSLT. Questi esempi funzionano con lo scenario di utilizzo per l'elaborazione di ordini in un file XML.

File di input XML

<?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>

Nota: Per impedire che il file di input XML di esempio provochi errori nell'operazione DownloadFile, sostituire gli URL per la stampa dei file nel proprio sito Web con gli URL dell'esempio.

Prima espressione Xpath

/seller/order

File XML creati per i lavori

Numero d'ordine 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>
Numero d'ordine 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>

Foglio di stile XSLT per la prima operazione ApplyXSLTransform

<?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, '
', 'Job.CustomerName=', customername)"/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

File di sovrascrittura creati dalla prima operazione ApplyXSLTransform

Numero d'ordine 00060310
Job.Info.Attr1=00060310Job.CustomerName=Metropolis Real Estate
Numero d'ordine 00060311
Job.Info.Attr1=00060311Job.CustomerName=Town Point Realty

Seconda espressione XPath

/order/item/printfile/ancestor::item

File XML creati per i lavori degli elementi di stampa

Quando il file di input XML contiene il numero d'ordine 00060310, RICOH ProcessDirector crea questi file XML.

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

Terza espressione XPath

/order/item/stock/ancestor::item

File XML creato per il lavoro degli elementi promozionali

Quando il file di input XML contiene il numero d'ordine 00060310, RICOH ProcessDirector crea questo file XML.

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

Foglio di stile XSLT per la seconda operazione ApplyXSLTransform (elementi di stampa)

<?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, '
', 'Job.Copies=', quantity)"/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

File di sovrascrittura creati dalla seconda operazione ApplyXSLTransform

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

Foglio di stile XSLT per la terza operazione ApplyXSLTransform (elementi promozionali)

<?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, '
', 'Job.Copies=', quantity)"/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

File di sovrascrittura creati dalla terza operazione ApplyXSLTransform

Job.Info.Attr2=mug036Job.Copies=5