[Bots Open Source EDI Translator] XML Grammer

590 views
Skip to first unread message

Akhilesh Kumar

unread,
Dec 8, 2011, 2:02:38 PM12/8/11
to bots...@googlegroups.com
Hello,

If anyone can help me understand how do I create / generate grammar using XML input file. This is for an outbound mapping where the input file is a XML file and output would be X12 EDI.

Thanks,
Akhilesh Kumar

BikeMike

unread,
Dec 8, 2011, 5:23:51 PM12/8/11
to Bots Open Source EDI Translator
Hi Akhilesh,
Bots includes xml2botsgrammar.py for converting a sample xml into a
grammar. I have used this a couple of times, it gives you a good start
but you probably need to customise it further after creating it.

usage:
xmltobotsgrammar.py <xml_sample.xml> <xml_grammar.py>

Kind Regards,
Mike

Akhilesh Kumar

unread,
Dec 9, 2011, 12:07:16 PM12/9/11
to bots...@googlegroups.com
Hi Mike,

Thank you so much. I will try and let you know in case I have any difficulty.

Regards,
Akhilesh
--

Regards,
Akhilesh

henk-jan ebbers

unread,
Dec 9, 2011, 12:12:21 PM12/9/11
to bots...@googlegroups.com
hi Akhilesh,

this quality of of the generated xml grammar depends upon the quality of the xml file.
so:
- include all elements, all attributes
- if repeatable, have it occur more than once.

kind regards,
henk-jan

On 12/09/2011 06:07 PM, Akhilesh Kumar wrote:
> Hi Mike,
>
> Thank you so much. I will try and let you know in case I have any difficulty.
>
> Regards,
> Akhilesh
>

Akhilesh Kumar

unread,
Dec 9, 2011, 12:36:26 PM12/9/11
to bots...@googlegroups.com
Thanks Henk for this further info.

I got a good grammar file generated - cool one
Just a side note on how did I use this. Initially I got error that the input .xml file is missing, then I traced the error and did the following:

The file name I used was "claim.xml" (for 837).
I had to make a "claim" folder under "D:\Python27\Lib\site-packages\bots\botssys\data" directory and copy the "claim.xml" file here.
"D:\Python27\Lib\site-packages\bots\botssys\data\claim\claim.xml"

After executing the command I got the output grammar file in "D:\Python27\Lib\site-packages\bots" folder.

"bots-xml2botsgrammar.py claim.xml BCBSGA_grammar.py"

Thank you for your quick help.

Regards,
Akhilesh
--

Regards,
Akhilesh

henk-jan ebbers

unread,
Dec 9, 2011, 12:41:45 PM12/9/11
to bots...@googlegroups.com
good to hear it works for you.
I think you can also use full path names.

henk-jan

On 12/09/2011 06:36 PM, Akhilesh Kumar wrote:
> Thanks Henk for this further info.
>
> I got a good grammar file generated - cool one
> Just a side note on how did I use this. Initially I got error that the input .xml file is missing, then I traced the error and did the following:
>
> The file name I used was "claim.xml" (for 837).
> I had to make a "claim" folder under "D:\Python27\Lib\site-packages\bots\botssys\data" directory and copy the "claim.xml" file here.
> "D:\Python27\Lib\site-packages\bots\botssys\data\claim\claim.xml"
>
> After executing the command I got the output grammar file in "D:\Python27\Lib\site-packages\bots" folder.
>
> "bots-xml2botsgrammar.py claim.xml BCBSGA_grammar.py"
>
> Thank you for your quick help.
>
> Regards,
> Akhilesh
>

> On Fri, Dec 9, 2011 at 12:12 PM, henk-jan ebbers <hjeb...@gmail.com <mailto:hjeb...@gmail.com>> wrote:
>
> hi Akhilesh,
>
> this quality of of the generated xml grammar depends upon the quality of the xml file.
> so:
> - include all elements, all attributes
> - if repeatable, have it occur more than once.
>
> kind regards,
> henk-jan
>
>
> On 12/09/2011 06:07 PM, Akhilesh Kumar wrote:
>
> Hi Mike,
>
> Thank you so much. I will try and let you know in case I have any difficulty.
>
> Regards,
> Akhilesh
>

Akhilesh Kumar

unread,
Dec 9, 2011, 12:54:49 PM12/9/11
to bots...@googlegroups.com
Yes Henk I tried full path first but got error:
IOError: [Errno 2] No such file or directory: .....

Regards,
Akhilesh
--

Regards,
Akhilesh

jeffk

unread,
Dec 9, 2011, 3:02:57 PM12/9/11
to bots...@googlegroups.com
Careful, sometimes Windoz path names with spaces in them cause problems!  Also, you probably know this, but you need to escape '\'s in Windoz paths if you choose to use them.  Put a 'print' statement in your code echoing the path name if you have any doubts.  This has bitten me a few times.
Reply all
Reply to author
Forward
0 new messages