From: tfennelly <do-...@jb...> - 2006-06-28 20:27:59
|
OK, so I've put something together on this. So the solution I implemented revolves around a standard SAX Parser implementation called X12nToSaxEventParser. As its name is supposed to suggest, it parses an X12N stream and generates a set of SAX Events which it fires at a standard SAX ContentHandler implementation. It has 2 support class: 1. X12nStreamReader: Wraps the stream and makes the X12N segments easier to access. 2. X12nModel: Contains definitions to help the parser convert the X12N stream to a stream of SAX events. Here's a sample of its output after parsing the sample X12N stream in Dave's above post - actually it's 2 blocks of the above sample X12N, hence the 2 blocks inside the root <x12n> element. So, this parser could be used by any XML transformation tools that support SAX based processing and transformation. I had to make a very small mod to Smooks in order to make it easier to specify specific SAX parsers for specific message types - available in the v 0.7.2-SNAPSHOT build from the downloads. See the JUnit test code. The x12n-config.cdrl config file illustrates how to configure the X12nToSaxEventParser to parse messages originating from X12N based message producers ("x12n-requester" - "x12n-producer" might have been a better profile name). See X12nToSaxEventParserTest for the units test code for executing a parse. Excuse the fact that this test has no assertions - it just runs the parse :-) This test doesn't perform any actual XML based transformations on the XMLified X12N stream. This would probably be required in a real life situation (different transformations for different consumers) and is easy enough using the standard Smooks mechanisms (see tutorials) - once we have it in XML, we can do whatever we want!! View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3954185#3954185 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3954185 |