Back in 2015, ONIXEDIT released version 3.1.6 with the first implementation of XPATH columns to our generic flat files and Excel export tool. XPATH stands for XML Path Language. XPATH uses "path like" syntax to identify and navigate nodes in an XML document.
When we released version 3.1.6, our goal was to provide a very precise way to export a specific value among repetitive records. For instance, if an ONIX title has many different SupplyDetail records and for each, many different prices, defining an XPATH column is the way to go to export a specific currency price from a specific supplier. For instance, consider this ONIX snippet:
<SupplyDetail>
<SupplierName>ONIXEDIT</SupplierName>
<ProductAvailability>21</ProductAvailability>
<Price>
<PriceTypeCode>01</PriceTypeCode>
<PriceAmount>6.99</PriceAmount>
<CurrencyCode>CAD</CurrencyCode>
</Price>
<Price>
<PriceTypeCode>01</PriceTypeCode>
<PriceAmount>4.99</PriceAmount>
<CurrencyCode>USD</CurrencyCode>
</Price>
</SupplyDetail>
If you want to export the USD price from Supplier ONIXEDIT, there is only one way you can be sure to get it no matter how many suppliers and prices are defined. It is with the help of this XPATH expression:
//Product/SupplyDetail[SupplierName='ONIXEDIT']/Price[CurrencyCode='USD']/PriceAmount
With the new ONIXEDIT version 3.4.8, we push usage of XPATH columns to the top with the implementation of a new XPATH 3.1 compliant engine. With it, you can now define IF THEN ELSE conditional expressions as well as FOR loop.
Here's an example of a complex XPATH 3.1 expression...
Consider that you want to export book dimension columns standardized to "mm" units. You know that ONIX support "mm" but also "cm" and "in" as Unit code for Height, Width and Thickness. Consequently, the following dimensions definition is perfectly possible and valid, although not likely:
To ensure you will always export "mm", you will create an XPATH column for each dimension value in your ONIXEDIT Export Script. This one is for the Height ([MeasureType="01"]):
if(//Product/DescriptiveDetail/Measure[MeasureType="01"]/MeasureUnitCode="mm")
then //Product/DescriptiveDetail/Measure[MeasureType="01"]/Measurement
else if(//Product/DescriptiveDetail/Measure[MeasureType="01"]/MeasureUnitCode="cm")
then (number(//Product/DescriptiveDetail/Measure[MeasureType="01"]/Measurement) * 10)
else if(//Product/DescriptiveDetail/Measure[MeasureType="01"]/MeasureUnitCode="in")
then (number(//Product/DescriptiveDetail/Measure[MeasureType="01"]/Measurement) * 25.4)
else 'INVALID UNIT'
Notice the usage of function "number" to convert the ONIX string value to its corresponding numerical value that is then multiplied by the conversion factor.
The following screen capture from our Generic Export Tool, is the result you will get:
For more details about XPATH Expression usage with ONIXEDIT, visit our online user manual here.
For those who are new to ONIX, hurry up and register at our website to grab your free trial copy of ONIXEDIT Pro. You will get everything that you need to try our new XPATH engine...
Have fun!