1 23 24 package com.sun.enterprise.webservice.monitoring; 25 26 import java.util.Iterator ; 27 import java.util.Vector ; 28 import javax.xml.namespace.NamespaceContext ; 29 import javax.xml.XMLConstants ; 30 31 import org.w3c.dom.Document ; 32 import org.w3c.dom.NamedNodeMap ; 33 import org.w3c.dom.Node ; 34 39 public class NamespaceContextImpl implements NamespaceContext { 40 41 42 public NamespaceContextImpl(Document wsdlDoc) { 43 NamedNodeMap attributes = wsdlDoc.getAttributes(); 45 if (attributes==null) 46 return; 47 for (int i=0;i<attributes.getLength();i++) { 48 Node attribute = attributes.item(i); 49 System.out.println("attribute " + attribute.getNodeName() + " value " + attribute.getNodeValue()); 50 } 51 } 52 53 60 public String getNamespaceURI(String prefix) { 61 if (prefix==null) { 62 throw new IllegalArgumentException ("prefix is null"); 63 } 64 if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) { 65 return "http://schemas.xmlsoap.org/wsdl/"; 66 } 67 if (XMLConstants.XML_NS_PREFIX.equals(prefix)) { 68 return XMLConstants.XML_NS_URI; 69 } 70 if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { 71 return XMLConstants.XMLNS_ATTRIBUTE_NS_URI; 72 } 73 if ("soap".equals(prefix)) { 74 return "http://schemas.xmlsoap.org/wsdl/soap/"; 75 } 76 if ("soap12".equals(prefix)) { 77 return "http://schemas.xmlsoap.org/wsdl/soap12/"; 78 } 79 return XMLConstants.NULL_NS_URI; 80 } 81 82 89 public String getPrefix(String namespace) { 90 if (namespace==null) { 91 throw new IllegalArgumentException ("namespace is null"); 92 } 93 if ("http://schemas.xmlsoap.org/wsdl/".equals(namespace)) { 94 return XMLConstants.DEFAULT_NS_PREFIX; 95 } 96 if (XMLConstants.XML_NS_URI.equals(namespace)) { 97 return XMLConstants.XML_NS_PREFIX; 98 } 99 if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespace)) { 100 return XMLConstants.XMLNS_ATTRIBUTE; 101 } 102 if ("http://schemas.xmlsoap.org/wsdl/soap/".equals(namespace)) { 103 return "soap"; 104 } 105 if(("http://schemas.xmlsoap.org/wsdl/soap12/").equals(namespace)) { 106 return "soap12"; 107 } 108 return null; 109 } 110 111 118 public Iterator getPrefixes(String namespaceURI) { 119 Vector v = new Vector (); 120 String prefix = getPrefix(namespaceURI); 121 if (prefix!=null) { 122 v.add(prefix); 123 } 124 return v.iterator(); 125 } 126 } 127 | Popular Tags |