Author |
Message
|
AgentSmith |
Posted: Sat Dec 27, 2003 2:44 am Post subject: XML Attribute (Simple) question |
|
|
 Novice
Joined: 19 Nov 2003 Posts: 19
|
Hi All,
I have a simple doubt i need to clarify ASAP.
I have an input XML like this:
<MAIN>
<DATA>
<Child1 Name="A" Age="28" Loc="US"/>
<Child2 Type="VV" Fen="DD"/>
<Child3 Next="X" GG="d" Loc="US"/>
</DATA>
<OUT>
<Child1 Name="A" Age="28" Loc="US">
<old>yes</old>
</Child1>
<Child2 Type="VV" Fen="DD"/>
<new>yes</new>
</Child2>
<Child3 Nm="A" g="28" />
<Child4 Name="B" Age="28" Loc="US"/>
</OUT>
</DATA>
I don't know the names of the child tags of DATA and OUT. So ,I am accessing them via anonymous references and I am comparing the child tags of DATA and OUT tags.
I should process them if the attributes(and their values) of the same named child tags in DATA and OUT are equal.
I neither know the names of the attributes nor HOW MANY attributes every child tag will contain, since XML is generated dynamically.
-> How can i compare attributes of two tags using anonymous field references without knowing their names?
-> How can i determine whether the anonymous reference is an XML Attribute or XML Element?
Anybody, Please reply to this query.
Thx,
AgentSmith. |
|
Back to top |
|
 |
EddieA |
Posted: Sat Dec 27, 2003 4:45 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
You can use FIELDNAME to get the Tag/Attribute name.
The following is how I check for a Tag. You'll have to get the value for an Attribute from a Trace node:
IF FIELDTYPE(InputBody.*[ThisTag]) = 0x1000000 THEN
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
AgentSmith |
Posted: Sat Jan 03, 2004 10:45 pm Post subject: |
|
|
 Novice
Joined: 19 Nov 2003 Posts: 19
|
Hey,
That worked.
Thx,
AgentSmith |
|
Back to top |
|
 |
kirani |
Posted: Sun Jan 04, 2004 11:24 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
From WBIMB manual,
Quote: |
Note that the mapping of integer values to field types is not published, and might change from release to release. You should therefore use the results of the FIELDTYPE function by comparing with named field types. For example:
Code: |
IF FIELDTYPE(source_field_reference) = NameValue
THEN ...
|
|
_________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
EddieA |
Posted: Sun Jan 04, 2004 1:25 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Agreed that it would be better. But, to do that, IBM need to publish what those field types are. I can't find them, not in any 2.1 manual.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
kirani |
Posted: Sun Jan 04, 2004 1:38 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
I remember seeing some table in one of the WMQI Manual specifying these values. I don't remember the manual name right now, I will try to find the table and post it here. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
kirani |
Posted: Sun Jan 04, 2004 4:11 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Please take a look at WMQI - Programming Guide Appendix E - XML and MRM parser constants. You can use constants specified in this section in your FIELDTYPE function. For example,
Code: |
IF FIELDTYPE(InputBody.*[ThisTag]) = XML.tag THEN
|
Hope this helps. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
AgentSmith |
Posted: Wed Jan 14, 2004 2:16 am Post subject: |
|
|
 Novice
Joined: 19 Nov 2003 Posts: 19
|
Yep. I got it.
Thx,
Smith. |
|
Back to top |
|
 |
|