messagecount in enevelope

25 views
Skip to first unread message

Hans

unread,
Oct 17, 2022, 6:37:15 AM10/17/22
to Bots Open Source EDI Translator
Hi All,

I was wondering if there's an easy way to know how many messages there are in a  XML envelope.
should i use out.getcountoccurrences({'BOTSID':'HEA'},{'BOTSID':'MESSAGE'}) in the envelope? It seems that this only works in a mappingscript?

Best regards,
Hans

Eppye Bots

unread,
Oct 17, 2022, 7:00:24 AM10/17/22
to 'Chuck Turco' via Bots Open Source EDI Translator
it has to be counted that is for sure.
that works in a mappingscript.
where do you want to use it? in an envelopescript?
kind regards, Henk-Jan Ebbers


--
You received this message because you are subscribed to the Google Groups "Bots Open Source EDI Translator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to botsmail+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/botsmail/a840d172-f9d2-45b2-954d-1be79e2eaceen%40googlegroups.com.

Hans

unread,
Oct 17, 2022, 7:29:08 AM10/17/22
to Bots Open Source EDI Translator
Hi Henk-Jan,

I need the messagecount in the XML envelope so the receiver knows how many messages are contained in the transmission.
So i thought i had to count the includes in the envelopescript, but that always returns 0. And any other mpath check gives the same value or mpath-error.
I've added the envelopescript i'm using for reference.
Op maandag 17 oktober 2022 om 13:00:24 UTC+2 schreef eppye:
xml_envelope.py

Eppye Bots

unread,
Oct 17, 2022, 7:36:54 AM10/17/22
to 'Chuck Turco' via Bots Open Source EDI Translator
this line is not correct AFAICS :
messageCount = self.out.getcountoccurrences({'BOTSID': '{http://www.w3.org/2001/XInclude}include'})
        
would expect the xml tag names here
kind regards, Henk-Jan Ebbers


Hans

unread,
Oct 17, 2022, 9:11:55 AM10/17/22
to Bots Open Source EDI Translator
Hi Henk-Jan,

I would expect that too, but i receive mpath errors when i try to count the actual XML tag name.

messageCount = self.out.getcountoccurrences({'BOTSID':'transmission'},{'BOTSID': 'message'})
Parameter mpath is not valid according to grammar: ({'BOTSIDnr': u'1', 'BOTSID': 'transmission'}, {'BOTSIDnr': u'1', 'BOTSID': 'message'})

messageCount = self.out.getcountoccurrences({'BOTSID':'message'})
Parameter mpath is not valid according to grammar: ({'BOTSIDnr': u'1', 'BOTSID': 'message'},)

Which grammar is this check based on? the envelope grammar? then it's correct it thows an error.
envelope grammar:

structure = [
{ID:'transmission',MIN:1,MAX:99999,LEVEL:[
{ID:'{http://www.w3.org/2001/XInclude}include',MIN:0,MAX:99999},
]},
]

Op maandag 17 oktober 2022 om 13:36:54 UTC+2 schreef eppye:

Eppye Bots

unread,
Oct 17, 2022, 9:15:36 AM10/17/22
to 'Chuck Turco' via Bots Open Source EDI Translator
does it work when you turn off grammar checks?
kind regards, Henk-Jan Ebbers


Hans

unread,
Oct 17, 2022, 10:15:45 AM10/17/22
to Bots Open Source EDI Translator
well, it doesn't throw an error anymore, but it also still doesn't count the occurrences.
The value is still 0.

Op maandag 17 oktober 2022 om 15:15:36 UTC+2 schreef eppye:

Eppye Bots

unread,
Oct 17, 2022, 10:30:34 AM10/17/22
to 'Chuck Turco' via Bots Open Source EDI Translator
try something along the lines of:
self.out.root.display()
at end of enveloping script to see what is there
kind regards, Henk-Jan Ebbers


Hans

unread,
Oct 17, 2022, 10:47:23 AM10/17/22
to Bots Open Source EDI Translator
It doens't show me anythig, except if i use
messageCount = self.out.getcountoccurrences({'BOTSID': '{http://www.w3.org/2001/XInclude}include'})


 {'BOTSIDnr': u'1', 'transmission__messageCount': u'0', 'BOTSID': u'transmission'}
     {}
     {}
     {}

Op maandag 17 oktober 2022 om 16:30:34 UTC+2 schreef eppye:

Eppye Bots

unread,
Oct 17, 2022, 10:54:32 AM10/17/22
to 'Chuck Turco' via Bots Open Source EDI Translator
what is the result of the enveloping?

kind regards, Henk-Jan Ebbers


Hans

unread,
Oct 17, 2022, 10:59:15 AM10/17/22
to Bots Open Source EDI Translator
I do get a good looking enveloped result, only the messagecount attribute is missing.
self.out.put({'BOTSID':'transmission','transmission__messageCount':messageCount})
messageCount = 0 so there's no output

Op maandag 17 oktober 2022 om 16:54:32 UTC+2 schreef eppye:

Eppye Bots

unread,
Oct 17, 2022, 3:16:18 PM10/17/22
to 'Chuck Turco' via Bots Open Source EDI Translator

        for filename in ta_list:
            self.out.put({'BOTSID':'transmission'},{'BOTSID':include,include + '__parse':'xml',include + '__href':filename})

think len(ta_list) would be good?

kind regards, Henk-Jan Ebbers


Hans

unread,
Oct 18, 2022, 3:23:01 AM10/18/22
to Bots Open Source EDI Translator
smart, that works, thx!

Op maandag 17 oktober 2022 om 21:16:18 UTC+2 schreef eppye:
Reply all
Reply to author
Forward
0 new messages