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.

quarta-feira, 5 de março de 2014

Sterling B2B Integrator XML namespaces on maps


1) There are there ways to set namespace while using a Sterling maps for output XMLs

To use the different approaches first hit the XML element in cause and hit the tab namespace. On this exercise we are using the root element but this applies to any element.


  • Using a full namespace with prefixes on tags
Use this namespace should get the value of the namespace description string.
The namespace prefix must be defined



All elements children of the element in cause will get the prefix unless a new namespace is selected
The result is an XML with following structure

  • Using a full namespace without prefixes on tags
To achieve this is quite simple instead of setting the namespace description  on Use this namespace one should rather set the namespace prefix it self.

The result is an XML with prefix identification but without actually inserting it onto the XML tags.

  • Insert a default namespace
To insert the default namespace is as simple as not identifying any prefix on the map, although not that much intuitive... 


And result.



2) While reading the namespace can also be specified the image bellow shows how, any of the previous samples, could be read. Again for each tag there can be a correspondent namespace, and it can never be more than 1.


Hope this helps cheers!

segunda-feira, 24 de setembro de 2012

Tutorials - Using GitHub and EGit in Eclipse part 2

If you notice the title I'm mentioning using GitHub that's because it is my porpoise to also do some command line operations as well as explain the concepts behind GitHub.

Ok now that the EGit installation is complete is time to use to upload a project. So for starters its better to get good inside of GitHub working architecture. The first thing and one that was kind of hard for me to get is that we have a local repository and remote one. Now the tricky part is that we must always first make a commit to the local repository and only then you can push it to the remote one. What at first got me really confused is that in other SVN/CVS (like tortoise, which by the way O am not sure if still works like this been some years since last use it) systems you don't have to do this intermediary step. Once you've changed a file in you're local machine and you made a commit things woud go to the remote  repository.
I took this schema from Wikipedia and it represents quite well what's going on in a git repository. First you create a project (your working directory) then you have to create a repository by command line or by EGit (will show this bellow). By creating a repository now you will have an extra folder which is maintained by Git (it's actually a .Git folder)  and the block Index in the picture is an Head file in that folder. Now every time you make an add command the code/folders of your source will become staged, or a registry will be inserted in the Head file informing the changes you are about to do this way git keeps a track of your commits. Once you've done with staging you can commit by inserting a nice message on what you're actions were and finally push it to the remote server. The push will only be allowed your local repository is in sync with the remote one, so you might need to do a fetch command and check the differences and a pull to actually get those files that you don't have locally or that have been changed.



Maybe the first part would be better at the end I think you should re-read it after finishing the procedure. For the sake of completion I leave the images bellow on how to create the new project (standard Java on Eclipse...) to be under version control.





Now the EGit stuff comes into play, it is pretty straight forward wizard and allows to create the local repository. Pressing the second button over the project root folder on the Package Explorer window  you should be able to see Team and a Share option inside it.  This will open the wizard.



Select Git and on the next screen press create. This will show the folder where the repository will be created and the name you want to give to it.

Under the Project pane there is a checkbox if you leave it selected it will  make that your working directory to be transferred to the repository folder.
In the end you should get a project with an question mark over it's files meaning there are unstaged changes.
If you have installed the GitHub command line mode installed and you can get it like this for Ubuntu.

$ apt-get install git-core

Or for other systems check it here. It is possible to check the repository by navigating there using the command line. And you can see that there can be as many repositories as you want, also they can be connected to any number of online repos and even better you can have as many branches  as you want (that will be another tutorial). So you can see from my Terminal that I am navigating to Git folder where I have all my local repos stored if I run a git status outside a repo the output will be error but as soon as you are inside a repo git command immediately starts to make sense of it.

quarta-feira, 19 de setembro de 2012

Tutorials - Adding GitHub to Eclipse

To simplify life using GitHub one can recur to EGit a great tool that can make interaction with GitHub much more intuitive and integrated for those who like to work with IDE's instead of using the terminal!

You can find most of this tutorial on the EGit Eclipse page but I had some features of my own but allot of stuff is just plain copy paste.

Installing EGit into Eclipse

After downloading Eclipse (any version can be plugged with this feature) and start it go to preferences:

Select Install New Software. On the new screen type http://download.eclipse.org/egit/updates on the work with: TextBox.


Click Next and confirm your selection in the following window pressing Next again. Finally, accept the terms of license agreement and click Finish to start the installation. After the installation has finished, restart Eclipse to work with EGit.





EGit Configuration
Every commit in EGit will include the user's name and his email-address. These attributes can be set in the Preferences-window Window => Preferences. Navigate to Team => Git => Configuration and hit the New Entry... Button. Enter user.name as Key and your name as Value and confirm. Repeat this procedure with user.email and your email-address and click OK in the Preferences-window.

What else to do with this feature, this key-value pair?
Why not use it to store parameters for your workflow scripts? Here's some ideas.
  • The locations of CSS and JS files to be minified
  • Compilation output directory
  • The latest version release number (if your not a tag fan)
  • Feature branch meta data (owner, decription, etc.)
  • A list of deployment servers
More on this here.

So this finishes the installation and setup of EGit on Eclipse (well not really because we still need to push files to the SVN server on this case GitHub and this requires configurations on both sides).

Next tutorials will be more interesting as I am describing some concepts of git that normally are confusing at the beginning.