http://java.sun.com/webservices/docs/1.0/api/javax/xml/soap/ SOAPElement.html#getNamespaceURI(java.lang.String)
here is javadoc:
/**
* Returns an iterator of namespace prefixes. The iterator can be used to get the namespace prefixes, which
* can then be passed to the method getNamespaceURI to retrieve the URI of each namespace.
* @return an iterator over the namespace prefixes in this SOAPElement object
*/
On Tuesday, November 5, 2002, at 08:14 AM, Davanum Srinivas wrote:
I don't either....It's there in the SAAJ API so we can't drop it.
(http://java.sun.com/webservices/docs/1.0/api/javax/xml/soap/ SOAPElement.html#getNamespacePrefixes())
Thanks,
dims
--- Glen Daniels <[EMAIL PROTECTED]> wrote:
Thanks, Dims!
What the heck is the point of getNamespacePrefixes(), anyway? Doesn't seem very useful to me,
unless you're trying to figure out a new prefix so it doesn't collide with an already-mapped
one. *shrug*
--Glen
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:dims@;apache.org]
Sent: Tuesday, November 05, 2002 10:53 AM
To: [EMAIL PROTECTED]
Subject: cvs commit: xml-axis/java/test/message
TestMessageElement.java
dims 2002/11/05 07:53:18
Modified: java/src/org/apache/axis/message MessageElement.java
java/test/message TestMessageElement.java
Log:
- Reworking previous Fix for Bug 14140 to prevent object creation.
- Checking in a test case as well.
Revision Changes Path
1.135 +16 -14
xml-axis/java/src/org/apache/axis/message/MessageElement.java
Index: MessageElement.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/message/MessageEle
ment.java,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -r1.134 -r1.135
--- MessageElement.java 5 Nov 2002 14:40:31 -0000 1.134
+++ MessageElement.java 5 Nov 2002 15:53:17 -0000 1.135
@@ -143,7 +143,7 @@
protected MessageElement parent = null;
- public ArrayList namespaces = new ArrayList();
+ public ArrayList namespaces = null;
/** Our encoding style, if any */
protected String encodingStyle = null;
@@ -301,7 +301,7 @@
* @return Attributes collection
*/
public Attributes getCompleteAttributes() {
- if (namespaces.size()==0)
+ if (namespaces == null)
return attributes;
AttributesImpl attrs = null;
@@ -447,8 +447,7 @@
public void setNSMappings(ArrayList namespaces)
{
- if(namespaces != null)
- this.namespaces = namespaces;
+ this.namespaces = namespaces;
}
public String getPrefix(String namespaceURI) {
@@ -459,7 +458,7 @@
return getRealElement().getPrefix(namespaceURI);
}
- for (int i = 0; i < namespaces.size(); i++) {
+ for (int i = 0; namespaces != null && i <
namespaces.size(); i++) {
Mapping map = (Mapping)namespaces.get(i);
if (map.getNamespaceURI().equals(namespaceURI))
return map.getPrefix();
@@ -479,7 +478,7 @@
return getRealElement().getNamespaceURI(prefix);
}
- for (int i = 0; i < namespaces.size(); i++) {
+ for (int i = 0; namespaces != null && i <
namespaces.size(); i++) {
Mapping map = (Mapping)namespaces.get(i);
if (map.getPrefix().equals(prefix)) {
return map.getNamespaceURI();
@@ -780,10 +779,12 @@
if (prefix != null)
context.registerPrefixForURI(prefix, namespaceURI);
- for (Iterator i = namespaces.iterator(); i.hasNext();) {
- Mapping mapping = (Mapping) i.next();
-
context.registerPrefixForURI(mapping.getPrefix(),
mapping.getNamespaceURI());
- }
+ if (namespaces != null) {
+ for (Iterator i = namespaces.iterator();
i.hasNext();) {
+ Mapping mapping = (Mapping) i.next();
+
context.registerPrefixForURI(mapping.getPrefix(),
mapping.getNamespaceURI());
+ }
+ }
if (objectValue != null) {
context.serialize(new QName(namespaceURI, name),
@@ -812,6 +813,8 @@
}
public void addMapping(Mapping map) {
+ if (namespaces == null)
+ namespaces = new ArrayList();
namespaces.add(map);
}
@@ -1033,9 +1036,8 @@
// getNamespaceURI implemented above
public Iterator getNamespacePrefixes() {
- int num = namespaces.size();
- Vector prefixes = new Vector(num);
- for (int i = 0; i < num; i++) {
+ Vector prefixes = new Vector();
+ for (int i = 0; namespaces != null && i <
namespaces.size(); i++) {
prefixes.add(((Mapping)namespaces.get(i)).getPrefix());
}
return prefixes.iterator();
@@ -1063,7 +1065,7 @@
AttributesImpl attributes = makeAttributesEditable();
boolean removed = false;
- for (int i = 0; i < namespaces.size() && !removed; i++) {
+ for (int i = 0; namespaces != null && i <
namespaces.size() && !removed; i++) {
if
(((Mapping)namespaces.get(i)).getPrefix().equals(prefix)) {
namespaces.remove(i);
removed = true;
1.7 +8 -1
xml-axis/java/test/message/TestMessageElement.java
Index: TestMessageElement.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/test/message/TestMessageElement.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TestMessageElement.java 4 Nov 2002 19:51:20 -0000 1.6
+++ TestMessageElement.java 5 Nov 2002 15:53:18 -0000 1.7
@@ -178,8 +178,15 @@
assertTrue("Did not find namespace declaration
\"pre\"", found);
}
+ public void testGetNamespacePrefixes() throws Exception {
+ MessageElement me =
+ new MessageElement("http://www.wolfram.com","Test");
+ Iterator it = me.getNamespacePrefixes();
+ assertTrue(it != null);
+ }
+
public static void main(String[] args) throws Exception {
TestMessageElement tester = new
TestMessageElement("TestMessageElement");
- tester.testAddNamespaceDeclaration();
+ tester.testGetNamespacePrefixes();
}
}
===== Davanum Srinivas - http://xml.apache.org/~dims/__________________________________________________ Do you Yahoo!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/