ws-wsrf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r227033 [18/27] - in /webservices/wsrf/trunk: ./ src/java/org/apache/ws/ src/java/org/apache/ws/addressing/ src/java/org/apache/ws/addressing/v2003_03/ src/java/org/apache/ws/addressing/v2004_08_10/ src/java/org/apache/ws/resource/ src/java...
Date Tue, 02 Aug 2005 16:30:44 GMT
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/SaajUtils.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/SaajUtils.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/SaajUtils.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/SaajUtils.java Tue Aug  2 09:28:49 2005
@@ -20,7 +20,6 @@
 import org.apache.ws.util.i18n.Messages;
 import org.apache.ws.util.i18n.MessagesImpl;
 import org.w3c.dom.Element;
-
 import javax.xml.namespace.QName;
 import javax.xml.soap.Detail;
 import javax.xml.soap.DetailEntry;
@@ -40,237 +39,239 @@
  */
 public abstract class SaajUtils
 {
-    public static final Messages MSG = MessagesImpl.getInstance();
-
-    /**
-     * Given a {@link SOAPElement}, returns a list containing the children of that element. If at least one of the
-     * children is a SOAPElement, any {@link Text} nodes are excluded from the list. This is because it is assumed that
-     * if the specified element has mixed content, it is only because of insignificant whitespace text nodes.
-     *
-     * @param soapElem a SAAJ {@link SOAPElement}
-     *
-     * @return a list containing the children of the specified {@link SOAPElement}
-     */
-    public static List getChildNodes( SOAPElement soapElem )
-    {
-        List elem_children = new ArrayList();
-        List text_children = new ArrayList();
-        Iterator node_iter = soapElem.getChildElements();
-
-        while ( node_iter.hasNext() )
-        {
-            Node child_node = (Node) node_iter.next();
-
-            if ( isSOAPElement( child_node ) )
-            {
-                elem_children.add( child_node );
-            }
-            else
-            {
-                text_children.add( child_node );
-            }
-        }
-
-        return ( elem_children.isEmpty() ? text_children : elem_children );
-    }
-
-    /**
-     * DOCUMENT_ME
-     *
-     * @param elem DOCUMENT_ME
-     *
-     * @return DOCUMENT_ME
-     */
-    public static QName getQualifiedName( SOAPElement elem )
-    {
-        return ( elem != null ) ? NameUtils.toQName( elem.getElementName() ) : null;
-    }
-
-    /**
-     * Returns true if the specified SAAJ node is an element, or false otherwise.
-     *
-     * @param soap_node a SAAJ node
-     *
-     * @return true if the specified SAAJ node is an element, or false otherwise
-     */
-    public static boolean isSOAPElement( Node soap_node )
-    {
-        // NOTE: the second condition below is nessary for Axis, because its Text impl also implements SOAPElement
-        return ( soap_node instanceof SOAPElement && !( soap_node instanceof Text ) );
-    }
-
-    /**
-     * Returns true if the specified SAAJ node is text, or false otherwise.
-     *
-     * @param soap_node a SAAJ node
-     *
-     * @return true if the specified SAAJ node is text, or false otherwise
-     */
-    public static boolean isText( Node soap_node )
-    {
-        return ( soap_node instanceof Text );
-    }
-
-    /**
-     * Returns the value of the specified SAAJ text node.
-     *
-     * @param soapNode a SAAJ text node
-     *
-     * @return the value of the specified SAAJ text node
-     *
-     * @throws SOAPException
-     */
-    public static String getValue( Node soapNode )
-            throws SOAPException
-    {
-        if ( soapNode == null )
-        {
-            throw new IllegalArgumentException( MSG.getMessage( Keys.PARAM_MAY_NOT_BE_NULL ) );
-        }
-
-        if ( isText( soapNode ) )
-        {
-            return getTextValue( (Text) soapNode );
-        }
-        else
-        {
-            return getSOAPElementValue( (SOAPElement) soapNode );
-        }
-    }
-
-    /**
-     * DOCUMENT_ME
-     *
-     * @param soapElem DOCUMENT_ME
-     * @param value    DOCUMENT_ME
-     *
-     * @throws SOAPException DOCUMENT_ME
-     */
-    public static void addTextNode( SOAPElement soapElem,
-                                    String value )
-            throws SOAPException
-    {
-        soapElem.addTextNode( value );
-
-        if ( soapElem.getValue() == null )
-        {
-            Iterator childElemIter = soapElem.getChildElements();
-
-            if ( childElemIter.hasNext() )
-            {
-                Node firstChild = (Node) childElemIter.next();
+   /** DOCUMENT_ME */
+   public static final Messages MSG = MessagesImpl.getInstance(  );
 
-                if ( firstChild instanceof Text )
-                {
-                    firstChild.setValue( value );
-
-                    return;
-                }
-            }
-        }
-    }
-
-    /**
-     * DOCUMENT_ME
-     *
-     * @param value DOCUMENT_ME
-     *
-     * @return DOCUMENT_ME
-     *
-     * @throws SOAPException DOCUMENT_ME
-     */
-    public static Text createTextNode( String value )
-            throws SOAPException
-    {
-        return ( (Text) SOAPFactory.newInstance().createElement( "foo" ).addTextNode( value ).getChildElements()
-                .next() );
-    }
-
-    /**
-     * Converts a DOM {@link org.w3c.dom.Element} to a SAAJ {@link javax.xml.soap.SOAPElement}.
-     *
-     * @param elem a DOM {@link org.w3c.dom.Element}
-     *
-     * @return a {@link javax.xml.soap.SOAPElement}
-     *
-     * @throws javax.xml.soap.SOAPException
-     */
-    public static SOAPElement toSOAPElement( Element elem )
-            throws SOAPException
-    {
-        return ( new Dom2SaajConverter().toSOAPElement( elem ) );
-    }
-
-    /**
-     * Adds a DOM {@link org.w3c.dom.Element} as an entry to a SAAJ {@link Detail}.
-     *
-     * @param detail  a SAAJ detail
-     * @param domElem a DOM element to be added as an entry in the specified detail
-     *
-     * @return a SAAJ detail entry
-     *
-     * @throws javax.xml.soap.SOAPException
-     */
-    public static DetailEntry addDetailEntry( Detail detail, Element domElem )
-            throws SOAPException
-    {
-        return ( new Dom2SaajConverter().addDetailEntry( detail, domElem ) );
-    }
-
-    private static String getSOAPElementValue( SOAPElement soapElem )
-    {
-        String value = soapElem.getValue();
-
-        if ( value == null )
-        {
-            Text textNode = getTextNode( soapElem );
-
-            if ( textNode != null )
-            {
-                value = textNode.getValue();
-            }
-        }
-
-        if ( value == null )
-        {
-            value = soapElem.getNodeValue();
-        }
-
-        return value;
-    }
-
-    private static Text getTextNode( SOAPElement soapElem )
-    {
-        Iterator childElemIter = soapElem.getChildElements();
-
-        if ( childElemIter.hasNext() )
-        {
-            Node firstChild = (Node) childElemIter.next();
+   /**
+    * Given a {@link SOAPElement}, returns a list containing the children of that element. If at least one of the
+    * children is a SOAPElement, any {@link Text} nodes are excluded from the list. This is because it is assumed that
+    * if the specified element has mixed content, it is only because of insignificant whitespace text nodes.
+    *
+    * @param soapElem a SAAJ {@link SOAPElement}
+    *
+    * @return a list containing the children of the specified {@link SOAPElement}
+    */
+   public static List getChildNodes( SOAPElement soapElem )
+   {
+      List     elem_children = new ArrayList(  );
+      List     text_children = new ArrayList(  );
+      Iterator node_iter     = soapElem.getChildElements(  );
+
+      while ( node_iter.hasNext(  ) )
+      {
+         Node child_node = (Node) node_iter.next(  );
+
+         if ( isSOAPElement( child_node ) )
+         {
+            elem_children.add( child_node );
+         }
+         else
+         {
+            text_children.add( child_node );
+         }
+      }
+
+      return ( elem_children.isEmpty(  ) ? text_children : elem_children );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param elem DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static QName getQualifiedName( SOAPElement elem )
+   {
+      return ( elem != null ) ? NameUtils.toQName( elem.getElementName(  ) ) : null;
+   }
+
+   /**
+    * Returns true if the specified SAAJ node is an element, or false otherwise.
+    *
+    * @param soap_node a SAAJ node
+    *
+    * @return true if the specified SAAJ node is an element, or false otherwise
+    */
+   public static boolean isSOAPElement( Node soap_node )
+   {
+      // NOTE: the second condition below is nessary for Axis, because its Text impl also implements SOAPElement
+      return ( soap_node instanceof SOAPElement && !( soap_node instanceof Text ) );
+   }
+
+   /**
+    * Returns true if the specified SAAJ node is text, or false otherwise.
+    *
+    * @param soap_node a SAAJ node
+    *
+    * @return true if the specified SAAJ node is text, or false otherwise
+    */
+   public static boolean isText( Node soap_node )
+   {
+      return ( soap_node instanceof Text );
+   }
+
+   /**
+    * Returns the value of the specified SAAJ text node.
+    *
+    * @param soapNode a SAAJ text node
+    *
+    * @return the value of the specified SAAJ text node
+    *
+    * @throws SOAPException
+    */
+   public static String getValue( Node soapNode )
+   throws SOAPException
+   {
+      if ( soapNode == null )
+      {
+         throw new IllegalArgumentException( MSG.getMessage( Keys.PARAM_MAY_NOT_BE_NULL ) );
+      }
+
+      if ( isText( soapNode ) )
+      {
+         return getTextValue( (Text) soapNode );
+      }
+      else
+      {
+         return getSOAPElementValue( (SOAPElement) soapNode );
+      }
+   }
+
+   /**
+    * Adds a DOM {@link org.w3c.dom.Element} as an entry to a SAAJ {@link Detail}.
+    *
+    * @param detail  a SAAJ detail
+    * @param domElem a DOM element to be added as an entry in the specified detail
+    *
+    * @return a SAAJ detail entry
+    *
+    * @throws javax.xml.soap.SOAPException
+    */
+   public static DetailEntry addDetailEntry( Detail  detail,
+                                             Element domElem )
+   throws SOAPException
+   {
+      return ( new Dom2SaajConverter(  ).addDetailEntry( detail, domElem ) );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param soapElem DOCUMENT_ME
+    * @param value    DOCUMENT_ME
+    *
+    * @throws SOAPException DOCUMENT_ME
+    */
+   public static void addTextNode( SOAPElement soapElem,
+                                   String      value )
+   throws SOAPException
+   {
+      soapElem.addTextNode( value );
+
+      if ( soapElem.getValue(  ) == null )
+      {
+         Iterator childElemIter = soapElem.getChildElements(  );
+
+         if ( childElemIter.hasNext(  ) )
+         {
+            Node firstChild = (Node) childElemIter.next(  );
 
             if ( firstChild instanceof Text )
             {
-                return (Text) firstChild;
-            }
-        }
+               firstChild.setValue( value );
 
-        return null;
-    }
-
-    private static String getTextValue( Text soapText )
-            throws SOAPException
-    {
-        String value = soapText.getValue();
-
-        if ( value == null )
-        {
-            value = soapText.toString();
-        }
-
-        if ( value == null )
-        {
-            throw new SOAPException( MSG.getMessage( Keys.TEXT_NODE_IS_NULL ) );
-        }
+               return;
+            }
+         }
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param value DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    *
+    * @throws SOAPException DOCUMENT_ME
+    */
+   public static Text createTextNode( String value )
+   throws SOAPException
+   {
+      return ( (Text) SOAPFactory.newInstance(  ).createElement( "foo" ).addTextNode( value ).getChildElements(  )
+                                 .next(  ) );
+   }
+
+   /**
+    * Converts a DOM {@link org.w3c.dom.Element} to a SAAJ {@link javax.xml.soap.SOAPElement}.
+    *
+    * @param elem a DOM {@link org.w3c.dom.Element}
+    *
+    * @return a {@link javax.xml.soap.SOAPElement}
+    *
+    * @throws javax.xml.soap.SOAPException
+    */
+   public static SOAPElement toSOAPElement( Element elem )
+   throws SOAPException
+   {
+      return ( new Dom2SaajConverter(  ).toSOAPElement( elem ) );
+   }
+
+   private static String getSOAPElementValue( SOAPElement soapElem )
+   {
+      String value = soapElem.getValue(  );
+
+      if ( value == null )
+      {
+         Text textNode = getTextNode( soapElem );
+
+         if ( textNode != null )
+         {
+            value = textNode.getValue(  );
+         }
+      }
+
+      if ( value == null )
+      {
+         value = soapElem.getNodeValue(  );
+      }
+
+      return value;
+   }
+
+   private static Text getTextNode( SOAPElement soapElem )
+   {
+      Iterator childElemIter = soapElem.getChildElements(  );
+
+      if ( childElemIter.hasNext(  ) )
+      {
+         Node firstChild = (Node) childElemIter.next(  );
+
+         if ( firstChild instanceof Text )
+         {
+            return (Text) firstChild;
+         }
+      }
+
+      return null;
+   }
+
+   private static String getTextValue( Text soapText )
+   throws SOAPException
+   {
+      String value = soapText.getValue(  );
+
+      if ( value == null )
+      {
+         value = soapText.toString(  );
+      }
+
+      if ( value == null )
+      {
+         throw new SOAPException( MSG.getMessage( Keys.TEXT_NODE_IS_NULL ) );
+      }
 
-        return value;
-    }
+      return value;
+   }
 }

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/WsdlUtils.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/WsdlUtils.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/WsdlUtils.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/WsdlUtils.java Tue Aug  2 09:28:49 2005
@@ -1,116 +1,158 @@
-/*=============================================================================*
- *  Copyright 2004 The Apache Software Foundation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *=============================================================================*/
-package org.apache.ws.util;
-
-import javax.wsdl.Import;
-import javax.wsdl.Input;
-import javax.wsdl.Message;
-import javax.wsdl.Operation;
-import javax.wsdl.Output;
-import javax.wsdl.Port;
-import javax.wsdl.PortType;
-import javax.wsdl.Service;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Generic utility methods for working with various JWSDL objects.
- *
- * @author Ian Springer (Hewlett-Packard Company)
- */
-public abstract class WsdlUtils
-{
-    /**
-     * DOCUMENT_ME
-     *
-     * @param service DOCUMENT_ME
-     *
-     * @return DOCUMENT_ME
-     */
-    public static Map getPortTypes( Service service )
-    {
-        Map portTypes = new HashMap();
-        Map ports = service.getPorts();
-        Iterator portsIter = ports.values().iterator();
-        while ( portsIter.hasNext() )
-        {
-            Port port = (Port) portsIter.next();
-            PortType portType = port.getBinding().getPortType();
-            portTypes.put( portType.getQName(),
-                    portType );
-        }
-
-        return portTypes;
-    }
-
-    public static boolean equals( Import import1, Import import2 )
-    {
-        if ( import1 == null )
-        {
-            return import2 == null;
-        }
-        else if ( import2 == null )
-        {
-            return false;
-        }
-        return import1.getNamespaceURI().equals( import2.getNamespaceURI() ) &&
-                import1.getLocationURI().equals( import2.getLocationURI() );
-    }
-
-    public static boolean equals( Operation op1,
-                                  Operation op2 )
-    {
-        if ( op1 == null )
-        {
-            return op2 == null;
-        }
-
-        if ( op2 == null )
-        {
-            return false;
-        }
-
-        return equals( op1.getInput(),
-                op2.getInput() ) && equals( op1.getOutput(),
-                        op2.getOutput() );
-    }
-
-    public static boolean equals( Input input1,
-                                  Input input2 )
-    {
-        return equals( input1.getMessage(),
-                input2.getMessage() );
-    }
-
-    public static boolean equals( Output output1,
-                                  Output output2 )
-    {
-        if(output1 == null && output2==null)
-        {
-            return true;
-        }
-        return equals( output1.getMessage(),
-                output2.getMessage() );
-    }
-
-    public static boolean equals( Message msg1,
-                                  Message msg2 )
-    {
-        return msg1.getQName().equals( msg2.getQName() );
-    }
-
-}
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.util;
+
+import javax.wsdl.Import;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Generic utility methods for working with various JWSDL objects.
+ *
+ * @author Ian Springer (Hewlett-Packard Company)
+ */
+public abstract class WsdlUtils
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @param service DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static Map getPortTypes( Service service )
+   {
+      Map      portTypes = new HashMap(  );
+      Map      ports     = service.getPorts(  );
+      Iterator portsIter = ports.values(  ).iterator(  );
+      while ( portsIter.hasNext(  ) )
+      {
+         Port     port     = (Port) portsIter.next(  );
+         PortType portType = port.getBinding(  ).getPortType(  );
+         portTypes.put( portType.getQName(  ),
+                        portType );
+      }
+
+      return portTypes;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param import1 DOCUMENT_ME
+    * @param import2 DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static boolean equals( Import import1,
+                                 Import import2 )
+   {
+      if ( import1 == null )
+      {
+         return import2 == null;
+      }
+      else if ( import2 == null )
+      {
+         return false;
+      }
+
+      return import1.getNamespaceURI(  ).equals( import2.getNamespaceURI(  ) )
+             && import1.getLocationURI(  ).equals( import2.getLocationURI(  ) );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param op1 DOCUMENT_ME
+    * @param op2 DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static boolean equals( Operation op1,
+                                 Operation op2 )
+   {
+      if ( op1 == null )
+      {
+         return op2 == null;
+      }
+
+      if ( op2 == null )
+      {
+         return false;
+      }
+
+      return equals( op1.getInput(  ),
+                     op2.getInput(  ) ) && equals( op1.getOutput(  ),
+                                                   op2.getOutput(  ) );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param input1 DOCUMENT_ME
+    * @param input2 DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static boolean equals( Input input1,
+                                 Input input2 )
+   {
+      return equals( input1.getMessage(  ),
+                     input2.getMessage(  ) );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param output1 DOCUMENT_ME
+    * @param output2 DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static boolean equals( Output output1,
+                                 Output output2 )
+   {
+      if ( ( output1 == null ) && ( output2 == null ) )
+      {
+         return true;
+      }
+
+      return equals( output1.getMessage(  ),
+                     output2.getMessage(  ) );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param msg1 DOCUMENT_ME
+    * @param msg2 DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static boolean equals( Message msg1,
+                                 Message msg2 )
+   {
+      return msg1.getQName(  ).equals( msg2.getQName(  ) );
+   }
+}
\ No newline at end of file

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/WsrfWsdlUtils.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/WsrfWsdlUtils.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/WsrfWsdlUtils.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/WsrfWsdlUtils.java Tue Aug  2 09:28:49 2005
@@ -23,7 +23,6 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-
 import javax.wsdl.Definition;
 import javax.wsdl.Operation;
 import javax.wsdl.PortType;
@@ -45,416 +44,500 @@
  */
 public abstract class WsrfWsdlUtils
 {
+   /**
+    * DOCUMENT_ME
+    *
+    * @param portType DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    *
+    * @throws org.apache.ws.resource.InvalidWsrfWsdlException DOCUMENT_ME
+    */
+   public static String getMetadataDescriptorLocation( PortType portType )
+   throws org.apache.ws.resource.InvalidWsrfWsdlException
+   {
+      Map         extAttribs                          = portType.getExtensionAttributes(  );
+      final QName METADATA_DESCRIPTOR_PORTTYPE_ATTRIB =
+         new QName( "http://docs.oasis-open.org/wsrf/2004/10/wsrf-WSResourceMetadataDescriptor-1.0-draft-01.xsd",
+                    "metadataDescriptorLocation", "wsrmd" );
+      QName qValue = ( (QName) extAttribs.get( METADATA_DESCRIPTOR_PORTTYPE_ATTRIB ) );
+      if ( qValue == null )
+      {
+         return null;
+      }
+
+      String          value     = qValue.getLocalPart(  );
+      StringTokenizer tokenizer = new StringTokenizer( value );
+      if ( tokenizer.countTokens(  ) != 2 )
+      {
+         throw new org.apache.ws.resource.InvalidWsrfWsdlException( METADATA_DESCRIPTOR_PORTTYPE_ATTRIB
+                                                                    + " attribute on portType must be of the format \"namespaceURI locationURL\"" );
+      }
+
+      tokenizer.nextToken(  );
+      return tokenizer.nextToken(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param portType DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static QName getMetadataDescriptorName( PortType portType )
+   {
+      Map extAttribs = portType.getExtensionAttributes(  );
+      return (QName) extAttribs.get( new QName( "http://docs.oasis-open.org/wsrf/2004/10/wsrf-WSResourceMetadataDescriptor-1.0-draft-01.xsd",
+                                                "metadataDescriptor", "wsrmd" ) );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param portType DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static QName getResourcePropertiesDocumentName( PortType portType )
+   {
+      Map   extAttribs    = portType.getExtensionAttributes(  );
+      QName rpDocDefQName =
+         (QName) extAttribs.get( org.apache.ws.resource.properties.v2004_11.ResourcePropertiesConstants.RESOURCE_PROPERTIES_PORTTYPE_ATTRIB );
+      if ( rpDocDefQName == null )
+      {
+         rpDocDefQName =
+            (QName) extAttribs.get( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.RESOURCE_PROPERTIES_PORTTYPE_ATTRIB );
+      }
+
+      return rpDocDefQName;
+   }
+
+   /**
+    * @param rpDocElemName
+    * @param def
+    * @param baseUrl
+    *
+    * @return the names of the resource properties associated with the specified portType
+    */
+   public static QName[] getResourcePropertyNames( QName      rpDocElemName,
+                                                   Definition def,
+                                                   URL        baseUrl )
+   throws InvalidWsrfWsdlException
+   {
+      if ( rpDocElemName == null )
+      {
+         return null;
+      }
+
+      Set        propNames    = new HashSet(  );
+      Element[]  schemaElems  = getSchemaElements( def );
+      XsdElement rpDocXsdElem = null;
+      for ( int i = 0; i < schemaElems.length; i++ )
+      {
+         rpDocXsdElem = getXsdElementElementRecursively( schemaElems[i], rpDocElemName, baseUrl );
+         if ( rpDocXsdElem != null )
+         {
+            break;
+         }
+      }
+
+      if ( rpDocXsdElem == null )
+      {
+         throw new InvalidWsrfWsdlException( "Unable to locate the ResourceProperties document element with QName "
+                                             + rpDocElemName );
+      }
+
+      QName   type          = getQualifiedAttribute( rpDocXsdElem, "type" );
+      Element rpDocTypeElem;
+      if ( type != null )
+      {
+         if ( !type.getNamespaceURI(  ).equals( rpDocXsdElem.getSchemaElement(  ).getAttribute( "targetNamespace" ) ) )
+         {
+            throw new InvalidWsrfWsdlException( "This tool currently does not support referencing a ResourceProperties complexType that is not in the current schema's targetNamespace." );
+         }
+
+         rpDocTypeElem = getComplexTypeByName( rpDocXsdElem.getSchemaElement(  ),
+                                               type.getLocalPart(  ) );
+      }
+      else
+      {
+         rpDocTypeElem =
+            (Element) rpDocXsdElem.getElement(  )
+                                  .getElementsByTagNameNS( XmlConstants.NSURI_SCHEMA_XSD, "complexType" ).item( 0 );
+      }
+
+      if ( rpDocTypeElem == null )
+      {
+         throw new InvalidWsrfWsdlException( "Unable to determine type of the ResourceProperties document element with QName "
+                                             + rpDocElemName
+                                             + " - expected either a type atribute or a nested anonymous complexType element." );
+      }
+
+      Element  sequenceElem  = null;
+      NodeList sequenceNodes = rpDocTypeElem.getElementsByTagNameNS( XmlConstants.NSURI_SCHEMA_XSD, "sequence" );
+      if ( sequenceNodes != null )
+      {
+         sequenceElem = (Element) sequenceNodes.item( 0 );
+      }
+      else
+      {
+         sequenceNodes = rpDocTypeElem.getElementsByTagNameNS( XmlConstants.NSURI_SCHEMA_XSD, "all" );
+         if ( sequenceNodes != null )
+         {
+            sequenceElem = (Element) sequenceNodes.item( 0 );
+         }
+      }
 
-    /**
-     * DOCUMENT_ME
-     *
-     * @param mostDerivedPortType DOCUMENT_ME
-     * @param specPortType        DOCUMENT_ME
-     *
-     * @return DOCUMENT_ME
-     */
-    public static boolean implementsPortType( PortType mostDerivedPortType,
-                                              PortType specPortType )
-    {
-        List specOps = specPortType.getOperations();
-        if ( specOps.size() == 0 )
-        {
-            return false;
-            // TODO (v1.1): need to determine if props are present for portTypes which have no ops.
-        }
-        boolean foundSome = false;
-        for ( int i = 0; i < specOps.size(); i++ )
-        {
-            Operation specOp = (Operation) specOps.get( i );
-            Operation aggregatedOp = mostDerivedPortType.getOperation( specOp.getName(),
-                    null,
-                    null );
-            if ( !WsdlUtils.equals( specOp, aggregatedOp ) )
-            {
-                if ( foundSome )
-                {
-                    System.out.println( "WARNING: PortType " + mostDerivedPortType.getQName()
-                            + " contains some, but not all, operations from portType "
-                            + specPortType.getQName() );
-                }
-
-                return false;
-            }
-
-            if ( !isInheritedOperation( specOp, specPortType ) )
-            {
-                foundSome = true;
+      if ( sequenceElem == null )
+      {
+         throw new RuntimeException( "Resource property element definitions must be contained in an xsd:sequence or an xsd:all element." );
+      }
+
+      NodeList propElems = sequenceElem.getElementsByTagNameNS( XmlConstants.NSURI_SCHEMA_XSD, "element" );
+      for ( int j = 0; j < propElems.getLength(  ); j++ )
+      {
+         Element propElem = (Element) propElems.item( j );
+         QName   propName =
+            getQualifiedAttribute( new XsdElement( propElem,
+                                                   rpDocXsdElem.getSchemaElement(  ) ),
+                                   "ref" );
+         if ( propName == null )
+         {
+            throw new InvalidWsrfWsdlException( "All element defs within the resource property document def must have a 'ref' attribute that points at a global element def." );
+         }
+
+         propNames.add( propName );
+      }
+
+      return (QName[]) propNames.toArray( new QName[0] );
+   }
+
+   /**
+    *
+    * @param def a JWSDL definition
+    *
+    * @return array of DOM elements, representing any xsd:schema elements within the specified definition's types section
+    */
+   public static Element[] getSchemaElements( Definition def )
+   {
+      List schemaElems = new ArrayList(  );
+      if ( def.getTypes(  ) != null )
+      {
+         List extElems = def.getTypes(  ).getExtensibilityElements(  );
+         for ( int i = 0; i < extElems.size(  ); i++ )
+         {
+            ExtensibilityElement extElem = (ExtensibilityElement) extElems.get( i );
+            if ( extElem instanceof UnknownExtensibilityElement )
+            {
+               UnknownExtensibilityElement unknownExtElem = (UnknownExtensibilityElement) extElem;
+               Element                     elem = unknownExtElem.getElement(  );
+               if ( elem.getNamespaceURI(  ).equals( XmlConstants.NSURI_SCHEMA_XSD )
+                    && elem.getLocalName(  ).equals( XmlConstants.XSD_SCHEMA.getLocalPart(  ) ) )
+               {
+                  schemaElems.add( elem );
+               }
+            }
+         }
+      }
+
+      return (Element[]) schemaElems.toArray( new Element[0] );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param mostDerivedPortType DOCUMENT_ME
+    * @param specPortType        DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static boolean implementsPortType( PortType mostDerivedPortType,
+                                             PortType specPortType )
+   {
+      List specOps = specPortType.getOperations(  );
+      if ( specOps.size(  ) == 0 )
+      {
+         return false;
+
+         // TODO (v1.1): need to determine if props are present for portTypes which have no ops.
+      }
+
+      boolean foundSome = false;
+      for ( int i = 0; i < specOps.size(  ); i++ )
+      {
+         Operation specOp       = (Operation) specOps.get( i );
+         Operation aggregatedOp = mostDerivedPortType.getOperation( specOp.getName(  ),
+                                                                    null,
+                                                                    null );
+         if ( !WsdlUtils.equals( specOp, aggregatedOp ) )
+         {
+            if ( foundSome )
+            {
+               System.out.println( "WARNING: PortType " + mostDerivedPortType.getQName(  )
+                                   + " contains some, but not all, operations from portType "
+                                   + specPortType.getQName(  ) );
             }
-        }
 
-        return true;
-    }
-
-    private static boolean isInheritedOperation( Operation specOp,
-                                                 PortType specPortType )
-    {
-        return !specOp.getInput().getMessage().getQName().getNamespaceURI().equals( specPortType.getQName()
-                .getNamespaceURI() );
-    }
-
-    /**
-     * @param rpDocElemName
-     * @param def
-     * @param baseUrl
-     *
-     * @return the names of the resource properties associated with the specified portType
-     */
-    public static QName[] getResourcePropertyNames( QName rpDocElemName,
-                                                    Definition def, URL baseUrl ) throws InvalidWsrfWsdlException
-    {
-        if ( rpDocElemName == null )
-        {
-            return null;
-        }
-        Set propNames = new HashSet();
-        Element[] schemaElems = getSchemaElements( def );
-        XsdElement rpDocXsdElem = null;
-        for ( int i = 0; i < schemaElems.length; i++ )
-        {
-            rpDocXsdElem = getXsdElementElementRecursively( schemaElems[i], rpDocElemName, baseUrl );
-            if ( rpDocXsdElem != null )
-            {
-                break;
-            }
-        }
-        if ( rpDocXsdElem == null )
-        {
-            throw new InvalidWsrfWsdlException(
-                    "Unable to locate the ResourceProperties document element with QName " + rpDocElemName );
-        }
-        QName type = getQualifiedAttribute( rpDocXsdElem, "type" );
-        Element rpDocTypeElem;
-        if ( type != null )
-        {
-            if ( !type.getNamespaceURI().equals( rpDocXsdElem.getSchemaElement().getAttribute( "targetNamespace" ) ) )
-            {
-                throw new InvalidWsrfWsdlException(
-                        "This tool currently does not support referencing a ResourceProperties complexType that is not in the current schema's targetNamespace." );
-            }
-            rpDocTypeElem = getComplexTypeByName( rpDocXsdElem.getSchemaElement(), type.getLocalPart() );
-        }
-        else
-        {
-            rpDocTypeElem =
-                    (Element) rpDocXsdElem.getElement().getElementsByTagNameNS( XmlConstants.NSURI_SCHEMA_XSD,
-                            "complexType" )
-                    .item( 0 );
-        }
-        if ( rpDocTypeElem == null )
-        {
-            throw new InvalidWsrfWsdlException(
-                    "Unable to determine type of the ResourceProperties document element with QName " + rpDocElemName +
-                    " - expected either a type atribute or a nested anonymous complexType element." );
-        }
-        Element sequenceElem = null;
-        NodeList sequenceNodes = rpDocTypeElem.getElementsByTagNameNS( XmlConstants.NSURI_SCHEMA_XSD, "sequence" );
-        if ( sequenceNodes != null )
-        {
-            sequenceElem = (Element) sequenceNodes.item( 0 );
-        }
-        else
-        {
-            sequenceNodes = rpDocTypeElem.getElementsByTagNameNS( XmlConstants.NSURI_SCHEMA_XSD, "all" );
-            if ( sequenceNodes != null )
-            {
-                sequenceElem = (Element) sequenceNodes.item( 0 );
-            }
-        }
-        if ( sequenceElem == null )
-        {
-            throw new RuntimeException(
-                    "Resource property element definitions must be contained in an xsd:sequence or an xsd:all element." );
-        }
-        NodeList propElems = sequenceElem.getElementsByTagNameNS( XmlConstants.NSURI_SCHEMA_XSD, "element" );
-        for ( int j = 0; j < propElems.getLength(); j++ )
-        {
-            Element propElem = (Element) propElems.item( j );
-            QName propName = getQualifiedAttribute( new XsdElement( propElem, rpDocXsdElem.getSchemaElement() ), "ref" );
-            if ( propName == null )
-            {
-                throw new InvalidWsrfWsdlException(
-                        "All element defs within the resource property document def must have a 'ref' attribute that points at a global element def." );
-            }
-            propNames.add( propName );
-        }
-        return (QName[]) propNames.toArray( new QName[0] );
-    }
-
-    private static XsdElement getXsdElementElementRecursively( Element xsdSchemaElem, QName xsdElemName, URL baseUrl )
-            throws InvalidWsrfWsdlException
-    {
-        XsdElement xsdElementElem = getXsdElementElement( xsdSchemaElem, xsdElemName );
-        if ( xsdElementElem == null )
-        {
-            String[] schemaLocations = findImportsAndIncludes( xsdSchemaElem, xsdElemName.getNamespaceURI() );
-            for ( int j = 0; j < schemaLocations.length; j++ )
-            {
-                String location = schemaLocations[j];
-                URL schemaUrl = null;
-                Document schemaDoc = null;
-                try
-                {
-                    schemaUrl = new URL( baseUrl, location );
-                    schemaDoc = JaxpUtils.loadDocument( schemaUrl.openStream() );
-                }
-                catch ( Exception e )
-                {
-                    throw new InvalidWsrfWsdlException( "Failed to load schema at location " + location );
-                }
-                xsdElementElem =
-                        getXsdElementElementRecursively( schemaDoc.getDocumentElement(), xsdElemName, schemaUrl );
-                if ( xsdElementElem != null )
-                {
-                    break;
-                }
-            }
-        }
-        return xsdElementElem;
-    }
-
-    private static QName getQualifiedAttribute( XsdElement xsdElem, String attribName )
-            throws InvalidWsrfWsdlException
-    {
-        String value = xsdElem.getElement().getAttribute( attribName );
-        if ( "".equals( value ) )
-        {
-            return null;
-        }
-        PrefixResolver prefixResolver = new PrefixResolverDefault( xsdElem.getSchemaElement() );
-        QName propName = null;
-        try
-        {
-            propName = toQName( value, prefixResolver );
-        }
-        catch ( PrefixResolutionException pre )
-        {
-            throw new InvalidWsrfWsdlException(
-                    "Unable to resolve prefix '" + pre.getPrefix() + "' in xsd:element '" + attribName +
-                    "' attribute value." );
-        }
-        catch ( InvalidValueException ive )
-        {
-            throw new InvalidWsrfWsdlException(
-                    "Value for xsd:element 'ref' attribute must be qualified via a namespace prefix." );
-        }
-        return propName;
-    }
-
-    private static QName toQName( String value, PrefixResolver prefixResolver ) throws InvalidValueException,
-            PrefixResolutionException
-    {
-        StringTokenizer tokenizer = new StringTokenizer( value, ":" );
-        if ( tokenizer.countTokens() != 2 )
-        {
-            throw new InvalidValueException();
-        }
-        String prefix = tokenizer.nextToken();
-        String localName = tokenizer.nextToken();
-        // TODO: write our own prefix resolver to eliminate dep on Xalan
-        String namespace = prefixResolver.getNamespaceForPrefix( prefix );
-        if ( namespace == null )
-        {
-            throw new PrefixResolutionException( prefix );
-        }
-        return new QName( namespace, localName, prefix );        
-    }
-
-    private static String[] findImportsAndIncludes( Element schemaElem, String namespaceURI )
-    {
-        List elems = new ArrayList();
-        NodeList imports = schemaElem.getElementsByTagNameNS( XmlConstants.NSURI_SCHEMA_XSD,
-                XmlConstants.XSD_ATTRIB_IMPORT );
-        for ( int i = 0; i < imports.getLength(); i++ )
-        {
-            Element importNode = (Element) imports.item( i );
-            Attr attributeNode = importNode.getAttributeNode( "namespace" );
-            if ( attributeNode != null )
-            {
-                if ( namespaceURI.equals( attributeNode.getValue() ) )
-                {
-                    elems.add( importNode );
-                }
-            }
-        }
-        NodeList includes = schemaElem.getElementsByTagNameNS( XmlConstants.NSURI_SCHEMA_XSD,
-                XmlConstants.XSD_ATTRIB_INCLUDE );
-        for ( int i = 0; i < includes.getLength(); i++ )
-        {
-            elems.add( includes.item( i ) );
-        }
-        String[] locations = new String[elems.size()];
-        for ( int i = 0; i < elems.size(); i++ )
-        {
-            Element element = (Element) elems.get( i );
-            Attr attributeNode = element.getAttributeNode( "schemaLocation" );
-            if ( attributeNode != null )
-            {
-                locations[i] = attributeNode.getValue();
-            }
-        }
-        return locations;
-    }
-
-    private static XsdElement getXsdElementElement( Element schemaElem,
-                                                    QName name )
-    {
-        NodeList children = schemaElem.getChildNodes();
-        for ( int i = 0; i < children.getLength(); i++ )
-        {
-            Node child = children.item( i );
-            if ( child instanceof Element && child.getLocalName().equals( "element" ) )
-            {
-                Element elementElem = (Element) child;
-                if ( String.valueOf( elementElem.getAttribute( "name" ) ).equals( name.getLocalPart() ) )
-                {
-                    return new XsdElement( elementElem, schemaElem );
-                }
-            }
-        }
-        return null;
-    }
-
-    private static Element getComplexTypeByName( Element schemaElem,
-                                                 String name )
-    {
-        NodeList children = schemaElem.getChildNodes();
-        for ( int i = 0; i < children.getLength(); i++ )
-        {
-            Node child = children.item( i );
-            if ( child instanceof Element && child.getLocalName().equals( "complexType" ) )
-            {
-                Element elementElem = (Element) child;
-                if ( String.valueOf( elementElem.getAttribute( "name" ) ).equals( name ) )
-                {
-                    return elementElem;
-                }
-            }
-        }
-        return null;
-    }
-
-    public static QName getResourcePropertiesDocumentName( PortType portType )
-    {
-        Map extAttribs = portType.getExtensionAttributes();
-        QName rpDocDefQName = (QName) extAttribs.get(
-                org.apache.ws.resource.properties.v2004_11.ResourcePropertiesConstants.RESOURCE_PROPERTIES_PORTTYPE_ATTRIB );
-        if ( rpDocDefQName == null )
-        {
-            rpDocDefQName =
-                    (QName) extAttribs.get(
-                            org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.RESOURCE_PROPERTIES_PORTTYPE_ATTRIB );
-        }
-        return rpDocDefQName;
-    }
-
-    public static QName getMetadataDescriptorName( PortType portType )
-    {
-        Map extAttribs = portType.getExtensionAttributes();
-        return (QName) extAttribs.get( new QName(
-                "http://docs.oasis-open.org/wsrf/2004/10/wsrf-WSResourceMetadataDescriptor-1.0-draft-01.xsd",
-                "metadataDescriptor", "wsrmd" ) );
-    }
-
-    public static String getMetadataDescriptorLocation( PortType portType )
-            throws org.apache.ws.resource.InvalidWsrfWsdlException
-    {
-        Map extAttribs = portType.getExtensionAttributes();
-        final QName METADATA_DESCRIPTOR_PORTTYPE_ATTRIB =
-                new QName(
-                        "http://docs.oasis-open.org/wsrf/2004/10/wsrf-WSResourceMetadataDescriptor-1.0-draft-01.xsd",
-                        "metadataDescriptorLocation", "wsrmd" );
-        QName qValue = ( (QName) extAttribs.get( METADATA_DESCRIPTOR_PORTTYPE_ATTRIB ) );
-        if ( qValue == null )
-        {
-            return null;
-        }
-        String value = qValue.getLocalPart();
-        StringTokenizer tokenizer = new StringTokenizer( value );
-        if ( tokenizer.countTokens() != 2 )
-        {
-            throw new org.apache.ws.resource.InvalidWsrfWsdlException( METADATA_DESCRIPTOR_PORTTYPE_ATTRIB +
-                    " attribute on portType must be of the format \"namespaceURI locationURL\"" );
-        }
-        tokenizer.nextToken();
-        return tokenizer.nextToken();
-    }
-
-    /**
-     *
-     * @param def a JWSDL definition
-     *
-     * @return array of DOM elements, representing any xsd:schema elements within the specified definition's types section
-     */
-    public static Element[] getSchemaElements( Definition def )
-    {
-        List schemaElems = new ArrayList();
-        if ( def.getTypes() != null )
-        {
-            List extElems = def.getTypes().getExtensibilityElements();
-            for ( int i = 0; i < extElems.size(); i++ )
-            {
-                ExtensibilityElement extElem = (ExtensibilityElement) extElems.get( i );
-                if ( extElem instanceof UnknownExtensibilityElement )
-                {
-                    UnknownExtensibilityElement unknownExtElem = (UnknownExtensibilityElement) extElem;
-                    Element elem = unknownExtElem.getElement();
-                    if ( elem.getNamespaceURI().equals( XmlConstants.NSURI_SCHEMA_XSD )
-                            && elem.getLocalName().equals( XmlConstants.XSD_SCHEMA.getLocalPart() ) )
-                    {
-                        schemaElems.add( elem );
-                    }
-                }
-            }
-        }
-        return (Element[]) schemaElems.toArray( new Element[0] );
-    }
-
-    private static class XsdElement
-    {
-        private Element m_elem;
-        private Element m_schemaElem;
-
-        public XsdElement( Element elem, Element schemaElem )
-        {
-            m_elem = elem;
-            m_schemaElem = schemaElem;
-        }
-
-        public Element getElement()
-        {
-            return m_elem;
-        }
-
-        public Element getSchemaElement()
-        {
-            return m_schemaElem;
-        }
-    }
-
-    private static class PrefixResolutionException extends Exception
-    {
-        private String m_prefix;
-
-        public PrefixResolutionException( String prefix )
-        {
-            super();
-            m_prefix = prefix;
-        }
-
-        public String getPrefix()
-        {
-            return m_prefix;
-        }
-    }
-
-    private static class InvalidValueException extends Exception
-    {
-    }
+            return false;
+         }
 
+         if ( !isInheritedOperation( specOp, specPortType ) )
+         {
+            foundSome = true;
+         }
+      }
+
+      return true;
+   }
+
+   private static Element getComplexTypeByName( Element schemaElem,
+                                                String  name )
+   {
+      NodeList children = schemaElem.getChildNodes(  );
+      for ( int i = 0; i < children.getLength(  ); i++ )
+      {
+         Node child = children.item( i );
+         if ( child instanceof Element && child.getLocalName(  ).equals( "complexType" ) )
+         {
+            Element elementElem = (Element) child;
+            if ( String.valueOf( elementElem.getAttribute( "name" ) ).equals( name ) )
+            {
+               return elementElem;
+            }
+         }
+      }
+
+      return null;
+   }
+
+   private static boolean isInheritedOperation( Operation specOp,
+                                                PortType  specPortType )
+   {
+      return !specOp.getInput(  ).getMessage(  ).getQName(  ).getNamespaceURI(  ).equals( specPortType.getQName(  )
+                                                                                                      .getNamespaceURI(  ) );
+   }
+
+   private static QName getQualifiedAttribute( XsdElement xsdElem,
+                                               String     attribName )
+   throws InvalidWsrfWsdlException
+   {
+      String value = xsdElem.getElement(  ).getAttribute( attribName );
+      if ( "".equals( value ) )
+      {
+         return null;
+      }
+
+      PrefixResolver prefixResolver = new PrefixResolverDefault( xsdElem.getSchemaElement(  ) );
+      QName          propName = null;
+      try
+      {
+         propName = toQName( value, prefixResolver );
+      }
+      catch ( PrefixResolutionException pre )
+      {
+         throw new InvalidWsrfWsdlException( "Unable to resolve prefix '" + pre.getPrefix(  )
+                                             + "' in xsd:element '" + attribName + "' attribute value." );
+      }
+      catch ( InvalidValueException ive )
+      {
+         throw new InvalidWsrfWsdlException( "Value for xsd:element 'ref' attribute must be qualified via a namespace prefix." );
+      }
+
+      return propName;
+   }
+
+   private static XsdElement getXsdElementElement( Element schemaElem,
+                                                   QName   name )
+   {
+      NodeList children = schemaElem.getChildNodes(  );
+      for ( int i = 0; i < children.getLength(  ); i++ )
+      {
+         Node child = children.item( i );
+         if ( child instanceof Element && child.getLocalName(  ).equals( "element" ) )
+         {
+            Element elementElem = (Element) child;
+            if ( String.valueOf( elementElem.getAttribute( "name" ) ).equals( name.getLocalPart(  ) ) )
+            {
+               return new XsdElement( elementElem, schemaElem );
+            }
+         }
+      }
+
+      return null;
+   }
+
+   private static XsdElement getXsdElementElementRecursively( Element xsdSchemaElem,
+                                                              QName   xsdElemName,
+                                                              URL     baseUrl )
+   throws InvalidWsrfWsdlException
+   {
+      XsdElement xsdElementElem = getXsdElementElement( xsdSchemaElem, xsdElemName );
+      if ( xsdElementElem == null )
+      {
+         String[] schemaLocations = findImportsAndIncludes( xsdSchemaElem,
+                                                            xsdElemName.getNamespaceURI(  ) );
+         for ( int j = 0; j < schemaLocations.length; j++ )
+         {
+            String   location  = schemaLocations[j];
+            URL      schemaUrl = null;
+            Document schemaDoc = null;
+            try
+            {
+               schemaUrl    = new URL( baseUrl, location );
+               schemaDoc    = JaxpUtils.loadDocument( schemaUrl.openStream(  ) );
+            }
+            catch ( Exception e )
+            {
+               throw new InvalidWsrfWsdlException( "Failed to load schema at location " + location );
+            }
+
+            xsdElementElem =
+               getXsdElementElementRecursively( schemaDoc.getDocumentElement(  ),
+                                                xsdElemName,
+                                                schemaUrl );
+            if ( xsdElementElem != null )
+            {
+               break;
+            }
+         }
+      }
+
+      return xsdElementElem;
+   }
+
+   private static String[] findImportsAndIncludes( Element schemaElem,
+                                                   String  namespaceURI )
+   {
+      List     elems   = new ArrayList(  );
+      NodeList imports =
+         schemaElem.getElementsByTagNameNS( XmlConstants.NSURI_SCHEMA_XSD, XmlConstants.XSD_ATTRIB_IMPORT );
+      for ( int i = 0; i < imports.getLength(  ); i++ )
+      {
+         Element importNode    = (Element) imports.item( i );
+         Attr    attributeNode = importNode.getAttributeNode( "namespace" );
+         if ( attributeNode != null )
+         {
+            if ( namespaceURI.equals( attributeNode.getValue(  ) ) )
+            {
+               elems.add( importNode );
+            }
+         }
+      }
+
+      NodeList includes =
+         schemaElem.getElementsByTagNameNS( XmlConstants.NSURI_SCHEMA_XSD, XmlConstants.XSD_ATTRIB_INCLUDE );
+      for ( int i = 0; i < includes.getLength(  ); i++ )
+      {
+         elems.add( includes.item( i ) );
+      }
+
+      String[] locations = new String[elems.size(  )];
+      for ( int i = 0; i < elems.size(  ); i++ )
+      {
+         Element element       = (Element) elems.get( i );
+         Attr    attributeNode = element.getAttributeNode( "schemaLocation" );
+         if ( attributeNode != null )
+         {
+            locations[i] = attributeNode.getValue(  );
+         }
+      }
+
+      return locations;
+   }
+
+   private static QName toQName( String         value,
+                                 PrefixResolver prefixResolver )
+   throws InvalidValueException, 
+          PrefixResolutionException
+   {
+      StringTokenizer tokenizer = new StringTokenizer( value, ":" );
+      if ( tokenizer.countTokens(  ) != 2 )
+      {
+         throw new InvalidValueException(  );
+      }
+
+      String prefix    = tokenizer.nextToken(  );
+      String localName = tokenizer.nextToken(  );
+
+      // TODO: write our own prefix resolver to eliminate dep on Xalan
+      String namespace = prefixResolver.getNamespaceForPrefix( prefix );
+      if ( namespace == null )
+      {
+         throw new PrefixResolutionException( prefix );
+      }
+
+      return new QName( namespace, localName, prefix );
+   }
+
+   private static class InvalidValueException
+      extends Exception
+   {
+   }
+
+   private static class PrefixResolutionException
+      extends Exception
+   {
+      private String m_prefix;
+
+      /**
+       * Creates a new {@link PrefixResolutionException} object.
+       *
+       * @param prefix DOCUMENT_ME
+       */
+      public PrefixResolutionException( String prefix )
+      {
+         super(  );
+         m_prefix = prefix;
+      }
+
+      /**
+       * DOCUMENT_ME
+       *
+       * @return DOCUMENT_ME
+       */
+      public String getPrefix(  )
+      {
+         return m_prefix;
+      }
+   }
+
+   private static class XsdElement
+   {
+      private Element m_elem;
+      private Element m_schemaElem;
+
+      /**
+       * Creates a new {@link XsdElement} object.
+       *
+       * @param elem DOCUMENT_ME
+       * @param schemaElem DOCUMENT_ME
+       */
+      public XsdElement( Element elem,
+                         Element schemaElem )
+      {
+         m_elem          = elem;
+         m_schemaElem    = schemaElem;
+      }
+
+      /**
+       * DOCUMENT_ME
+       *
+       * @return DOCUMENT_ME
+       */
+      public Element getElement(  )
+      {
+         return m_elem;
+      }
+
+      /**
+       * DOCUMENT_ME
+       *
+       * @return DOCUMENT_ME
+       */
+      public Element getSchemaElement(  )
+      {
+         return m_schemaElem;
+      }
+   }
 }

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/XmlBeanNameUtils.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/XmlBeanNameUtils.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/util/XmlBeanNameUtils.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/util/XmlBeanNameUtils.java Tue Aug  2 09:28:49 2005
@@ -1,81 +1,78 @@
-/*=============================================================================*
- *  Copyright 2004 The Apache Software Foundation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *=============================================================================*/
-package org.apache.ws.util;
-
-import org.apache.xmlbeans.impl.common.NameUtil;
-
-import javax.xml.namespace.QName;
-
-/**
- * A set of utility methods for obtaining the names of the Java classes associated with
- * a particular qualified element name.
- *
- * @author Ian Springer
- */
-public abstract class XmlBeanNameUtils
-{
-
-    /**
-     * DOCUMENT_ME
-     *
-     * @param propsDocElemQName DOCUMENT_ME
-     *
-     * @return DOCUMENT_ME
-     */
-    public static String getElementXmlBeanClassName( QName propsDocElemQName )
-    {
-       return getDocumentElementXmlBeanClassName( propsDocElemQName ) + "."
-              + getElementXmlBeanUnqualifiedClassName( propsDocElemQName );
-    }
-
-    /**
-     * DOCUMENT_ME
-     *
-     * @param propsDocElemQName DOCUMENT_ME
-     *
-     * @return DOCUMENT_ME
-     */
-    public static String getElementXmlBeanUnqualifiedClassName( QName propsDocElemQName )
-    {
-       String props_xml_bean_class_name = NameUtil.getClassNameFromQName( propsDocElemQName );
-       return props_xml_bean_class_name.substring( props_xml_bean_class_name.lastIndexOf( '.' ) + 1 );
-    }
-
-    /**
-     * DOCUMENT_ME
-     *
-     * @param propsDocElemQName DOCUMENT_ME
-     *
-     * @return DOCUMENT_ME
-     */
-    public static String getDocumentElementXmlBeanClassName( QName propsDocElemQName )
-    {
-       return NameUtil.getClassNameFromQName( propsDocElemQName ) + "Document";
-    }
-
-    /**
-     * DOCUMENT_ME
-     *
-     * @param propsDocElemQName DOCUMENT_ME
-     *
-     * @return DOCUMENT_ME
-     */
-    public static String getDocumentElementXmlBeanFactoryClassName( QName propsDocElemQName )
-    {
-       return getDocumentElementXmlBeanClassName( propsDocElemQName ) + "$Factory";
-    }
-
-}
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.util;
+
+import org.apache.xmlbeans.impl.common.NameUtil;
+import javax.xml.namespace.QName;
+
+/**
+ * A set of utility methods for obtaining the names of the Java classes associated with
+ * a particular qualified element name.
+ *
+ * @author Ian Springer
+ */
+public abstract class XmlBeanNameUtils
+{
+   /**
+    * DOCUMENT_ME
+    *
+    * @param propsDocElemQName DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static String getDocumentElementXmlBeanClassName( QName propsDocElemQName )
+   {
+      return NameUtil.getClassNameFromQName( propsDocElemQName ) + "Document";
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param propsDocElemQName DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static String getDocumentElementXmlBeanFactoryClassName( QName propsDocElemQName )
+   {
+      return getDocumentElementXmlBeanClassName( propsDocElemQName ) + "$Factory";
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param propsDocElemQName DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static String getElementXmlBeanClassName( QName propsDocElemQName )
+   {
+      return getDocumentElementXmlBeanClassName( propsDocElemQName ) + "."
+             + getElementXmlBeanUnqualifiedClassName( propsDocElemQName );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param propsDocElemQName DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public static String getElementXmlBeanUnqualifiedClassName( QName propsDocElemQName )
+   {
+      String props_xml_bean_class_name = NameUtil.getClassNameFromQName( propsDocElemQName );
+      return props_xml_bean_class_name.substring( props_xml_bean_class_name.lastIndexOf( '.' ) + 1 );
+   }
+}
\ No newline at end of file



Mime
View raw message