Author |
Message
|
wilsonjohn24 |
Posted: Fri Apr 10, 2009 6:10 am Post subject: Changing Namespaces |
|
|
 Voyager
Joined: 02 Feb 2007 Posts: 93 Location: Scotland
|
Hi,
Basic scenario is I want to change a namespace from http://bob to http://sue.
I came up with a nice route to find NS declaration and reset it .
When I look at the tree the namspace has been changed, but the orginal definition prefixes have not changed despite me just replacing the namespace URL and not the prefix.
Broker seems to have magically readded the orginal and give it a new prefix. I am using xmlns domain.
Any nice routines to reset a namespace definition and not have it affect(effect) the elements? I appreciate this is likely prescribed behaviour as the tree has the full url not the prefix.
thanks
John |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Apr 10, 2009 8:11 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
There's a difference between the node in the logical tree that represents the XML namespace declaration and the node in the logical tree that represents the element that has a namespace on it... |
|
Back to top |
|
 |
kimbert |
Posted: Fri Apr 10, 2009 9:50 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
|
Back to top |
|
 |
wilsonjohn24 |
Posted: Sun Apr 12, 2009 10:50 pm Post subject: |
|
|
 Voyager
Joined: 02 Feb 2007 Posts: 93 Location: Scotland
|
Cheers for that...
I seen that post- but it does not work. If I have an anonoymous namespace it will not pick up this.
I am thinking of parsing the message as a blob and doing some string manipulating of the blob. Does this approach seem ok?
thanks
John |
|
Back to top |
|
 |
kimbert |
Posted: Mon Apr 13, 2009 1:06 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I am thinking of parsing the message as a blob and doing some string manipulating of the blob. Does this approach seem ok? |
No, that approach would be very bad practice. There is a straightforward solution to your problem. Just
a) set the correct namespace on every node in the message tree and
b) add namespace declarations into the message tree to obtain the prefixes ( or default namespaces ) that you want to see in your output. |
|
Back to top |
|
 |
wilsonjohn24 |
Posted: Thu Apr 16, 2009 11:38 pm Post subject: |
|
|
 Voyager
Joined: 02 Feb 2007 Posts: 93 Location: Scotland
|
I gathered it was not good to parse a mesage with two different parsers... It was the path of least resistence!
Anyway, coded it from code you reference thanks for that. For reference for anyone else ( the alogirithim is not mights but the nicely named procedure and variables are )
CREATE PROCEDURE changeAllNSReferences(IN StartRefPtr REFERENCE, IN ns1 CHAR,IN ns2 CHAR)
BEGIN
DECLARE FieldRefPtr REFERENCE TO StartRefPtr;
MOVE FieldRefPtr FIRSTCHILD;
IF LASTMOVE(FieldRefPtr) THEN
IF FIELDTYPE(FieldRefPtr) IN (0x01000000, 0x03000000) AND FIELDNAMESPACE( FieldRefPtr)= ns1 THEN
SET FieldRefPtr.(XML.NamespaceDecl) = NULL;
SET FieldRefPtr NAMESPACE = ns2;
END IF;
END IF;
WHILE LASTMOVE(FieldRefPtr) DO
CALL changeAllNSReferences(FieldRefPtr,ns1,ns2);
IF FIELDTYPE(FieldRefPtr) IN (0x01000000, 0x03000000) AND FIELDNAMESPACE( FieldRefPtr)= ns1 THEN
SET FieldRefPtr.(XML.NamespaceDecl) = NULL;
SET FieldRefPtr NAMESPACE = ns2;
END IF;
MOVE FieldRefPtr NEXTSIBLING;
END WHILE;
END;
cheers
john |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Apr 17, 2009 1:33 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
(XML.NamespaceDecl) only applies to the XMLNS parser.
Please use the XMLNSC parser instead, unless you are still on Broker v5.
If you are still on Broker v5, please upgrade to Broker 6.1. |
|
Back to top |
|
 |
kimbert |
Posted: Fri Apr 17, 2009 8:17 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Either you have described your problem wrongly above, or your code does not work.
You must SET the NAMESPACE on every single folder and field in the message tree ( apart from the namespace declarations / xsi:type attributes and other XML-related things ).
Your code is only changing the namespace declarations. |
|
Back to top |
|
 |
|