Author |
Message
|
schroederms |
Posted: Wed Sep 20, 2006 11:57 am Post subject: Getting rid of namespaces ? |
|
|
 Disciple
Joined: 21 Jul 2003 Posts: 169 Location: IA
|
I'm trying to take a message from a HTTP Input node and put it to a queue to a legacy WMB flow that processes XML, However because of the namespaces the XML router can not handle it.
Is there a way to generically strip out the name spaces that come in on the XMLNS messages? Here is an example of one type of XMLNS we have to handle.
Thanks.
(0x01000010):XML = (
(0x01000000):REQUEST = (
(0x02000000): = '
'
(0x01000000):CONTROL = (
(0x02000000): = '
'
(0x01000000):NS1:ORIGINATOR = (
(0x03000000):xmlns:NS1 = 'http://Pioneer.com/IWAY_SERVICE/'
(0x02000000): = 'Alex'
)
(0x02000000): = '
'
(0x01000000):NS2:SERVICE = (
(0x03000000):xmlns:NS2 = 'http://Pioneer.com/IWAY_SERVICE/'
(0x02000000): = 'R3'
)
(0x02000000): = '
'
(0x01000000):NS3:FUNCTION = (
(0x03000000):xmlns:NS3 = 'http://Pioneer.com/IWAY_SERVICE/'
(0x02000000): = 'Z_RFC_ORDER_CREATE'
)
(0x02000000): = '
'
(0x01000000):NS4:LOCATOR = (
(0x03000000):xmlns:NS4 = 'http://Pioneer.com/IWAY_SERVICE/'
)
(0x02000000): = '
'
(0x01000000):NS5:VERSION = (
(0x03000000):xmlns:NS5 = 'http://Pioneer.com/IWAY_SERVICE/'
(0x02000000): = '1.1'
)
(0x02000000): = '
'
(0x01000000):NS6:SERIAL = (
(0x03000000):xmlns:NS6 = 'http://Pioneer.com/IWAY_SERVICE/'
)
(0x02000000): = '
'
(0x01000000):NS7:DESTINATION = (
(0x03000000):xmlns:NS7 = 'http://Pioneer.com/IWAY_SERVICE/'
(0x02000000): = '
'
(0x01000000):NS7:INSTANCE = (
(0x02000000): = 'DV3'
)
(0x02000000): = '
'
(0x01000000):NS7:CLIENT = (
(0x02000000): = '-120'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
(0x01000000):NS8:PERSISTENCE = (
(0x03000000):xmlns:NS8 = 'http://Pioneer.com/IWAY_SERVICE/'
)
(0x02000000): = '
'
(0x01000000):NS9:REALTIME = (
(0x03000000):xmlns:NS9 = 'http://Pioneer.com/IWAY_SERVICE/'
)
(0x02000000): = '
'
(0x01000000):NS10:AUDIT_LOG = (
(0x03000000):xmlns:NS10 = 'http://Pioneer.com/IWAY_SERVICE/'
(0x02000000): = 'Y'
)
(0x02000000): = '
'
(0x01000000):NS11:CONFIRMATION_Q = (
(0x03000000):xmlns:NS11 = 'http://Pioneer.com/IWAY_SERVICE/'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
(0x01000000):NS12:APP = (
(0x03000000):xmlns:NS12 = 'http://Pioneer.com/IWAY_SERVICE/'
(0x02000000): = '
'
(0x01000000):NS12:R3 = (
(0x02000000): = '
'
(0x01000000):NS12:I_ORDER_HEAD = (
(0x02000000): = '
'
(0x01000000):NS12:IDOC_TYPE = (
(0x02000000): = 'YKE2'
)
(0x02000000): = '
'
(0x01000000):NS12:ISALES_ORG = (
(0x02000000): = '1900'
)
(0x02000000): = '
'
(0x01000000):NS12:IDISTR_CHAN = (
(0x02000000): = '40'
)
(0x02000000): = '
'
(0x01000000):NS12:IDIVISION = (
(0x02000000): = '10'
)
(0x02000000): = '
'
(0x01000000):NS12:IPURCH_DATE = (
(0x02000000): = '2006-09-18T11:24:36.842-05:00'
)
(0x02000000): = '
'
(0x01000000):NS12:IDATE_TYPE = (
(0x02000000): = '1'
)
(0x02000000): = '
'
(0x01000000):NS12:IREQ_DATE_H = (
(0x02000000): = '2006-09-18T00:00:00.000-05:00'
)
(0x02000000): = '
'
(0x01000000):NS12:IPRICE_DATE = (
(0x02000000): = '2006-09-18T11:24:36.842-05:00'
)
(0x02000000): = '
'
(0x01000000):NS12:IPO_METHOD = (
(0x02000000): = 'FBW'
)
(0x02000000): = '
'
(0x01000000):NS12:INAME = (
(0x02000000): = '270700'
)
(0x02000000): = '
'
(0x01000000):NS12:IREF_1 = (
(0x02000000): = '12003'
)
(0x02000000): = '
'
(0x01000000):NS12:IASS_NUMBER = (
(0x02000000): = '2006R2'
)
(0x02000000): = '
'
(0x01000000):NS12:IPURCH_NO_S = (
(0x02000000): = 'o2oNE0129436'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
(0x01000000):NS12:T_ORDER_ITEM = (
(0x02000000): = '
'
(0x01000000):NS12:item = (
(0x02000000): = '
'
(0x01000000):NS12:MATERIAL = (
(0x02000000): = '45D01-I429'
)
(0x02000000): = '
'
(0x01000000):NS12:REQ_QTY = (
(0x02000000): = '-7'
)
(0x02000000): = '
'
(0x01000000):NS12:BLOCKING_CODE = (
(0x02000000): = 'D 45D0116O'
)
(0x02000000): = '
'
(0x01000000):NS12:PLANT = (
(0x02000000): = 'DE29'
)
(0x02000000): = '
'
(0x01000000):NS12:PURCH_NO_S = (
(0x02000000): = 'o2oNE0143306'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
(0x01000000):NS12:T_ORDER_PARTNER = (
(0x02000000): = '
'
(0x01000000):NS12:item = (
(0x02000000): = '
'
(0x01000000):NS12:PARTN_ROLE = (
(0x02000000): = 'RG'
)
(0x02000000): = '
'
(0x01000000):NS12:PARTN_NUMB = (
(0x02000000): = '1010173728'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
)
)
)
****************************************************************** |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 20, 2006 12:57 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You should be using XMLNSC in version 6.
A few other people have asked this question, and I remember seeing some code posted.
One way to do it would be to copy the XML data into an MRM-XML tree, where the message set didn't have namespaces. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Sep 21, 2006 12:24 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
You should be using XMLNSC in version 6 |
Correct - unless you really like having a message tree in which ~50% of the syntax elements look like this
Quote: |
(0x02000000): = '
'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
)
(0x02000000): = '
' |
|
|
Back to top |
|
 |
kimbert |
Posted: Thu Sep 21, 2006 12:54 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
and on the subject of stripping namespaces:
http://www.mqseries.net/phpBB2/viewtopic.php?t=25039&highlight=xml+strip+namespaces
The best algorithm is this one ( don't use the BLOB domain solution - it's not reliable ):
Code: |
CREATE PROCEDURE StripNamespaces(IN StartRefPtr REFERENCE)
BEGIN
DECLARE FieldRefPtr REFERENCE TO StartRefPtr;
MOVE FieldRefPtr FIRSTCHILD;
IF LASTMOVE(FieldRefPtr) THEN
IF FIELDTYPE(FieldRefPtr) IN (0x01000000, 0x03000000) THEN
SET FieldRefPtr.(XML.NamespaceDecl)* = NULL;
SET FieldRefPtr NAMESPACE = '';
END IF;
END IF;
WHILE LASTMOVE(FieldRefPtr) DO
CALL StripNamespaces(FieldRefPtr);
IF FIELDTYPE(FieldRefPtr) IN (0x01000000, 0x03000000) THEN
SET FieldRefPtr.(XML.NamespaceDecl)* = NULL;
SET FieldRefPtr NAMESPACE = '';
END IF;
MOVE FieldRefPtr NEXTSIBLING;
END WHILE;
END;
To use it you simply declare a reference to the starting position within an XML message where you want the namespaces removed and it will strip the namespaces from all its children and their siblings for fields of type 0x01000000 and 0x03000000 (i.e. tag field names and attribute names).
Note: You can specify additional field types as well by adding them to the IN list, but these two are the main types we are interested in.
For example, to strip the namespaces and prefixes from the XML document contained in the Body of a SOAP message:
DECLARE BodyRefPtr REFERENCE TO OutputRoot.XMLNS.soapenv:Envelope.soapenv:Body;
CALL StripNamespaces(BodyRefPtr);
Note: It is important that the reference pointer passed into the procedure points to an Output message structure and not an Input one. The message structure has to be modifiable in order for this to work. |
but I think the algorithm needs one more feature - it should strip xmlns attributes. It's not very well documented, but the bitmask for an xmlns attribute is 0x07000012 If you do get that part working, please post the updated algorithm here for the benefit of others. |
|
Back to top |
|
 |
shanson |
Posted: Thu Sep 21, 2006 1:39 am Post subject: |
|
|
 Partisan
Joined: 17 Oct 2003 Posts: 344 Location: IBM Hursley
|
An alternative suggestion (untried). Does the namespaced XML have an XML Schema? If so copy the schema and change it so that the namespace is the notarget namespace. Import each schema into its own message set. Use the Mapping node to copy one to the other.
XMLNS does not use the message set at run time, it is used just by the Mapping editor at build time. |
|
Back to top |
|
 |
airazabal |
Posted: Thu Sep 21, 2006 5:32 am Post subject: That worked! |
|
|
Newbie
Joined: 17 Aug 2005 Posts: 6
|
This is something that should make it back to the product as a build-in function! It has to be very common and should not be so hard to do.
Thanks for sharing!!!
kimbert wrote: |
and on the subject of stripping namespaces:
http://www.mqseries.net/phpBB2/viewtopic.php?t=25039&highlight=xml+strip+namespaces
The best algorithm is this one ( don't use the BLOB domain solution - it's not reliable ):
Code: |
CREATE PROCEDURE StripNamespaces(IN StartRefPtr REFERENCE)
BEGIN
DECLARE FieldRefPtr REFERENCE TO StartRefPtr;
MOVE FieldRefPtr FIRSTCHILD;
IF LASTMOVE(FieldRefPtr) THEN
IF FIELDTYPE(FieldRefPtr) IN (0x01000000, 0x03000000) THEN
SET FieldRefPtr.(XML.NamespaceDecl)* = NULL;
SET FieldRefPtr NAMESPACE = '';
END IF;
END IF;
WHILE LASTMOVE(FieldRefPtr) DO
CALL StripNamespaces(FieldRefPtr);
IF FIELDTYPE(FieldRefPtr) IN (0x01000000, 0x03000000) THEN
SET FieldRefPtr.(XML.NamespaceDecl)* = NULL;
SET FieldRefPtr NAMESPACE = '';
END IF;
MOVE FieldRefPtr NEXTSIBLING;
END WHILE;
END;
To use it you simply declare a reference to the starting position within an XML message where you want the namespaces removed and it will strip the namespaces from all its children and their siblings for fields of type 0x01000000 and 0x03000000 (i.e. tag field names and attribute names).
Note: You can specify additional field types as well by adding them to the IN list, but these two are the main types we are interested in.
For example, to strip the namespaces and prefixes from the XML document contained in the Body of a SOAP message:
DECLARE BodyRefPtr REFERENCE TO OutputRoot.XMLNS.soapenv:Envelope.soapenv:Body;
CALL StripNamespaces(BodyRefPtr);
Note: It is important that the reference pointer passed into the procedure points to an Output message structure and not an Input one. The message structure has to be modifiable in order for this to work. |
but I think the algorithm needs one more feature - it should strip xmlns attributes. It's not very well documented, but the bitmask for an xmlns attribute is 0x07000012 If you do get that part working, please post the updated algorithm here for the benefit of others. |
|
|
Back to top |
|
 |
|