This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Trying to add xmlns attribute to a <result> tag in my xml response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Trying to add xmlns attribute to a <result> tag in my xml response" Watch "Trying to add xmlns attribute to a <result> tag in my xml response" New topic
Author

Trying to add xmlns attribute to a <result> tag in my xml response

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

I have an xml response from a bpel process. It has a <result> tag that includes all of the xml I need to parse. I need to make that <result> tag have an attribute - xmlns="http://..." - That means it would look like <result xmlns="http://...">

Here is the result <tag> in part of the actual response:



I need it to have an attribute xmlns="http://..." <result xmlns="htp://....">

Here is my .xsd file which has the only reference to the <result> tag I can seem to find (It is at the bottom):



So is there a new tag I will need to add nested within that <element name="result" type="string"/> tag, or do I need to add a new attribute to it? Or is there another way

It would be great if someone could help me with this one.

Thanks very much


True wisdom is in knowing you know nothing - Socrates
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18113
    
    8

You mean, you want to declare that element to be in the default namespace with a particular namespace URI. I don't know much about schema but if you use the standard terminology you're more likely to be able to find the answer in the documentation.

Oh wait a minute... you said you want to parse it and it has to have that namespace declaration. In that case you'll have to contact whoever is producing the document and ask them to fix it. Or are you the one producing it? I'm a bit confused about what you are asking.

Edit: I looked again at the XML you're complaining about and that <result> element (not "tag", let's use the standard terminology) is already in the default namespace. The default namespace is inherited from its parent. You'll notice that the <QUOTE> element which is the child of the <result> element redeclares the default namespace so that it isn't in any namespace. So now I'm a lot confused about what you are asking. Can you go back a step and ask the earlier question which you thought adding a namespace declaration was the answer to?
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

I should start then by saying I am migrating some bpel processes from oas10 to weblogic

I have some pl sql that parses the xml



The last variable on each line, v_quote_name_space is causing an issue. If I remove it altogether my stuff works fine, but if it is there my process gets hung up and will not complete (it goes down to the end of the if-statement containing that pl sql).

I looked at the old version of the response xml, and it looks like this:



If you compare that to the current response xml the only real difference is that <response> element is missing the xmlns="" definition:



So I thought that meant I needed to add it there, but maybe I am wrong about that entirely then? I wish removing the v_quote_name_space variable from the pl sql were an option, but it is not.

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18113
    
    8

Okay, I see. But what has actually changed is that in the new format you have this:

Which declares that the <QUOTE_XML> element and all its children are not in any namespace. Whereas in the old format, they were in the "http://xmlns.oracle.com/Get_Quote_XML" namespace. Presumably that namespace URI is the value of the v_quote_name_space variable in that PL-SQL code?

It seems to me that you want that <QUOTE_XML> element to just inherit the default namespace from its parent. Or are you looking for fixes to your PL-SQL code to make it work as before?

I have no idea how to achieve the former. As for the latter, I know basically nothing about PL-SQL but I would hazard a guess that there's a version of the EXTRACTVALUE function which doesn't take the third (namespace) parameter.
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

You are exactly right. In your assumptions and the pl sql fix. Unfortunately the pl sql fix is not an option, but I do have a better idea of what I need to do now. Thanks very much!
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Turns out removing the name_space from the pl sql was the best option, so that is what I did; if you were wondering about it.
Turns out, that name_space variable was only there because it had to be there due to the way our old web services worked, so with the migrated version, this was no longer needed, so I just struck it from the code altogether. Made for an easy fix, and easier to debug pl sql code

Thanks for your help Paul, you always are able to set me on the right path.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to add xmlns attribute to a <result> tag in my xml response
 
Similar Threads
Please help me with ksoap!
how do I set xsd element attributes?
need a point in the right direction using XMLTYPE, dbms_xmlgen.convert, dbms_xmlgen.ENTITY_DECODE
Using WS-RM with Axis2 1.5?
need to add namespace to <result> tag from a .jca file