You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2006/08/21 19:18:55 UTC
svn commit: r433292 -
/webservices/muse/trunk/modules/muse-util-xml/src/org/apache/muse/util/xml/XmlUtils.java
Author: danj
Date: Mon Aug 21 10:18:55 2006
New Revision: 433292
URL: http://svn.apache.org/viewvc?rev=433292&view=rev
Log:
Fixed setQNameNamespace() so that it does not add a prefix-namespace mapping to an element if the prefix is
already bound on the element (not its parents, though).
Modified:
webservices/muse/trunk/modules/muse-util-xml/src/org/apache/muse/util/xml/XmlUtils.java
Modified: webservices/muse/trunk/modules/muse-util-xml/src/org/apache/muse/util/xml/XmlUtils.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-util-xml/src/org/apache/muse/util/xml/XmlUtils.java?rev=433292&r1=433291&r2=433292&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-util-xml/src/org/apache/muse/util/xml/XmlUtils.java (original)
+++ webservices/muse/trunk/modules/muse-util-xml/src/org/apache/muse/util/xml/XmlUtils.java Mon Aug 21 10:18:55 2006
@@ -1529,7 +1529,8 @@
* @return The same Node as the second parameter (the new sub-tree).
*
*/
- public static Node moveSubTree(Node from, Node to, Node context) {
+ public static Node moveSubTree(Node from, Node to, Node context)
+ {
NodeList children = from.getChildNodes();
Node[] asArray = XmlUtils.convertToArray(children);
@@ -1543,11 +1544,11 @@
if (fromDoc != toDoc)
asArray[n] = toDoc.importNode(asArray[n], true);
- if(context == null) {
+ if(context == null)
to.appendChild(asArray[n]);
- } else {
+
+ else
to.insertBefore(asArray[n], context);
- }
}
return to;
@@ -1820,11 +1821,20 @@
*/
private static void setQNameNamespace(Element xml, QName value)
{
- String uri = value.getNamespaceURI();
- String prefix = value.getPrefix();
+ String elementPrefix = xml.getPrefix();
+
+ String valueURI = value.getNamespaceURI();
+ String valuePrefix = value.getPrefix();
- if (uri != null && uri.length() > 0)
- setNamespaceAttribute(xml, prefix, uri);
+ //
+ // check to make sure:
+ //
+ // 1. the value has a namespace URI
+ // 2. that the value's prefix isn't already bound on this element
+ //
+ if ((valueURI != null && valueURI.length() > 0) &&
+ (elementPrefix != null && valuePrefix.equals(elementPrefix)))
+ setNamespaceAttribute(xml, valuePrefix, valueURI);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org