Category: X-Path (page 1 of 2)

X-Path: How to get the previous node

Problem: In a loop in XSLT or on iterating items, the previous node of the current node is needed. Solution: The previous node is: preceding-sibling::*[1] The previous node of the previous node is:  preceding-sibling::*[2] …  

Using Date X-Path functions (since version 8.0.10505)

Problem: Calculate a date in a specific date/time format from X-Path (without using a datamodel). Solution: In example we need the date-time of yesterday, (current date minus 1 day). Step 1: The current date as UNIX time is delivered by the currentdate() function. currentdate() Step 2: The dateadjust() function shifts the date two days back. […]

Explaining the X-Path functions concat, mconcat and sconcat for concatenating strings:

1)      concat(<args>) concat is for scalar values. Examples: concat(´A´,´B´,´C´) à ‚ABC‘ XPath/To/List = { ‘A‘,‘B‘,‘C‘ } concat( XPath/To/List, ‘B‘) à  AB  (takes only first argument from list) 2)      mconcat(<args>) mconcat is for building combinations (multiple). Examples: mconcat(´A´,´B´,´C´) à  { ‘ABC‘ } XPath/To/List = { ‘A‘,‘B‘,‘C‘ } mconcat(´A´, XPath/To/List,´C´) à  { ‘AAC‘,‘ABC‘,‘ACC‘  } List1 = { […]

Summarize CSV – Columns to context – BMECAT

Problem: Several columns of CSV data shall be summarized to one XML node. CSV example data: MERKMAL_NAME1;MERKMAL_UNIT1;MERKMAL_VALUE1;MERKMAL_ORDER1; merkmalname1;merkmalunit1;merkmalvalue1;merkmalorder1; XML data after transformation: <FEATURE> <FNAME>merkmalname1</FNAME> <FUNIT>merkmalunit1</FUNIT> <FVALUE>merkmalvalue1</FVALUE> <FORDER>merkmalorder1</FORDER> </FEATURE> <FEATURE> <FNAME>merkmalname2</FNAME> <FUNIT>merkmalunit2</FUNIT> <FVALUE>merkmalvalue2</FVALUE> <FORDER>merkmalorder2</FORDER> </FEATURE> Solution: At the data model at context “FEATURE” the following function must be inserted: *[starts-with(name(.),’MERKMAL_NAME’)]. Now every node that starts with […]

X-Path with two conditions, where one condition is the position

Problem: Think of a tree, where multiple conditions and a position is needed to select the correct value. Solution: X-Path is able to process more than one condition ( […] ): ../../../ZRWE_CodeDefinition[@headerfieldName=’ItemTextTypeCode’ and @headerfieldValue='”insert::TypeCode”‘][1]/ZRWE_headerfieldCust1 Example:

Using split and index() function to assign index fields

Problem: A head field of an XML invoice document contains order numbers as a concatenated string by ‘ ‘, which are related to the items of the invoice. In example: The second item in the head field is BE11-07968, which means, that the second INVOICE_ITEM (line item) of the invoice is  referenced by the order […]

Explaining rearrangement and auto assign feature in transformer

Problem: Assume we have a purchase order with delivery parties on line item level. Each line item may have one or more different delivery parties. The destination system has only the ability to process a delivery party on head level. Therefore the purchase order has been already grouped by delivery parties on line item level […]

How to use transformer with dynamic X-Path Expression (join) by example : Transform EDIFACT allowances

The following example illustrates the tranformation of allowances in EDIFACT. Assume the following extract from an EDIFACT message: ALC+A+1++1+DI’ PCD+3:3.5′ MOA+8:-0.7′ TAX+7+VAT+++:::0+S’ ALC+A+1++1+DI’ PCD+3:3.5′ MOA+8:-2.1′ TAX+7+VAT+++:::7+S’ ALC+A+1++1+DI’ PCD+3:3.5′ MOA+8:-0.7′ TAX+7+VAT+++:::19+S’ ALC+A+1++1+DI’ PCD+3:3.5′ MOA+8:-0.7′ TAX+7+VAT+++:::25+S’ ALC+A+1++2+EAB’ PCD+3:5′ MOA+8:-0.97′ TAX+7+VAT+++:::0+S’ ALC+A+1++2+EAB’ PCD+3:5′ MOA+8:-2.9′ TAX+7+VAT+++:::7+S’ ALC+A+1++2+EAB’ PCD+3:5′ MOA+8:-0.97′ TAX+7+VAT+++:::19+S’ ALC+A+1++2+EAB’ PCD+3:5′ MOA+8:-0.97′ TAX+7+VAT+++:::25+S’ ALC+A+1++3+FA’ PCD+3:5′ MOA+8:-0.92′ TAX+7+VAT+++:::0+S’ ALC+A+1++3+FA’ […]

Count items / Sequencing items / Enumerating items

Problem: Sometimes there is a need of enumerating items, i.e. insert a sequence for the line items of  a purchase order. Solution for versions > 5.0.5886: Use the index() function -> see X-Path functions Solution for versions < 5.0.5886: The Cleaning workflow item can be used to enumerate the items by the following X-Path syntax: […]

X-Path wildcard extension for element name search (*)

ET-Connector provides a way for selecting data nodes by X-Path expressions with wildcards. Therefore, the wildcard character % is honoured in X-Path expressions. Example: Select all nodes (elements/children) starting with name “DAIMLER” The standard X-Path expression to select those elements would be: child::*[starts-with(name(.), ‘DAIMLER’) This is obviously tedious, and can be simply replaced by: /DAIMLER%

Older posts

© 2017 SCHAEFER B.S. GmbH / Erich-Steinfurth-Str. 6 - 10243 Berlin / +49 (0)30 9700386 - 0 / sales@schaefer-bs.com