sexta-feira, 7 de março de 2014

Sterling B2B Integrator Map EDI/XML EDIFACT CONTRL to XML

This is a visual guide for beginners to have a reference on how to generate a map that allows to convert an EDI document to XML.

Start by going through the map wizard. The map was name FROM_EDI_CONTRL_TO_XML.

Input side is the standard.

Code lists are imported so it uses the standard defined codes and validate them with Standard Rules. 




The standard is CONTRL


XML on the output side. There is no schema so the xml structure will have to be built on the map.




Expand to display all input side.

Enable message response.

Enable action code.


Change output name to contrl.






Create first child element.







For each element one must set the PCDATA, the XML structure in maps work as schema definitions.



Use Insert so it places the new element bellow.

Proceed as before for remaining elements.




This corresponds to a repeating segment, a particle is set in place, the three types mean for Choice only element can only have one children with value, Sequence all values should be present and following in the same order as displayed in map and finally All that is the same to say there are no rules. Particles are the equivalent of the complex type functions on schema.



Generate remaining elements under the particle




Turn on the LINE Mode and this way connectors will be available.
Connect EDI elements with XML PCDATA just by clicking on the left side and then click again on the target on the XML output.


Save the map and compile it (button next of the save icon).
A correct compilation should look like that.
The new file definition can be stored and reused on other maps if required.

Finally test the map and check results.





















































quinta-feira, 6 de março de 2014

Sterling B2B Integrator XPath and namespace

The are two ways to handle namespaces on Sterling, using a registered prefix or specifying on the XPath the namespace URI.

To work with default namespace there is no other option rather then using XPath URI.

If the namespace uses prefix using XPath URI can be quite tricky for complex queries so you might think about just registering the namespace to avoid extra complexity on the XPath queries. The procedure to register a namespace is described bellow.

Having the following code has an XML


XPath

//*[local-name()='some_content1']/text()

Result in Sterling

text some_content1 testnamespace1text some_content1 testnamespace2

Result in http://www.xpathtester.com/xpath
text some_content1 testnamespace1 text some_content1 testnamespace2

XPath

(//*[local-name()='some_content1'])[1]/text()

Result

text some_content1 testnamespace1

XPath

//*[local-name()='some_content1' and namespace-uri()='www.testnamespace1.com']/text()

Result

text some_content1 testnamespace1

XPath

//*[local-name()='some_content2' and namespace-uri()='www.testnamespace1.com']/*[local-name()='another_content' and namespace-uri()='www.testnamespace1.com']/text()

Result

text another_content

BPML of test_xml_namespace


Results on Process Data



  • To update you're namespace on Sterling you need to edit the namespace.properties file and add a new entry as following:


## PROPERTY_START
## PROPERTY_NAME: test1
## PROPERTY_TYPE: String
## PROPERTY_DESCRIPTION
##
test1 = www.testnamespace1.com
## PROPERTY_END

## PROPERTY_START
## PROPERTY_NAME: test2
## PROPERTY_TYPE: String
## PROPERTY_DESCRIPTION
##
test2 = www.testnamespace2.com
## PROPERTY_END

And run ./opscmd.sh -cREFRESHNAMESPACES -nnode1
There might be some errors but normally it should work.

Testing against an XML with prefixes


XPath

root/test2:test/test2:some_content1/text()

Result

text some_content1 testnamespace2

XPath

root/test1:test/test1:some_content1/text()

Result

text some_content1 testnamespace1

BPML of test_xml_namespace updated


Results on Process Data

Bottom line is to register namespace while dealing with prefix otherwise stick to XPath local names and URIs.