Using the XML Wizard

In Version 2.2.0.41 the ability to open and parse XML data natively was added.  An XML Wizard was also created to speed up the initial map design from the raw XML data.

XML data consists of Tags in a Text file.  The tags start with < and end with >.  Each tag comes in pairs.  One is the beginning tag and the other is the ending tag.  The ending tag start with </ instead of <.  Examples of an XML tag pair is

<currency>USD</currency>

XML is case sensitive. XML data can contain nested tags and multiple instances of tag pairs.  XML data can also contain attributes.  Attributes are sections of text that are contained in the beginning Tag and are in Attribute/Value pairs.  The Value of an attribute is always contained in Double Quotes.

An example of an Attribute is

AccountCode="257309" ClientAddressLine1="Homer Simpson 0"

The XML Parser handle both of the above.

Before Mapping XML data you will still need to review the XML data in an XML viewer such s XML Notepad (Microsoft) or some other XML viewer.  You will need an idea of what each XML tag or attribute represents.

XML Wizard

To start the XML Wizard open the RPMapper program and select the data menu and then XML Wizard.

 xml_1.png

If the map has not been saved then you will be asked to confirm your decision not to save the map.

xml_2.png 

Select Yes to return to the mapper to save the current map or No to continue to the Wizard.

 xml_3.png

The tabs across the top are for information.  Do not use them to move around.  Use the Arrow buttons instead.

The First step is to select the XML file to parse.  This XML file should contain a representative sample of the XML data.  Use the smallest sample set of data that contains all the tags and attributes.  If the data does not contain all the tags and attributes then they will not be parsed in the final set.  This will not produce an error but the tags or attributes that are missing from the sample data will not be parsed in the actual data later.

Enter the file or Select by clicking the Browse Button.  One the file is selected click the Next Arrow button.

xml_4.png 

Click the Parse XML button.  This will parse the XML and move to the Select Document Tag window.

 xml_5.png

This displays all the tags in the document with the count of the number of instances.  It also shows the tags in the Data structure.  As seen above the Invoice tag is below the invoicelist tag which is below the dataroot tag. 

Select the tag that would best represent a document.  Since the invoice tag has 33 instances in the xml file and contains data that is consistent with an invoice, it will be selected.  Once selected click the Next arrow button. 

This will move you to the Select Details window and display a list of tags under the select document tag. 

 xml_6.png

Look through the list of tags and find the tags that represent details.

 xml_7.png

In the Example shown above the message tag, aritem tag and asset tag appear to represent detail.  Select the tag (one at a time) and click the Add button (+). 

 xml_8.png

When finished click the Next Arrow Button.  This will move to the Select Fields window and display the message:

 xml_9.png

Click OK and depending on the size of the XML datafile you may have to wait for the parse.  Once parsed you will see the number of Documents and the tags within the document.  It there are any attributes they will be displayed in Green with an A: at the beginning of the name.

 xml_10.png

As you select a tag or an attribute you will see the value displayed in the data window at the bottom.  If the tag contains multiple instance they the Rep # x of Y will show a value other than 1 in the of Y.

As an example look at the aritem Item_description tag.  When selected it shows 1 of 14 because in the 1st document there are 14 instances of the aritem>>item_description tag.  As you change the Rep # you will see the data change.

You can also change the document number to move through all the available documents.

 xml_11.png

This window will also allow you to add fields and main section variable definitions.  To add a Single field select the desired tag or attribute and click the Add Field button (+ Fld).  This will display the Edit Fields form with the appropriate data filed in automatically.

 xml_12.png

Notice that eh XML entries contain a Node, Attribute, Delimiter, and Length entry areas.  The Node contain the node path.  The node path tells the system how to find the desired node.  Each tag is separated from its parent with >>.  The Attribute is the selected attribute of the selected node.

Once the node and attribute are found, all the data is returned by the system unless the delimiter and/or the length is provided.  A length of 0 and delimiter of blank will return all the data.  If a length is provided then the returned data contains at most the specified number of characters.  If a delimiter is specified then the data is returned up to the specified delimiter.  If both delimiter and length are specified then the data is returned to the delimiter and then the maximum specified characters are returned.

Edit the displayed entries as desired just as any other field.

Multiple fields may be selected by holding the control key and selecting the field.  Then click the Add Field button to add the fields in a Group.

 xml_13.png

 xml_14.png

This displays the Group field edit form.  As each field is selected in the List of Fields the information about the field will be displayed.  Edit these as desired and click the Save arrow button (<-) to store the data.

 xml_15.png

When finished with the field group click the OK button.

Fields are displayed with a Gray background.  Double-click on the Field to edit.  Select the field and click the Delete button (X) to delete.

To add a Variable select the tag or attribute and click the Add Var button (+Var).  This displays the edit variable form.  Edit the variable as desired and click Ok to save.

 xml_16.png

To add multiple variables use the control key and select the desired tags and click the Add Var button.

This displays the Edit variable form.  The values selected will be used for all the variables (except the Node, Attribute and variable Name).  Click ok when finished.

Double Click on a variable to edit and select the variable and click the delete button to delete.

Variable are in an Aqua background.

 xml_17.png

If you create a field or variable from a tag or attribute that contains multiple instances then you may use the Occurrence radio buttons to set the occurrence desired.

As an example aritem>>Item_description occurs 14 times in document 1.

 When you select the tag and click the Add Field button you will see the edit fields form.  The Occurrence defaults to First.  You may select first, Last, or Position. First will use the first occurrence of the tag or attribute.  Last will use the Last occurrence,  Pos will select the desired value (0 and 1 are the same as first).

 xml_18.png

When all the fields and variables are selected click the Next Arrow button to move to details.

This window displays the details as selected earlier.  You can move from document to document, Select the desired detail section (as defined earlier) and select the desired repetition of the tag or attribute within the detail for the selected document.

 xml_20.png

In the above we are looking at document 1, detail section 1 and repetition 1 of the detail section.  Even if the document does not contain the detail area it will display here but no data will be returned.

xml_21.png

Changing the detail # will change to the next detail section.  In the above the 2nd detail section is aritem and contains 14 repetitions. 

As before you can select one or More tags or attributes and click the Add Var button to add the variables.  Detail sections do not contain fields.  The recommended process is to select the tags and attributes that are the same type and create them together.  That means select the tags that represent text data and click Add Variable.  Then select the tags that represent dates and click Add Variable, etc.

When finished click the Next Arrow button.

You can move back to any page by using the Arrow buttons.  Do not use the tabs.

On the last page you can create the map and open the data.

 xml_22.png

 xml_23.png

Click Yes to create the map.

When the map is opened you will see the data area contains the words “XML No Display” .  The XML is displayed in the XML Data tab.

xml_24.png 

 xml_25.png

The command area contains all the field and variable definitions from the Wizard.

The Detail definitions were created from the selected nodes.

 xml_26.png

 

 xml_27.png

xml_28.png

Change the Output display areas to the desired output areas.

 xml_29.png

The detail was created with no increment.  Set the increment if desired or increment manually in the Detail section.

 xml_30.png

 Sorting can also be done in the mapper.  Specify the tags and order for Sorting.

 xml_31.png

 xml_32.png

 xml_33.png

The Define Input Page command contains the XML setting for Document.

 xml_34.png

If changes are necessary this is where it is changed.

The XML data display shows the XML from the currently selected document.  Not all documents contain all the tag and attributes.  In particular the Detail information is displayed as it is in the original data file.  If the document contains 14 aritem>>Item_description tags then all 14 will be displayed. 

 xml_35.png

To add additional field or variable select the desired tag or attribute and right click to display a popup menu.

 xml_36.png

Select Define Field to define a Field or Group of Fields.

 xml_37.png

Select Define Variable to define a variable for the Main or Detail section.

 xml_38.png

 

Currently the Conditional Field menu does not work.

You can also click the Desired tag or attribute and click the Add Command button (+) on Doc, Disp, or Det areas.

When you add the Field or Variable select XML from the type list and then Click the Retrieve button to retrieve the appropriate tag and attribute names.  You can also manually enter the values.

 xml_39.png

 xml_40.png

Now that the Fields and Variables are defined you can map the XML as you would any other document type.

 xml_41.png

0 Comments

Article is closed for comments.
Powered by Zendesk