ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Dynamic parsing question

Post new topic  Reply to topic Goto page 1, 2, 3  Next
 Dynamic parsing question « View previous topic :: View next topic » 
Author Message
schroederms
PostPosted: Mon Jun 10, 2013 8:57 am    Post subject: Dynamic parsing question Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

I'm trying to parse down to the REQUEST tag section of this XML WITHOUT hard coding the the parent tag name, in this case SAP_DPTBCHUB. This first outer tag will change from message to message. I've tried many things, including referencing it by the .*[nbr] for example, with no luck.

Any help would be appreciated!
thanks.

Code:
<?xml version="1.0" encoding="utf-8"?>
<SAP_DPTBCHUP xmlns="http://www.Apriso.com/SAP_DPTBCHUP.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <SessionContext>
  <EmployeeID>100000002</EmployeeID>
  <EmployeeNo>darshan</EmployeeNo>
  <TransactionTime>2013-06-07T21:12:42.3372294</TransactionTime>
  <Facility>ALG1</Facility>
  <Department />
  <OperationID>100000756</OperationID>
  <OperationRevision>DPT.I.1.0</OperationRevision>
  <StepSequenceNo>3</StepSequenceNo>
  <FunctionName>WriteXML</FunctionName>
  <TransactionGUID>T9501</TransactionGUID>
  <EquipmentID>0</EquipmentID>
  <FunctionID>100010256</FunctionID>
  <OperationCode>Upload_BatchCharacteristicUpdate</OperationCode>
  <OprSequenceNo />
  <LocalTransactionTime>2013-06-07T21:12:45.0091044</LocalTransactionTime>
  <PartnerInfo>
   <RCVPOR>SAPC64</RCVPOR>
   <SNDPRN>FLEXNET</SNDPRN>
   <RCVPRN>SAPLOG</RCVPRN>
   <RCVPRT>LS</RCVPRT>
   <SNDPOR>A000000022</SNDPOR>
   <SNDPRT>LS</SNDPRT>
   <CLNT>100</CLNT>
  </PartnerInfo>
 </SessionContext>
[color=red] [b]<REQUEST>[/b][/color]
  <DESTINATION>
   <INSTANCE>DV3</INSTANCE>
   <CLIENT>120</CLIENT>
  </DESTINATION>
  <APP>
   <TYPE>DPTBCHUP</TYPE>
   <AUFNR>2</AUFNR>
   <CHARG>5042</CHARG>
   <CHAR>hte</CHAR>
   <NUMERIC>5</NUMERIC>
   <ALPHA>gfd</ALPHA>
  </APP>
[color=red] [b]</REQUEST>[/b][/color]
</SAP_DPTBCHUP>
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jun 10, 2013 9:02 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

I'd expect the [nbr] construction to work. Remember that you may have to cast it:

Code:
 [1].REQUEST


doesn't exist because REQUEST isn't a child of the XML declaration (the [1] element in the document) but

Code:
 (XMLNSC.Element)[1].REQUEST


does.

Also be sure to specify either the right namespace or a wildcard
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Jun 10, 2013 9:10 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Code:
 DECLARE myRef reference to InputRoot.XMLNSC.*:*.*:REQUEST;
Back to top
View user's profile Send private message
schroederms
PostPosted: Mon Jun 10, 2013 9:49 am    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

I tried both or your examples, neither gets me to the tags below REQUEST. In the case of InputRoot.XMLNSC.*:*.*:REQUEST,
I have this coded:
DECLARE myRef reference to InputRoot.XMLNSC.*:*.*:REQUEST;
Set Environment.INSTANCE = myRef.DESTINATION.INSTANCE;
Set Environment.CLIENT = myRef2.DESTINATION.CLIENT;

and both Environments fields are null.
When I parse this message using RFHUtil, it does not look like REQUEST is needed to be parsed with as though there is name spaces??? Here is what I'm seeing using RFHUtil, using PARSED for data format.

Thanks.

SAP_DPTBCHUP
SAP_DPTBCHUP.(XML.attr)xmlns='http://www.Apriso.com/SAP_DPTBCHUP.xsd'
SAP_DPTBCHUP.(XML.attr)xmlns:xsd='http://www.w3.org/2001/XMLSchema'
SAP_DPTBCHUP.SessionContext
SAP_DPTBCHUP.SessionContext.EmployeeID='100000002'
SAP_DPTBCHUP.SessionContext.EmployeeNo='darshan'
SAP_DPTBCHUP.SessionContext.TransactionTime='2013-06-07T21:12:42.3372294'
SAP_DPTBCHUP.SessionContext.Facility='ALG1'
SAP_DPTBCHUP.SessionContext.Department=''
SAP_DPTBCHUP.SessionContext.OperationID='100000756'
SAP_DPTBCHUP.SessionContext.OperationRevision='DPT.I.1.0'
SAP_DPTBCHUP.SessionContext.StepSequenceNo='3'
SAP_DPTBCHUP.SessionContext.FunctionName='WriteXML'
SAP_DPTBCHUP.SessionContext.TransactionGUID='T9501'
SAP_DPTBCHUP.SessionContext.EquipmentID='0'
SAP_DPTBCHUP.SessionContext.FunctionID='100010256'
SAP_DPTBCHUP.SessionContext.OperationCode='Upload_BatchCharacteristicUpdate'
SAP_DPTBCHUP.SessionContext.OprSequenceNo=''
SAP_DPTBCHUP.SessionContext.LocalTransactionTime='2013-06-07T21:12:45.0091044'
SAP_DPTBCHUP.SessionContext.PartnerInfo
SAP_DPTBCHUP.SessionContext.PartnerInfo.RCVPOR='SAPC64'
SAP_DPTBCHUP.SessionContext.PartnerInfo.SNDPRN='FLEXNET'
SAP_DPTBCHUP.SessionContext.PartnerInfo.RCVPRN='SAPLOG'
SAP_DPTBCHUP.SessionContext.PartnerInfo.RCVPRT='LS'
SAP_DPTBCHUP.SessionContext.PartnerInfo.SNDPOR='A000000022'
SAP_DPTBCHUP.SessionContext.PartnerInfo.SNDPRT='LS'
SAP_DPTBCHUP.SessionContext.PartnerInfo.CLNT='100'
SAP_DPTBCHUP.REQUEST
SAP_DPTBCHUP.REQUEST.DESTINATION
SAP_DPTBCHUP.REQUEST.DESTINATION.INSTANCE='DV3'
SAP_DPTBCHUP.REQUEST.DESTINATION.CLIENT='120'
SAP_DPTBCHUP.REQUEST.APP
SAP_DPTBCHUP.REQUEST.APP.TYPE='DPTBCHUP'
SAP_DPTBCHUP.REQUEST.APP.AUFNR='2'
SAP_DPTBCHUP.REQUEST.APP.CHARG='5042'
SAP_DPTBCHUP.REQUEST.APP.CHAR='hte'
SAP_DPTBCHUP.REQUEST.APP.NUMERIC='5'
SAP_DPTBCHUP.REQUEST.APP.ALPHA='gfd'
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Mon Jun 10, 2013 9:59 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Adding Trace nodes will display the Logical Message Tree. From this output, you can write explicit code to get the right values. From the explicit code, you can substitute * in the places where you do not want to reference the field/folder name.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Mon Jun 10, 2013 10:20 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

lancelotlinc wrote:
Adding Trace nodes will display the Logical Message Tree. From this output, you can write explicit code to get the right values. From the explicit code, you can substitute * in the places where you do not want to reference the field/folder name.


And where you want to use * in the places you do not want to reference the namespace by name....
Back to top
View user's profile Send private message
schroederms
PostPosted: Mon Jun 10, 2013 10:32 am    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

Ok I'm getting close but not getting what I need. Let me show you what I've done so far:

Declare ns1 namespace 'http://www.Apriso.com/SAP_DPTBCHUP.xsd';

This statment brought back my result...
Set Environment.APP = InputRoot.XMLNSC.ns1:SAP_DPTBCHUP.ns1:REQUEST.ns1:APP.ns1:TYPE;

So then I went one step farther and coded this and this too brought back what I wanted.
Set Environment.APP = InputRoot.XMLNSC.*:SAP_DPTBCHUP.*:REQUEST.*:APP.*:TYPE;

But when I try this below, it brings back a null value:
Set Environment.APP = InputRoot.XMLNSC.*:*.*:REQUEST.*:APP.*:TYPE;
Back to top
View user's profile Send private message
rekarm01
PostPosted: Mon Jun 10, 2013 11:52 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

schroederms wrote:
But when I try this below, it brings back a null value:

Code:
Set Environment.APP = InputRoot.XMLNSC.*:*.*:REQUEST.*:APP.*:TYPE;

If the Trace node indicates that XMLNSC (for example) has more than one child element, then the ESQL reference may need a suitable type qualifier or subscript to match the correct one.
Back to top
View user's profile Send private message
schroederms
PostPosted: Mon Jun 10, 2013 12:22 pm    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

Correct, but there is only one outer tag, and when I qualify it, it brings back the expected results.

This is what I see in the trace.

(0x01000000:Folder):XMLNSC = ( ['xmlnsc' : 0x117e72490]
(0x01000400:NamespaceDecl):XmlDeclaration = (
(0x03000100:Attribute):Version = '1.0' (CHARACTER)
(0x03000100:Attribute):Encoding = 'utf-8' (CHARACTER)
)
(0x01000000:Folder )http://www.Apriso.com/SAP_DPTBCHUP.xsd:SAP_DPTBCHUP = (
(0x03000102:NamespaceDecl):xmlns = 'http://www.Apriso.com/SAP_DPTBCHUP.xsd' (CHA
RACTER)
(0x03000102:NamespaceDecl)http://www.w3.org/2000/xmlns/:xsd = 'http://www.w3.org/2001/XMLSchema' (CHARACTER
)
(0x01000000:Folder )http://www.Apriso.com/SAP_DPTBCHUP.xsd:SessionContext = (
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:EmployeeID = '100000002' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:EmployeeNo = 'darshan' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:TransactionTime = '2013-06-07T21:12:42.3372294' (CHARACTE
R)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:Facility = 'ALG1' (CHARACTER)
(0x01000000:Folder )http://www.Apriso.com/SAP_DPTBCHUP.xsd:Department =
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:OperationID = '100000756' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:OperationRevision = 'DPT.I.1.0' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:StepSequenceNo = '3' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:FunctionName = 'WriteXML' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:TransactionGUID = 'T9501' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:EquipmentID = '0' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:FunctionID = '100010256' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:OperationCode = 'Upload_BatchCharacteristicUpdate' (CHA
RACTER)
(0x01000000:Folder )http://www.Apriso.com/SAP_DPTBCHUP.xsd:OprSequenceNo =
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:LocalTransactionTime = '2013-06-07T21:12:45.0091044' (CHARACTE
R)
(0x01000000:Folder )http://www.Apriso.com/SAP_DPTBCHUP.xsd:PartnerInfo = (
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:RCVPOR = 'SAPC64' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:SNDPRN = 'FLEXNET' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:RCVPRN = 'SAPLOG' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:RCVPRT = 'LS' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:SNDPOR = 'A000000022' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:SNDPRT = 'LS' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:CLNT = '100' (CHARACTER)
)
)
(0x01000000:Folder )http://www.Apriso.com/SAP_DPTBCHUP.xsd:REQUEST = (
(0x01000000:Folder)http://www.Apriso.com/SAP_DPTBCHUP.xsd:DESTINATION = (
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:INSTANCE = 'DV3' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:CLIENT = '120' (CHARACTER)
)
(0x01000000:Folder)http://www.Apriso.com/SAP_DPTBCHUP.xsd:APP = (
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:TYPE = 'DPTBCHUP' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:AUFNR = '2' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:CHARG = '5042' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:CHAR = 'hte' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:NUMERIC = '5' (CHARACTER)
(0x03000000:PCDataField)http://www.Apriso.com/SAP_DPTBCHUP.xsd:ALPHA = 'gfd' (CHARACTER)
)
)
)
)
)
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Jun 10, 2013 12:40 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The namespace declaration counts.

You want *:*[<]
Back to top
View user's profile Send private message
schroederms
PostPosted: Mon Jun 10, 2013 12:45 pm    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

thanks, it's working.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Jun 10, 2013 12:56 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

As rekarm01 said, you could also use "(XMLNSC.Element)*:*", to indicate you wanted the first anonymous child that is an XMLNSC Element, rather than indicating you wanted the last anonymous child.
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Jun 11, 2013 3:04 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

The top level of an XML document ( InputRoot.XMLNSC ) can contain
- an optional prolog ( the XML declaration ). This must be first if it exists in the document.
- optional processing instructions/comments
- exactly one root tag
- optional processing instructions/comments

So *:*[<], which takes the last top-level child of XMLNSC, will not be reliable in all cases. It might select a comment or a processing instruction instead of the root tag.

This is exactly why XMLSNC.Element was provided. The safe way to do it is:
Code:
InputRoot.XMLNSC.(XMLNSC.Element)*:*.*:REQUEST
Back to top
View user's profile Send private message
schroederms
PostPosted: Tue Jun 11, 2013 4:14 am    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

Thanks I will try it.
Back to top
View user's profile Send private message
schroederms
PostPosted: Tue Jun 11, 2013 4:58 am    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2003
Posts: 169
Location: IA

I appreciate everyone's help, I've got it doing what I need to have it do. Completely namespace independent (multiple namespace possible from a third party company), which I then loop through whatever the tag names are under REQUEST.APP, removing the name space, and building a message to feed into SAP.

Thanks Again!

Set Environment.MyloopStart = Cardinality(InputRoot.XMLNSC.(XMLNSC.Element)*:*.*:REQUEST.*:APP.*:*[]);
--Pull all data under REQUEST.APP and prepare for SAP feed.
While i <= Environment.MyloopStart Do
Set Environment.APP.[i] NAME = Fieldname(InputRoot.XMLNSC.(XMLNSC.Element)*:*.*:REQUEST.*:APP.*:*[i]);
Set Environment.APP.[i] = InputRoot.XMLNSC.(XMLNSC.Element)*:*.*:REQUEST.*:APP.*:*[i];
set i = i +1;
End While;

Set OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Version=InputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Version;
Set OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Encoding=InputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Encoding;
--
--
Set OutputRoot.XMLNSC.REQUEST.APP = Environment.APP;
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2, 3  Next Page 1 of 3

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Dynamic parsing question
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.