You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by TMG <tm...@nc.rr.com> on 2004/11/21 02:11:26 UTC
Patch for MessageElement problem
Axis Developers,
I ran into the same problem with RC1 and RC2 as describe about the
problem with qname part.
I believe the problem is with the copyNode method in MessageElement.
In brief, I don't believe it is/was handling DOM 1/2 correctly - using
getNodeValue() vs. getNodeName(). I tried to follow other
implementations in the code as to checking for null, then assuming DOM
1/2. Maybe there is a more elegant way, but this solves the problem. I
let recursion handle assigning the qname to the element versus trying to
force set it using PrefixedQName. The problem is/was with using
PrefixedQName is/was the second argument to the method always using only
one method to get local qname (so failed when it was the other type of
DOM).
A diff follows if you want to try/patch:
2010a2011,2014
> else
> {
> dest.setQName(new QName(source.getNamespaceURI(),
source.getNodeName()));
> }
2045,2048c2049
< PrefixedQName qname = new
PrefixedQName(child.getNamespaceURI(),
< child.getLocalName(),
< child.getPrefix());
< MessageElement childElement = new MessageElement(qname);
---
> MessageElement childElement = new MessageElement();
Thus, the whole method would be (if you have already started hacking it):
private void copyNode(MessageElement dest, org.w3c.dom.Node source)
{
dest.setPrefix(source.getPrefix());
if(source.getLocalName() != null) {
dest.setQName(new QName(source.getNamespaceURI(),
source.getLocalName()));
}
else
{
dest.setQName(new QName(source.getNamespaceURI(),
source.getNodeName()));
}
NamedNodeMap attrs = source.getAttributes();
for(int i = 0; i < attrs.getLength(); i++){
Node att = attrs.item(i);
if (att.getNamespaceURI() != null &&
att.getPrefix() != null &&
att.getNamespaceURI().equals(Constants.NS_URI_XMLNS) &&
"xmlns".equals(att.getPrefix())) {
Mapping map = new Mapping(att.getNodeValue(),
att.getLocalName());
addMapping(map);
}
if(att.getLocalName() != null) {
dest.addAttribute(att.getPrefix(),
(att.getNamespaceURI() != null ?
att.getNamespaceURI() : ""),
att.getLocalName(),
att.getNodeValue());
} else if (att.getNodeName() != null) {
dest.addAttribute(att.getPrefix(),
(att.getNamespaceURI() != null ?
att.getNamespaceURI() : ""),
att.getNodeName(),
att.getNodeValue());
}
}
NodeList children = source.getChildNodes();
for(int i = 0; i < children.getLength(); i++){
Node child = children.item(i);
if(child.getNodeType()==TEXT_NODE ||
child.getNodeType()==CDATA_SECTION_NODE ||
child.getNodeType()==COMMENT_NODE ) {
org.apache.axis.message.Text childElement =
new org.apache.axis.message.Text((CharacterData)child);
dest.appendChild(childElement);
} else {
MessageElement childElement = new MessageElement();
dest.appendChild(childElement);
copyNode(childElement, child);
}
}
}
Sincerely,
Tom Gordon
Re: Patch for MessageElement problem
Posted by TMG <tm...@nc.rr.com>.
Done.
Axis-1678 (http://nagoya.apache.org/jira/browse/AXIS-1678) is the issue
(bug) number.
Tom Gordon
Davanum Srinivas wrote:
>tom,
>
>diff got scrambled as it is part of an email. Can you please open a
>JIRA issue? (and please submit a "diff -u"?)
>
>thanks,
>dims
>
>
>On Sat, 20 Nov 2004 20:11:26 -0500, TMG <tm...@nc.rr.com> wrote:
>
>
>>Axis Developers,
>>
>>I ran into the same problem with RC1 and RC2 as describe about the
>>problem with qname part.
>>
>>I believe the problem is with the copyNode method in MessageElement.
>>
>>In brief, I don't believe it is/was handling DOM 1/2 correctly - using
>>getNodeValue() vs. getNodeName(). I tried to follow other
>>implementations in the code as to checking for null, then assuming DOM
>>1/2. Maybe there is a more elegant way, but this solves the problem. I
>>let recursion handle assigning the qname to the element versus trying to
>>force set it using PrefixedQName. The problem is/was with using
>>PrefixedQName is/was the second argument to the method always using only
>>one method to get local qname (so failed when it was the other type of
>>DOM).
>>
>>A diff follows if you want to try/patch:
>>
>>2010a2011,2014
>> > else
>> > {
>> > dest.setQName(new QName(source.getNamespaceURI(),
>>source.getNodeName()));
>> > }
>>2045,2048c2049
>>< PrefixedQName qname = new
>>PrefixedQName(child.getNamespaceURI(),
>>< child.getLocalName(),
>>< child.getPrefix());
>>< MessageElement childElement = new MessageElement(qname);
>>---
>> > MessageElement childElement = new MessageElement();
>>
>>Thus, the whole method would be (if you have already started hacking it):
>>
>> private void copyNode(MessageElement dest, org.w3c.dom.Node source)
>> {
>> dest.setPrefix(source.getPrefix());
>> if(source.getLocalName() != null) {
>> dest.setQName(new QName(source.getNamespaceURI(),
>>source.getLocalName()));
>> }
>> else
>> {
>> dest.setQName(new QName(source.getNamespaceURI(),
>>source.getNodeName()));
>> }
>>
>> NamedNodeMap attrs = source.getAttributes();
>> for(int i = 0; i < attrs.getLength(); i++){
>> Node att = attrs.item(i);
>> if (att.getNamespaceURI() != null &&
>> att.getPrefix() != null &&
>> att.getNamespaceURI().equals(Constants.NS_URI_XMLNS) &&
>> "xmlns".equals(att.getPrefix())) {
>> Mapping map = new Mapping(att.getNodeValue(),
>>att.getLocalName());
>> addMapping(map);
>> }
>> if(att.getLocalName() != null) {
>> dest.addAttribute(att.getPrefix(),
>> (att.getNamespaceURI() != null ?
>>att.getNamespaceURI() : ""),
>> att.getLocalName(),
>> att.getNodeValue());
>> } else if (att.getNodeName() != null) {
>> dest.addAttribute(att.getPrefix(),
>> (att.getNamespaceURI() != null ?
>>att.getNamespaceURI() : ""),
>> att.getNodeName(),
>> att.getNodeValue());
>> }
>> }
>>
>> NodeList children = source.getChildNodes();
>> for(int i = 0; i < children.getLength(); i++){
>> Node child = children.item(i);
>> if(child.getNodeType()==TEXT_NODE ||
>> child.getNodeType()==CDATA_SECTION_NODE ||
>> child.getNodeType()==COMMENT_NODE ) {
>> org.apache.axis.message.Text childElement =
>> new org.apache.axis.message.Text((CharacterData)child);
>> dest.appendChild(childElement);
>> } else {
>> MessageElement childElement = new MessageElement();
>> dest.appendChild(childElement);
>> copyNode(childElement, child);
>> }
>> }
>> }
>>
>>Sincerely,
>>
>>Tom Gordon
>>
>>
>>
>
>
>
>
Re: Patch for MessageElement problem
Posted by Davanum Srinivas <da...@gmail.com>.
tom,
diff got scrambled as it is part of an email. Can you please open a
JIRA issue? (and please submit a "diff -u"?)
thanks,
dims
On Sat, 20 Nov 2004 20:11:26 -0500, TMG <tm...@nc.rr.com> wrote:
> Axis Developers,
>
> I ran into the same problem with RC1 and RC2 as describe about the
> problem with qname part.
>
> I believe the problem is with the copyNode method in MessageElement.
>
> In brief, I don't believe it is/was handling DOM 1/2 correctly - using
> getNodeValue() vs. getNodeName(). I tried to follow other
> implementations in the code as to checking for null, then assuming DOM
> 1/2. Maybe there is a more elegant way, but this solves the problem. I
> let recursion handle assigning the qname to the element versus trying to
> force set it using PrefixedQName. The problem is/was with using
> PrefixedQName is/was the second argument to the method always using only
> one method to get local qname (so failed when it was the other type of
> DOM).
>
> A diff follows if you want to try/patch:
>
> 2010a2011,2014
> > else
> > {
> > dest.setQName(new QName(source.getNamespaceURI(),
> source.getNodeName()));
> > }
> 2045,2048c2049
> < PrefixedQName qname = new
> PrefixedQName(child.getNamespaceURI(),
> < child.getLocalName(),
> < child.getPrefix());
> < MessageElement childElement = new MessageElement(qname);
> ---
> > MessageElement childElement = new MessageElement();
>
> Thus, the whole method would be (if you have already started hacking it):
>
> private void copyNode(MessageElement dest, org.w3c.dom.Node source)
> {
> dest.setPrefix(source.getPrefix());
> if(source.getLocalName() != null) {
> dest.setQName(new QName(source.getNamespaceURI(),
> source.getLocalName()));
> }
> else
> {
> dest.setQName(new QName(source.getNamespaceURI(),
> source.getNodeName()));
> }
>
> NamedNodeMap attrs = source.getAttributes();
> for(int i = 0; i < attrs.getLength(); i++){
> Node att = attrs.item(i);
> if (att.getNamespaceURI() != null &&
> att.getPrefix() != null &&
> att.getNamespaceURI().equals(Constants.NS_URI_XMLNS) &&
> "xmlns".equals(att.getPrefix())) {
> Mapping map = new Mapping(att.getNodeValue(),
> att.getLocalName());
> addMapping(map);
> }
> if(att.getLocalName() != null) {
> dest.addAttribute(att.getPrefix(),
> (att.getNamespaceURI() != null ?
> att.getNamespaceURI() : ""),
> att.getLocalName(),
> att.getNodeValue());
> } else if (att.getNodeName() != null) {
> dest.addAttribute(att.getPrefix(),
> (att.getNamespaceURI() != null ?
> att.getNamespaceURI() : ""),
> att.getNodeName(),
> att.getNodeValue());
> }
> }
>
> NodeList children = source.getChildNodes();
> for(int i = 0; i < children.getLength(); i++){
> Node child = children.item(i);
> if(child.getNodeType()==TEXT_NODE ||
> child.getNodeType()==CDATA_SECTION_NODE ||
> child.getNodeType()==COMMENT_NODE ) {
> org.apache.axis.message.Text childElement =
> new org.apache.axis.message.Text((CharacterData)child);
> dest.appendChild(childElement);
> } else {
> MessageElement childElement = new MessageElement();
> dest.appendChild(childElement);
> copyNode(childElement, child);
> }
> }
> }
>
> Sincerely,
>
> Tom Gordon
>
--
Davanum Srinivas - http://webservices.apache.org/~dims/