• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Converting XML into legacy record layout

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
I need to convert some XML files into legacy format record layout. For example legacy record layout may look like this(delimeterd by '|'):
100|First Name|Last Name|Address
200|20021231|12:59 PM|Purchase|Credit Card
300|3735******|1023
Can any one suggest how I can do this? One option I am thinking is writing a Java program to parse the file and write out each element as it encounters, but this does not sound like the best solution.
Thanks
Suresh
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can set the output method to text in your XSL - for e.g.
<xsl utput method="text"/>
Then use <xsl:for-each> to iterate over each XML node that represents the record and output the content.
Please provide with your sample XML so that we can help you better.
Thanks
Ritu
 
Suresh Kanagalingam
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Ritu. When you say 'set the output method..' where do I set the output method? Can you explain in detail. Also I have attached a sample XML here.
Thanks in advace.
Suresh

(code tag supplied)
[ November 13, 2002: Message edited by: Mapraputa Is ]
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pretty hard to read the XML that way, with no indentation and no DTD. Could you use the UBB "CODE" tags to indent it?
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You set the output method exactly as Rita showed:
<xsl:output method="text"/>
Put this somewhere at the top level of your XSL stylesheet (that is, as a child of the
<xsl:stylesheet> element).
[ November 13, 2002: Message edited by: Ron Newman ]
 
Suresh Kanagalingam
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the XML with UBB code
<?xml version = "1.0" encoding = "UTF-8"?>
<MessageSet xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "message.xsd" Version = "1.0">
<Message>
<MessageCreate>
<Date>20010701</Date>
<Time>121212</Time>
<Source Participant = "D">
<DlrCode>9000</DlrCode>
</Source>
<Target Participant = "F">
<MgmtCode>DDD</MgmtCode>
</Target>
</MessageCreate>
<Network NtwrkID = "TEST">
<Date>20010701</Date>
<Time>121213</Time>
</Network>
<MessageType>
<Request SourceID = "200107011212121" MessageID = "0000001">
<ClerkID>JOE</ClerkID>
<Account>
<AcctLookup>
<DlrLookup>
<AcctDesignation>2</AcctDesignation>
<AcctType>01</AcctType>
<DlrCode>9000</DlrCode>
<DlrAcctID>12345678910</DlrAcctID>
</DlrLookup>
</AcctLookup>
</Account>
<BusProcess>
<AddModAddress>
<Address AddressCode="2">
<AddressLine>12 MY AVE</AddressLine>
<City>MY CITY</City>
<ProvState>ON</ProvState>
<Country>CAN</Country>
<PostalZip>M3J5R5</PostalZip>
</Address>
<TaxCode>ON</TaxCode>
</AddModAddress>
</BusProcess>
</Request>
</MessageType>
</Message>
<Message>
<MessageCreate>
<Date>20010701</Date>
<Time>121212</Time>
<Source Participant = "D">
<DlrCode>9000</DlrCode>
</Source>
<Target Participant = "F">
<MgmtCode>DDD</MgmtCode>
</Target>
</MessageCreate>
<Network NtwrkID = "TEST">
<Date>20010701</Date>
<Time>121213</Time>
</Network>
<MessageType>
<Request SourceID = "200107011212122" MessageID = "0000002">
<ClerkID>JOE</ClerkID>
<Account>
<AcctLookup>
<DlrLookup>
<AcctDesignation>2</AcctDesignation>
<AcctType>01</AcctType>
<DlrCode>9000</DlrCode>
<DlrAcctID>12458963342</DlrAcctID>
</DlrLookup>
</AcctLookup>
</Account>
<BusProcess>
<AddModAddress>
<Address AddressCode="2">
<AddressLine>12 HER STREET</AddressLine>
<City>HER CITY</City>
<ProvState>ON</ProvState>
<Country>CAN</Country>
<PostalZip>L5M8U7</PostalZip>
</Address>
<TaxCode>ON</TaxCode>
</AddModAddress>
</BusProcess>
</Request>
</MessageType>
</Message>
<Message>
<MessageCreate>
<Date>20010701</Date>
<Time>121212</Time>
<Source Participant = "D">
<DlrCode>9000</DlrCode>
</Source>
<Target Participant = "F">
<MgmtCode>DDD</MgmtCode>
</Target>
</MessageCreate>
<Network NtwrkID = "TEST">
<Date>20010701</Date>
<Time>121213</Time>
</Network>
<MessageType>
<Request SourceID = "200107011212123" MessageID = "0000003">
<ClerkID>JOE</ClerkID>
<Account>
<AcctLookup>
<DlrLookup>
<AcctDesignation>2</AcctDesignation>
<AcctType>01</AcctType>
<DlrCode>9000</DlrCode>
<DlrAcctID>12458963356</DlrAcctID>
</DlrLookup>
</AcctLookup>
</Account>
<BusProcess>
<AddModAddress>
<Address AddressCode="2">
<AddressLine>1662 ALL CR.</AddressLine>
<City>ALL CITY</City>
<ProvState>ON</ProvState>
<Country>CAN</Country>
<PostalZip>Z6Y4R5</PostalZip>
</Address>
<TaxCode>ON</TaxCode>
</AddModAddress>
</BusProcess>
</Request>
</MessageType>
</Message>
</MessageSet>
 
Suresh Kanagalingam
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry folks...
For some reason even though I enabled UBB code it is still not doing the indentation!
Thanks
Suresh
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suresh, you need to put [code] before your code, and [/code] after. So it will be
[code]
<?xml version = "1.0" encoding = "UTF-8"?>
...
[/code]
[ November 13, 2002: Message edited by: Mapraputa Is ]
 
Suresh Kanagalingam
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok.. here it is:

[ November 15, 2002: Message edited by: Mapraputa Is ]
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Much better. Now, is there a DTD that describes this XML? (XSLT doesn't need one, but it will help document the input file format.)
And can you define the legacy file format precisely, describing (in English for now) what fields you what to transfer from the XML to the legacy file?
In your first message, I don't know where many of the fields are coming from. Perhaps you could show us a real legacy record that derives from a real record in the input XML.
 
Suresh Kanagalingam
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ron,
There is a DTD, but I did not receive it for testing.
Here is the explanation for what I need to do.
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a first pass at what you want. It may not be exactly right, but you can start from here and tweak it.
Feel free to ask any questions about what it does and how it works.
 
Ritu Kama
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Did you finally figure it out? I couldn't check the forum after initial post
Ritu
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic