Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcsalter2006-07-19 04:35:37 +0000
committercsalter2006-07-19 04:35:37 +0000
commit1e8d1163820e6ae8bf994ba24b966ce5fbe1e09a (patch)
tree4a76db793baeeb069f3d3132f58be8c37b1f1d53
parent5e87f11d48bc65c6d24095ea8ba0d0a2398ac3c7 (diff)
downloadwebtools.webservices-1e8d1163820e6ae8bf994ba24b966ce5fbe1e09a.tar.gz
webtools.webservices-1e8d1163820e6ae8bf994ba24b966ce5fbe1e09a.tar.xz
webtools.webservices-1e8d1163820e6ae8bf994ba24b966ce5fbe1e09a.zip
[150553] Support local namespace prefix declarations
-rw-r--r--bundles/org.eclipse.wst.wsdl/src-soap/org/eclipse/wst/wsdl/binding/soap/internal/impl/SOAPHeaderBaseImpl.java2
-rw-r--r--bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingImpl.java2
-rw-r--r--bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageReferenceImpl.java2
-rw-r--r--bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PartImpl.java5
-rw-r--r--bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortImpl.java3
-rw-r--r--bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/WSDLElementImpl.java96
6 files changed, 98 insertions, 12 deletions
diff --git a/bundles/org.eclipse.wst.wsdl/src-soap/org/eclipse/wst/wsdl/binding/soap/internal/impl/SOAPHeaderBaseImpl.java b/bundles/org.eclipse.wst.wsdl/src-soap/org/eclipse/wst/wsdl/binding/soap/internal/impl/SOAPHeaderBaseImpl.java
index 32101d3a3..3ccc3a2dc 100644
--- a/bundles/org.eclipse.wst.wsdl/src-soap/org/eclipse/wst/wsdl/binding/soap/internal/impl/SOAPHeaderBaseImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-soap/org/eclipse/wst/wsdl/binding/soap/internal/impl/SOAPHeaderBaseImpl.java
@@ -480,7 +480,7 @@ public class SOAPHeaderBaseImpl extends ExtensibilityElementImpl implements SOAP
if (element != null && element.hasAttribute(SOAPConstants.MESSAGE_ATTRIBUTE))
{
Definition definition = getEnclosingDefinition();
- QName messageQName = createQName(definition, element.getAttribute(SOAPConstants.MESSAGE_ATTRIBUTE));
+ QName messageQName = createQName(definition, element.getAttribute(SOAPConstants.MESSAGE_ATTRIBUTE), element);
Message newMessage = (messageQName != null) ? (Message) definition.getMessage(messageQName) : null;
if (newMessage != null && newMessage != getMessage())
setMessage(newMessage);
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingImpl.java
index 1b46347b4..4fca0c097 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingImpl.java
@@ -774,7 +774,7 @@ public class BindingImpl extends ExtensibleElementImpl implements Binding
if (element != null)
{
Definition definition = (Definition) getEnclosingDefinition();
- QName portTypeQName = createQName(definition, element.getAttribute("type"));
+ QName portTypeQName = createQName(definition, element.getAttribute(WSDLConstants.TYPE_ATTRIBUTE), element);
PortType newPortType = portTypeQName != null ? (PortType) definition.getPortType(portTypeQName) : null;
if (newPortType != getEPortType())
{
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageReferenceImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageReferenceImpl.java
index 96a7b9004..9e84b8474 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageReferenceImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageReferenceImpl.java
@@ -332,7 +332,7 @@ public abstract class MessageReferenceImpl extends WSDLElementImpl implements Me
if (element != null)
{
Definition definition = getEnclosingDefinition();
- QName messageQName = createQName(definition, element.getAttribute("message"));
+ QName messageQName = createQName(definition, element.getAttribute(WSDLConstants.MESSAGE_ATTRIBUTE), element);
Message newMessage = messageQName != null ? (Message) definition.getMessage(messageQName) : null;
if (newMessage != getEMessage())
{
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PartImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PartImpl.java
index 670da206f..1e1dac0f2 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PartImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PartImpl.java
@@ -380,7 +380,6 @@ public class PartImpl extends WSDLElementImpl implements Part
public void setExtensionAttribute(QName name, QName value)
{
String localName = name.getLocalPart();
- String nsURI = name.getNamespaceURI();
if (localName == null)
return;
@@ -647,10 +646,10 @@ public class PartImpl extends WSDLElementImpl implements Part
}
String elementAttr = WSDLConstants.getAttribute(changedElement, WSDLConstants.ELEMENT_ATTRIBUTE);
- setElementName(elementAttr != null ? createQName(definition, elementAttr) : null);
+ setElementName(elementAttr != null ? createQName(definition, elementAttr, element) : null);
String typeAttr = WSDLConstants.getAttribute(changedElement, WSDLConstants.TYPE_ATTRIBUTE);
- setTypeName(typeAttr != null ? createQName(definition, typeAttr) : null);
+ setTypeName(typeAttr != null ? createQName(definition, typeAttr, element) : null);
reconcileReferences(false);
}
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortImpl.java
index d1f9403fe..44a80a058 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortImpl.java
@@ -340,7 +340,6 @@ public class PortImpl extends ExtensibleElementImpl implements Port
public void reconcileAttributes(Element changedElement)
{
- Definition definition = getEnclosingDefinition();
setName(changedElement.getAttribute("name"));
reconcileReferences(false);
}
@@ -425,7 +424,7 @@ public class PortImpl extends ExtensibleElementImpl implements Port
if (element != null)
{
Definition definition = getEnclosingDefinition();
- QName bindingQName = createQName(definition, element.getAttribute("binding"));
+ QName bindingQName = createQName(definition, element.getAttribute(WSDLConstants.BINDING_ATTRIBUTE), element);
Binding newBinding = (bindingQName != null) ? (Binding) definition.getBinding(bindingQName) : null;
if (newBinding != getEBinding())
{
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/WSDLElementImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/WSDLElementImpl.java
index 1b9a1469b..607433105 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/WSDLElementImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/WSDLElementImpl.java
@@ -37,6 +37,7 @@ import org.eclipse.wst.wsdl.WSDLElement;
import org.eclipse.wst.wsdl.WSDLPackage;
import org.eclipse.wst.wsdl.util.WSDLConstants;
import org.eclipse.xsd.util.XSDConstants;
+import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -707,13 +708,11 @@ public abstract class WSDLElementImpl extends EObjectImpl implements WSDLElement
}
}
- boolean isNew = false;
if (childElement == null)
{
((WSDLElementImpl)wsdlElement).isReconciling = true;
childElement = ((WSDLElementImpl)wsdlElement).createElement();
((WSDLElementImpl)wsdlElement).isReconciling = false;
- isNew = true;
if (childElement == null)
{
//System.out.println("not created! " + wsdlElement);
@@ -978,12 +977,43 @@ public abstract class WSDLElementImpl extends EObjectImpl implements WSDLElement
// Some subclasses use this method
protected QName createQName(Definition definition, String prefixedName)
{
+ // Delegate to the new form to preserve backward compatibility in case someone
+ // else calls this method.
+
+ return createQName(definition, prefixedName, null);
+ }
+
+ /**
+ * Creates a QName from a prefixed name. Takes into account locally defined
+ * namespace prefixes.
+ *
+ * @param definition
+ * the enclosing definition. Must not be null.
+ * @param prefixedName
+ * the prefixed name to convert to QName
+ * @param element
+ * the enclosing element. May be null in which case the prefix is
+ * only looked up among the ones defined at the definition level.
+ * @return the QName equivalent for the given prefixed name, or null if a
+ * namespace prefix cannot be found for the given namespace URI or if
+ * the prefixed name is null.
+ */
+ protected QName createQName(Definition definition, String prefixedName, Element element)
+ {
QName qname = null;
if (prefixedName != null)
{
- int index = prefixedName.indexOf(":");
- String prefix = (index == -1) ? "" : prefixedName.substring(0, index);
+ int index = prefixedName.indexOf(":"); ////$NON-NLS-1$
+ String prefix = (index == -1) ? "" : prefixedName.substring(0, index); //$NON-NLS-1$
String namespace = definition.getNamespace(prefix);
+
+ if (namespace == null && element != null)
+ {
+ // Try to find a locally defined namespace prefix.
+
+ namespace = getNamespaceURIFromPrefix(element, prefix);
+ }
+
if (namespace != null)
{
String localPart = prefixedName.substring(index + 1);
@@ -993,6 +1023,64 @@ public abstract class WSDLElementImpl extends EObjectImpl implements WSDLElement
return qname;
}
+ /**
+ * Given a prefix and a node, finds the namespace URI pointed to by the
+ * prefix. Walks the element containment hierarchy until it finds one or it
+ * reaches the document root.
+ *
+ * @param node
+ * the starting node
+ * @param prefix
+ * the prefix to find an xmlns:prefix=uri for
+ *
+ * @return the namespace URI or null if not found
+ */
+ private static String getNamespaceURIFromPrefix(Node node, String prefix)
+ {
+ if (node == null || prefix == null)
+ {
+ return null;
+ }
+
+ Node currentNode = node;
+
+ while (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE)
+ {
+ String namespaceURI = getAttributeNS((Element) currentNode, XSDConstants.XMLNS_URI_2000, prefix);
+
+ if (namespaceURI != null)
+ {
+ return namespaceURI;
+ }
+ else
+ {
+ currentNode = currentNode.getParentNode();
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Retrieves an attribute's value.
+ * @param element the containing element.
+ * @param namespaceURI the namespace URI.
+ * @param localPart the local name.
+ * @return the attribute's value if present, or null if not.
+ */
+ private static String getAttributeNS(Element element, String namespaceURI, String localPart)
+ {
+ String attributeValue = null;
+ Attr attribute = element.getAttributeNodeNS(namespaceURI, localPart);
+
+ if (attribute != null)
+ {
+ attributeValue = attribute.getValue();
+ }
+
+ return attributeValue;
+ }
+
//
// For reconciliation: Model -> DOM
//

Back to the top