Posted: Mon Aug 30, 2004 5:05 pm Post subject: Is it possible to add xmlns declaration to existing element
Apprentice
Joined: 30 Aug 2004 Posts: 34
Is it possible to add a xmlns declaration to an existing element in an XML document? I'm using WBI MB 5 FP3, I'm not an expert in ESQL so hopefully this is something trivial.
DECLARE sp1 NAMESPACE 'http://tempuri.org/';
SET OutputRoot.XMLNS = InputRoot.XMLNS;
SET OutputRoot.XMLNS.sp1:GetPurRedData.(XML.NamespaceDecl)xmlns = sp1;
But this doesn't seem to work. I was initially trying to achieve this using a MessageSet with XMLNS enabled but for some reason, the xmlns declaration never gets added to the root element, only to child elements, so this defeats the purpose of what I want to do. Any help with either approach will be appreciated.
Joined: 17 Oct 2003 Posts: 344 Location: IBM Hursley
The problem is that the input message is not using namespaces, so when parsed the elements are not in any namespace. As well as declaring a namespace you have to set the namespace of the elements to be in that namespace. The following ESQL should do it.
DECLARE sp1 NAMESPACE 'http://tempuri.org/';
SET OutputRoot.XMLNS = InputRoot.XMLNS;
SET OutputRoot.XMLNS.GetQuote NAMESPACE = sp1;
SET OutputRoot.XMLNS.sp1:GetQuote.test NAMESPACE = sp1;
SET OutputRoot.XMLNS.sp1:GetQuote.(XML.NamespaceDecl)xmlns = sp1;
Note that once the namespace has been set on GetQuote it must be referenced using that namespace.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum