Author |
Message
|
gyadavil |
Posted: Wed Sep 12, 2007 11:15 am Post subject: Problem with FiledType Function |
|
|
Acolyte
Joined: 01 Feb 2005 Posts: 62
|
Hello
I created a Message Set from XSD files and using this in my message flow. I am receiving a message with name spaces and I am converting this message to MRM using RCD node. I am trying to figure out some fields under the message are XML attributes or not. For this purpose I am using FieldType function and comparing with XML.Attribute. This chek is failing even for the elements classified as Attributes in my Message Set. I am curious hat is the issue here and what I am doing wrong. Please help me out. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 12, 2007 11:31 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Why do you need to know if an element is represented physically as an Attribute?
You can't use any field qualfiers from the XML domain (or the XMLNSC domain) on elements in the MRM domain.
I do not believe the FieldType on an MRM element tells you anything about the physical representation of that element, no matter which MRM parser is used to build it.
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/topic/com.ibm.etools.mft.doc/as08560_.htm _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
gyadavil |
Posted: Wed Sep 12, 2007 11:47 am Post subject: |
|
|
Acolyte
Joined: 01 Feb 2005 Posts: 62
|
Thanks so much for the reply. I am trying to construct an xml output and would like to construct only with the elements and avoid attributes. What is the best way to do it. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 12, 2007 11:50 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Configure your model appropriately.
That's what it's for. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
gyadavil |
Posted: Wed Sep 12, 2007 11:52 am Post subject: |
|
|
Acolyte
Joined: 01 Feb 2005 Posts: 62
|
if I remove these attributes from my messge set, then my incoming message will fail right as there is no matching attribute fields to store ?? |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 12, 2007 11:54 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I'm confused.
I thought you wanted to output them as elements, not attributes.
Do you wish to remove all attributes, instead?
What an odd notion. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
gyadavil |
Posted: Wed Sep 12, 2007 12:00 pm Post subject: |
|
|
Acolyte
Joined: 01 Feb 2005 Posts: 62
|
sorry for the confusion. Here is what I am doing.
I am getting data from db2 db using jdbc adapters. So I see attributes like version, delta, locale. My message flow is like this
Input Node --> RCD(convert to MRM Msgset based on BO) --> Compute Node(which is supposed to pass only elements but not attributes further) --> JCN( which adds some info to the message) --> ComputeNode(which constructs BO for Domino Adapter) -->Output Node
So I don't want to add these attributes as elements when I construct my Message for the Domino Adapter. Thats why I am trying to check whether the element is an attribute or element then trying to act. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 12, 2007 12:31 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I think you're missing the bigger picture.
You've got two message definitions - one that's an input and one that's an output. You need to map the correct fields from the input message and the augmented information from the JCN to the correct fields of the output.
You don't need to worry about whether a field is an Attribute or not - just whether it's the "correct" field. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Sep 12, 2007 12:57 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Hi there,
This is a frequent cause of confusion. As Jeff says, the MRM domain is guided by the message set, not by the field type.
If you want attributes to change into elements on the way through your flow you have two choices:
1. Define another message in which the all attribute declarations are changed to element declarations with the same simple type.
2. Use XMLNSC to output your message ( not XMLNS - the tree shape would be too different to the MRM's . And definitely not XML domain please!) |
|
Back to top |
|
 |
gyadavil |
Posted: Wed Sep 12, 2007 1:22 pm Post subject: |
|
|
Acolyte
Joined: 01 Feb 2005 Posts: 62
|
I don't want attribute to change as elements.
In MRM I have Attributes + Elements from the XSD and as you guys say I can't make out the difference between them programatically.
I wan to include only the elements not the attributes to the output root. I want to strip off the attributes from my message programtically. This is where my code is not working and Jeff already clarified why it is not working.
So how I can strip off the Attributes from my message if the message already converted to MRM using RCD. As per Jeff I can do it in my flow before RCD, like use FieldType and strip off all Attributes then submit the message to RCD. Will that work ??
How do I set the filed name for the xml tree using a variable
eg: Set OutputRoot.XML.<varibale_name> = value;
Can I use this ?? I want to capture the fieldname dynamically in the varibale and use it in the set command.
This is needed for the question I asked above. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 12, 2007 1:27 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I don't think you need to do this.
I think you can focus on the business level logic of the message flow, and only add to the Domino BO message set the correct fields from the input message.
If you really need to do this, then you can't do it with MRM. You can reparse your data, potentially several times, in the XMLNS or XMLNSC domains and the MRM domain.
Or you can hard code the list of fields that are represented as attributes, in one way or another (perhaps consider using FIELDNAME instead of FIELDTYPE), and create a new tree that way.
But it will no longer match your input message set. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
gyadavil |
Posted: Wed Sep 12, 2007 1:31 pm Post subject: |
|
|
Acolyte
Joined: 01 Feb 2005 Posts: 62
|
[quote="jefflowrey"]I think you're missing the bigger picture.
You've got two message definitions - one that's an input and one that's an output. You need to map the correct fields from the input message and the augmented information from the JCN to the correct fields of the output.
You don't need to worry about whether a field is an Attribute or not - just whether it's the "correct" field.[/quote]
Challenge here for is, when I construct the Message for the Domino Adapter, I need to only the fields came from DB but not the attributes added by the adapter. What I mean is, DominoDocument BO has pretty standard format which takes field name as one of the xml element value instead of xml tag. So if I have to update 10 columns I need to create that many of the following
<DominoDocument>
<DominoItem>
<Name>PART_NUM</Name>
<Type>STRING</Type>
<DominoItemValue>
<Value>11111</Value>
</DominoItemValue>
<DominoItem>
</DominoDocument>
So I need to send only the fields which will be in Notes DB. But I should not include attributes in my Message. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 12, 2007 1:38 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
So what you're saying is that you don't need any fields from your input message at all, and only need to create a brand new message based on data in the database, and described by a message definition. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
gyadavil |
Posted: Wed Sep 12, 2007 1:38 pm Post subject: |
|
|
Acolyte
Joined: 01 Feb 2005 Posts: 62
|
[quote="jefflowrey"]I don't think you need to do this.
I think you can focus on the business level logic of the message flow, and only add to the Domino BO message set the correct fields from the input message.
If you really need to do this, then you can't do it with MRM. You can reparse your data, potentially several times, in the XMLNS or XMLNSC domains and the MRM domain.
Or you can hard code the list of fields that are represented as attributes, in one way or another (perhaps consider using FIELDNAME instead of FIELDTYPE), and create a new tree that way.
But it will no longer match your input message set.[/quote]
I tried this intitially jeff. The issue is my code is adding even attributes also like elements to my Domino BO which will not work for me.
MY code looks like this
CREATE COMPUTE MODULE DominoInbound_CreateBO
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- CALL CopyMessageHeaders();
-- CALL CopyEntireMessage();
---------------------------------My Code Starts Here-----------------------------
CALL CopyMessageHeaders();
Declare DDoc NAMESPACE 'http://www.ibm.com/websphere/crossworlds/2002/BOSchema/DominoDocument';
Declare DItem NAMESPACE 'http://www.ibm.com/websphere/crossworlds/2002/BOSchema/DominoItem';
Declare DItemValue NAMESPACE 'http://www.ibm.com/websphere/crossworlds/2002/BOSchema/DominoItemValue';
Declare UD NAMESPACE 'http://www.ibm.com/websphere/crossworlds/2002/BOSchema/SWG_VSALESBOMFNSHDPARTINFO_UD';
Declare vInputMsg Reference To InputRoot.XMLNS;
Declare DD Reference To DDoc.DominoDocument;
Declare DI Reference To DItem.DominoItem;
Declare DIV Reference To DItemValue.DominoItemValue;
Set OutputRoot.Properties.MessageFormat = 'CwXML';
Set OutputRoot.Properties.MessageType = 'DominoDocument';
Set OutputRoot.MQMD.Format = 'MQRFH2';
SET OutputRoot.MQRFH2.(MQRFH2.Field)Version= 2 ;
SET OutputRoot.MQRFH2.(MQRFH2.Field)Format='MQSTR ' ;
SET OutputRoot.MQRFH2.(MQRFH2.Field)Encoding= 273 ;
Set OutputRoot.MQMD.MsgType = MQMT_REQUEST;
Set OutputRoot.MQMD.ReplyToQ = 'ESB_DOMINO/RESPONSEQUEUE';
-- SET OutputRoot.XMLNS.(XML.XmlDecl).(XML.Version) = '3.0.0';
Declare I Integer 1;
Declare ItemCnt Integer 0;
Declare verb Char '';
Declare ItemValueCnt Integer 0;
------------Setting Verb and NotesID-------------
-- If (vInputMsg.Verb <> 'MULTIPLE') Then
Set verb = vInputMsg.Record.Verb;
-- End If;
-------------------------------------------------
SET OutputRoot.XMLNS.(XML.XmlDecl).(XML.Version) = '1.0';
SET OutputRoot.XMLNS.(XML.XmlDecl).(XML.Encoding) = 'UTF-8';
Set OutputRoot.XMLNS.DDoc:DominoDocument.(XML.Attribute)version = '3.0.0';
Set OutputRoot.XMLNS.DDoc:DominoDocument.(XML.Attribute)verb = verb;
Set OutputRoot.XMLNS.DDoc:DominoDocument.(XML.Attribute)locale = 'en';
Set OutputRoot.XMLNS.DDoc:DominoDocument.(XML.Attribute)delta = 'false';
If (verb <> 'Create') Then
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:NoteID = FIELDVALUE(vInputMsg.Record.NoteId);
End If;
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:DatabaseName = FIELDVALUE(vInputMsg.Record.DBName);
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:ServerName = FIELDVALUE(vInputMsg.Record.HostName);
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:UserName = FIELDVALUE(vInputMsg.Record.UserName);
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Password = FIELDVALUE(vInputMsg.Record.Password);
-- If (Upper(verb) = 'UPDATE') Then
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:HasEmbedded = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:IsDeleted = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:IsProfile = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:IsResponse = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:IsSentByAgent = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:IsSigned = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:IsValid = 'true';
-- End If;
Set ItemCnt = Cardinality(vInputMsg.Record.*[]);
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.(XML.Attribute)size = ItemCnt;
While (I <= ItemCnt)
Do
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].(XML.Attribute)version = '3.0.0';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].(XML.Attribute)verb = '';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].(XML.Attribute)locale = 'en';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].(XML.Attribute)delta = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:Name = FIELDNAME(vInputMsg.Record.*[I]);
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:Type = 'String'; --vInputMsg.Item[I].Type;
Set ItemValueCnt = Cardinality(vInputMsg.Record.*[I].*[]);
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:Values.(XML.Attribute)size = ItemValueCnt;
Declare tmpValCnt Integer 1;
While (tmpValCnt <= ItemValueCnt)
Do
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:Values.DItemValue:DominoItemValue[tmpValCnt].(XML.Attribute)version = '3.0.0';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:Values.DItemValue:DominoItemValue[tmpValCnt].(XML.Attribute)verb = '';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:Values.DItemValue:DominoItemValue[tmpValCnt].(XML.Attribute)locale = 'en';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:Values.DItemValue:DominoItemValue[tmpValCnt].(XML.Attribute)delta = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:Values.DItemValue:DominoItemValue[tmpValCnt].DItemValue:Value = FIELDVALUE(vInputMsg.Record.UD:*[I].*[tmpValCnt]);
Set tmpValCnt = tmpValCnt + 1;
End While;
If ( Upper(verb) In ('CREATE','UPDATE') ) Then
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:IsAuthors = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:IsEncrypted = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:IsNames = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:IsProtected = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:IsReaders = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:IsSigned = 'false';
Set OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:IsSummary = 'true';
End If;
Set I = I+1;
End While;
---------------------------------My Code Ends Here -----------------------------
RETURN TRUE;
END;
============================================
OutputRoot.XMLNS.DDoc:DominoDocument.DDoc:Items.DItem:DominoItem[I].DItem:Name = FIELDNAME(vInputMsg.Record.*[I]);
This statement even adding attributes to my message which I don't want to do. |
|
Back to top |
|
 |
gyadavil |
Posted: Wed Sep 12, 2007 1:47 pm Post subject: |
|
|
Acolyte
Joined: 01 Feb 2005 Posts: 62
|
[quote="jefflowrey"]So what you're saying is that you don't need any fields from your input message at all, and only need to create a brand new message based on data in the database, and described by a message definition.[/quote]
Not exactly. The JDBC adapters bringing data from db2 and obviously the message has attributes like verb, locale etc. And I am converting the message to MRM using RCD. so all these attributes are becoming elements. I am trying to run a loop for all the elements and add them to Domino BO. While doing it obviously it is adding attributes also as elements. But technically there is no matching column for these attribs in the notes db. So to answer your question, after I converted my message to MRM, the output root should have only the actual elements which are db columns and no attributes added to output root as elements. my InputRoot looks like this
MRM
version (Attribute in xml)
delta (Attribute in xml)
locale (Attribute in xml)
verb (Attribute in xml)
part_num (DB Column)
qty (DB Column)
So my outputRoot should be only DB Columns but not Attribs. As you said I can hardcode, but I am trying to avoid that which causes trouble in future.
So if I use FieldType function before my RCD node on actual input XMLNSC message, will it work ?? If it works, I can identify the XML.Attribute and strip off and then submit only the actual elements of xml to RCD for the conversion. |
|
Back to top |
|
 |
|