Skip to content

XAware Community

Get the Flash Player to see this player.
Flash Image Rotator Module by Joomlashack.
XAware 5.6
Need Help
Webinars and Events
Advanced Tutorials
Webinars and Events

You are here: Home arrow Forums
XAware Community Forums
Welcome, Guest
Please Login or Register.    Lost Password?
XML Mapping using cross Reference file. (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: XML Mapping using cross Reference file.
#5286
rvalle (User)
XAware user
Posts: 5
User Offline Click here to see the profile of this user
XML Mapping using cross Reference file. 10 Years, 9 Months ago Karma: 0  
I have a specific requirement to import data from an XML file into a MySql database. The XML file has elements with code values. The cross references codes are listed in another file. Before I can insert/update the database tables, these codes will need to be converted into a string that will then be input into database tables.

Is there a method within Xaware to read the XML file, lookup the code value and pass that value to the database or other XML file.? Just to clarify, not all of the composite elements are coded.

Example:
<Price>
<PriceTypeCode>01</PriceTypeCode>
<ClassOfTrade>BKS</ClassOfTrade>
<DiscountCoded>
<DiscountCodeType>02</DiscountCodeType>
<DiscountCode>BKS</DiscountCode>
</DiscountCoded>
<PriceAmount>9.95</PriceAmount>
</Price>

The XML file to read is also very large, at time over 2 MB and processing will seem to be heavy, perhaps a streaming component?

Can anybody suggest if i can achieve this using xaware.If yes please specify the method.

Thank you.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5292
voconnor (Admin)
Admin
Posts: 984
User Offline Click here to see the profile of this user
Re:XML Mapping using cross Reference file. 10 Years, 9 Months ago Karma: 8  
Hi,

I think we can help you. The XAware Lookup Translation Functoid allows you to create a XML-based lookup table that will transform fields to other string values. You can use this functoid provided you have done the following:

* generated a lookup table (this will contain your codes) and added it as a separate XML file in the xaware.home/conf folder (or copied it into the sample lookup file in that folder),
* added your lookup table alias to the xaware.home/conf/Aliases.properties file (see the example in that file for a demonstration),
* declared the functoid in the BizView file to act on static field values or values passed in by substitution

The sample lookup table is stored in xaware.home/conf/Lookup.xml and it demonstrates the structure you must duplicate for your own lookup tables.

You can see an example of the lookup translation functoid by selecting File|New|Examples|Transforming and choosing the Field Transformations with Functoids or JavaScript example.

It sounds as if you also need streaming information, and there are examples of streaming to be found by selecting File|New|Examples|Handling Large Data Sets and choosing the Streaming example.

Information about how to implement streaming and the lookup translation are in the help.

Good luck, and please let us know how it works!
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5316
rvalle (User)
XAware user
Posts: 5
User Offline Click here to see the profile of this user
Re:XML Mapping using cross Reference file. 10 Years, 9 Months ago Karma: 0  
Thank you very much for the details provided. I have just begun to learn Xaware and still in the beginning of the learning curve. Actualy 3/4 of the way in reading the documentation.

I opened the example lookup table and from what I can see is that the table is built for a simple structure where there is one level to map. The code list I will be using is a bit more complex.

The format is as follows:
The top-level tag is <ONIXCodeTable>.
The document contains a sequence of composite elements<CodeList>, each of which contains the data elements <CodeListNumber>, <CodeListDescription>and <IssueNumber>, and a sequence of composite elements <Code>.

Each composite element <Code>contains the data elements <CodeNumber>, <CodeValue>, <CodeDescription>, <CodeNotes> and <IssueNumber>.

Here is a sample:
<?XML version="1.0" encoding="utf-8"?>
<ONIXCodeTable>
<CodeList>
<CodeListNumber>1</CodeListNumber>
<CodeListDescription>Notification or update type code</CodeListDescription>
<IssueNumber>0</IssueNumber>
<Code>
<CodeNumber>1</CodeNumber>
<CodeValue>01</CodeValue>
<CodeDescription>Early notification</CodeDescription>
<CodeNotes>Use for a complete record issued earlier than approximately six months before publication.</CodeNotes>
<IssueNumber>0</IssueNumber>
</Code>
...
Will an additional process be required to further simplify the code lists and input the data to the lookup table?

For instance, in the sample below the composit <ProductIdentifier> has a child element <ProductIDType> with value 2. This value correlates to IBSN. Then there is a another iteration of the same element with value 03. This value correlates to IBSN13 and so on. How would the lookup table need to be formatted to handle the translation?

<ProductIdentifier>
<ProductIDType>02</ProductIDType>
<IDValue>0849955432</IDValue>
</ProductIdentifier>
<ProductIdentifier>
<ProductIDType>03</ProductIDType>
<IDValue>9780849955433</IDValue>
</ProductIdentifier>
<ProductIdentifier>
<ProductIDType>04</ProductIDType
<IDValue></IDValue>
</ProductIdentifier>
<ProductIdentifier>
<ProductIDType>15</ProductIDType>
<IDValue>9780849955433</IDValue>
</ProductIdentifier>

Attached is the code list for review.

Thanks in advance.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5317
rvalle (User)
XAware user
Posts: 5
User Offline Click here to see the profile of this user
Re:XML Mapping using cross Reference file. 10 Years, 9 Months ago Karma: 0  
Attached is the XML file with the code list for review.
File Attachment:
File Name: ONIX_BookProduct_CodeLists_Issue_10_XML.zip
File Size: 84867
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5324
prichards (Admin)
Admin
Posts: 319
User Offline Click here to see the profile of this user
Re:XML Mapping using cross Reference file. 10 Years, 9 Months ago Karma: 18  
The LookupTranslation Functoid included with XAware, reads an XML file in a specific format. If you just need to convert a code value such as '02' to its corresponding string representation such as 'ISBN-10', then you would need to reformat your XML CodeList into the file format for the lookup. The <CodeListNumber/> becomes the "map" in the XAware lookup file. The description <CodeListDescription/> and <CodeNotes/> can be added as attributes to the map/item (but are not accessible through the curent interface). I'm not sure if you are using <IssueNumber/>, but you don't mention it in your scenario. (You could use XAware to convert the XML.)

Another option is to write your own functoid that reads your current file format, to handle the nested structure and additional elements such as <IssueNumber/>. Our lookup translation reads the file once, and caches the data in a java hash table to improve efficiency over reading the file multiple times. Your solution could implement something similar (you can access the code in our SourceForge project).

Typically, our customers store large amounts of reference data in a database, which you could access through the SQL BizComp. The SQL lookup can often be included in the insert query (with a nested select and/or database function). Or you could implement a functoid that performs a database lookup and caches the data similar to the LookupTranslation functoid to prevent excessive queries.

Otherwise, you would need to access the file directly as a reference file. If you use an XAware component such as a BizDoc to read the file as input or a File BizComp, XAware will attempt to construct a JDOM document for the structure which might significantly impact performance, especially if it is reading the file each time. You might also write a custom functoid to parse the file in a more efficient manner, such as using a SAX parser, to find the appropriate value. But in any solution - XAware or not - which doesn't provide some sort of data caching of the code list values, may impact performance depending on the number of lookups and size of the file. (You could also break the file up into multiple files to decrease some of the read times.)

You might have to test if reading the file each time fits within your performance requirements.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Community Login

Get the Flash Player to see this player.
Flash Image Rotator Module by Joomlashack.
Commercial
Free Training
QuickStart Packages
Image 4 Title
Image 5 Title

Visit XAware.com