Author |
Message
|
nobody |
Posted: Wed Jun 06, 2007 8:05 am Post subject: Namespace manipulation in XMLNSC parser |
|
|
Newbie
Joined: 06 Jun 2007 Posts: 3
|
Hi
I have an incoming message which when looking through the debugger gives me 2 or more namespace declarations. One of the namespaces is not required and have no idea on how to search for its existence and how then to remove it leaving the others in place as it is not really a field but an attribute is it not and can't find a field type to compare it against if i looped through the message. Having searched the books and the forum for similar. TIA. |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Wed Jun 06, 2007 10:11 am Post subject: Re: Namespace manipulation in XMLNSC parser |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
Here you have 2 procedures.
Check this code and modify it for your requirement.
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;
CREATE PROCEDURE SetNamespaces(IN StartRefPtr REFERENCE, IN namespace CHARACTER)
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 SetNamespaces(FieldRefPtr,namespace);
IF FIELDTYPE(FieldRefPtr) IN (0x01000000, 0x03000000) THEN
SET FieldRefPtr.(XML.NamespaceDecl)* = NULL;
SET FieldRefPtr NAMESPACE = namespace;
END IF;
MOVE FieldRefPtr NEXTSIBLING;
END WHILE;
END; |
_________________ Marcin |
|
Back to top |
|
 |
special_agent_Queue |
Posted: Wed Jun 06, 2007 10:38 am Post subject: |
|
|
 Centurion
Joined: 27 Jul 2006 Posts: 102
|
I don't think nobody wants to remove namespaces from the message, just one of the namespace declarations and if so, there wouldn't be any of that namespace in the message itself.
What would probably work is this field type:
Code: |
(XMLNSC.NamespaceDecl) |
|
|
Back to top |
|
 |
marcin.kasinski |
Posted: Wed Jun 06, 2007 10:45 am Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
special_agent_Queue wrote: |
I don't think nobody wants to remove namespaces from the message, just one of the namespace declarations and if so, there wouldn't be any of that namespace in the message itself.
What would probably work is this field type:
Code: |
(XMLNSC.NamespaceDecl) |
|
UPS sorry...
You are right.
I wrote it to fast  _________________ Marcin |
|
Back to top |
|
 |
kimbert |
Posted: Wed Jun 06, 2007 3:20 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
it is not really a field but an attribute is it not |
Well, in the message broker tree everything is a syntax element. A namespace declaration is just a syntax element with name=prefix, value=URI and a special type value to mark it as a namespace declaration.
As special_agent_Queue says, something like this should do the trick:
Code: |
SET OutputRoot.XMLNSC.(XMLNSC.NamespaceDecl)prefix = NULL; |
|
|
Back to top |
|
 |
nobody |
Posted: Wed Jun 06, 2007 11:49 pm Post subject: |
|
|
Newbie
Joined: 06 Jun 2007 Posts: 3
|
Gents / Ladies
Thanx for the reply I have since manage to get a decent trace and found the following, the "wotever it is" is ahas a field type of 0x03000102 which i have tried to lookup in the manuals and have found pretty much everything except this although the values in did find were only for the MRM and XML Parser conbstants not the XMLNSC (assume that this would be a seperate catagory and not bundled under XML) so maybe i can use that in a move against type scenario??
Here tis the trace output
0x01000000):XMLNSC = (
(0x01000000)http://www.w3.org/2000/xmlns/:TradesmanAllNBRq = (
(0x03000102):TradesmanAllNBRq = 'http://www.polaris-uk.co.uk/Schema/1-4/NUPrivateTradesmanAllNBRq'
(0x03000102):qs = 'http://www.aviva.com/NUI/2005/05/QuoteStore'
(0x03000000):DateGenerated = '2005-05-20'
(0x03000000):TimeGenerated = '10:00:00'
(0x03000000):StartDate = '2005-05-20'
the bit i want rid of is the (0x03000102):qs = 'http://www.aviva.com/NUI/2005/05/QuoteStore' piece
Appreciate all your input. Thanks |
|
Back to top |
|
 |
kimbert |
Posted: Thu Jun 07, 2007 12:06 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
|
Back to top |
|
 |
nobody |
Posted: Thu Jun 07, 2007 1:06 am Post subject: |
|
|
Newbie
Joined: 06 Jun 2007 Posts: 3
|
kimbert:
Yeah thanks, have to admit to small typo mistake on my behalf as didn't know if it was a Namesapcedecl so didn't search that i searched on the 0x3xxxx number but had typed it as 300012 not 3000102. Sorry peeps.  |
|
Back to top |
|
 |
|