You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by jk...@apache.org on 2008/01/07 18:36:43 UTC

svn commit: r609714 [4/8] - in /webservices/woden/branches/woden65: ./ ant-test/ src/org/apache/woden/ src/org/apache/woden/ant/ src/org/apache/woden/internal/ src/org/apache/woden/internal/resolver/ src/org/apache/woden/internal/util/dom/ src/org/apac...

Added: webservices/woden/branches/woden65/src/org/apache/woden/internal/xpointer/XMLElementEvaluator.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/internal/xpointer/XMLElementEvaluator.java?rev=609714&view=auto
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/internal/xpointer/XMLElementEvaluator.java (added)
+++ webservices/woden/branches/woden65/src/org/apache/woden/internal/xpointer/XMLElementEvaluator.java Mon Jan  7 09:36:13 2008
@@ -0,0 +1,217 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.internal.xpointer;
+
+import java.util.Collections;
+import java.util.EmptyStackException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Stack;
+import java.util.Arrays;
+
+import org.apache.woden.XMLElement;
+import org.apache.woden.types.NCName;
+import org.apache.woden.xpointer.PointerPart;
+import org.apache.woden.xpointer.ElementPointerPart;
+import org.apache.woden.xpointer.XPointer;
+
+/**
+ * This class Evaluates an XPointer on a XMLElement, using the XPointer model in Woden.
+ * It currently supports shorthand pointer and element() scheme based pointer part.
+ * 
+ * @author Dan Harvey <da...@gmail.com>
+ *
+ */
+public abstract class XMLElementEvaluator {
+    private final XPointer xpointer;
+    private final XMLElement root;
+
+    /**
+     * Constructs a new XMLElement abstract class for a XPointer and XMLElement.
+     *  
+     * @param xpointer an XPointer which to evaluate.
+     * @param root an XMLElement which to evaluate the XPointer against.
+     */
+    public XMLElementEvaluator(XPointer xpointer, XMLElement root) {
+        this.xpointer = xpointer;
+        this.root = root;
+    }
+    
+    /**
+     * Evaluates the XPointer on the root XMLElement and returns the resulting XMLElement or null.
+     * 
+     * @return an XMLElement from the resultant evaluation of the root XMLElement or null if evaluation fails.
+     * 
+     */
+    public XMLElement evaluate() {
+        if(xpointer.hasPointerParts()) { //Scheme based pointer.
+            //Take each pointer part at a time and evaluate it against the root element. The first result found will be returned.
+            XMLElement result = null;
+            for(Iterator it = Arrays.asList(xpointer.getPointerParts()).iterator(); it.hasNext(); ) {
+                PointerPart pointerPart = (PointerPart)it.next();
+                //TODO Add extra pointer parts here once we support them.
+                if (pointerPart instanceof ElementPointerPart) {
+                    result = evaluateElementPointerPart((ElementPointerPart)pointerPart);
+                }
+                if (result != null) return result;
+            }
+        } else if(xpointer.hasShorthandPointer()) { //Shorthand pointer
+            //Iterator for XMLElement from root in document order. See http://www.w3.org/TR/xpath#dt-document-order
+            return evaluateShorthandPointer(xpointer.getShorthandPointer());
+            
+        }
+        return null;
+    }
+    
+    /**
+     * Evaluates an element() XPointer scheme based pointer part to the specification at
+     * <a href="http://www.w3.org/TR/xptr-element/">http://www.w3.org/TR/xptr-element/</a>
+     * 
+     * @param elementPointerPart an ElementPointerPart to evaluate.
+     * @return an XMLElement pointed to by this Element pointer part, or null if none exists.
+     */
+    private XMLElement evaluateElementPointerPart(ElementPointerPart elementPointerPart) {
+        if (elementPointerPart.hasChildSequence() && elementPointerPart.hasNCName()) { //Both NCName and childSequence.
+            //Find NCName.
+            XMLElement element = evaluateShorthandPointer(elementPointerPart.getNCName());
+            if (element == null) return null;
+            //Walk through children.
+            return evaluateChildSequence(element, elementPointerPart.getChildSequence());
+        } else if(elementPointerPart.hasNCName()) { //Only NCName
+            return evaluateShorthandPointer(elementPointerPart.getNCName());
+        } else { //Only a childSequence
+            //XML must only have 1 root element so we can't evaluate it if its > 1
+            Integer[] childSequence = elementPointerPart.getChildSequence();
+            if (childSequence[0].intValue() > 1) return null;
+            Integer[] nChildSequence = new Integer[childSequence.length-1];
+            for (int i=1; i<childSequence.length; i++) {
+                nChildSequence[i-1] = childSequence[i];
+            }
+            return evaluateChildSequence(root, nChildSequence);
+        }
+    }
+    
+    /**
+     * Evaluates an shorthand pointer in an XPointer based on the specification at
+     * <a href="http://www.w3.org/TR/xptr-framework/#shorthand">http://www.w3.org/TR/xptr-framework/#shorthand</a>
+     * 
+     * @param ncname an NCName to evaluate.
+     * @return an XMLElement pointed to by this shorthand name, or null if none exists.
+     */
+    private XMLElement evaluateShorthandPointer(NCName ncname) {
+        //Iterator for XMLElement from root in document order. See http://www.w3.org/TR/xpath#dt-document-order
+        String shorthand = ncname.toString();
+        for(Iterator it = new DocumentOrderIterator(root); it.hasNext(); ){
+            XMLElement element = (XMLElement)it.next();
+            if (testElementShorthand(element, shorthand)) return element;
+        }
+        return null;
+    }
+    
+    /**
+     * Evaluates a child sequence array of Integers to an XMLElement following XML Document Order.
+     * This is a helper method used by other evaluation methods in this class.
+     * 
+     * @param element an XMLElement to start from.
+     * @param childSequence an Integer[] to evaluate from the start XMLElement.
+     * @return an XMLElement pointed to by this childSequence, or null if none exists.
+     */
+    private XMLElement evaluateChildSequence(XMLElement element, Integer[] childSequence) {
+        for(int i=0; i<childSequence.length; i++) {
+            //does the iTh child exist?
+            XMLElement[] children = element.getChildElements();
+            children = filterNoneElementNodes(children);
+            if (childSequence[i].intValue() > children.length) { //childSequence int out of bounds of child array so does not exist.
+                return null;
+            } else {
+                element = element.getChildElements()[childSequence[i].intValue()-1];
+            }
+        }
+        return element;
+    }
+    
+    //Utility classes
+    
+    /**
+     * Filters an XMLElement[] for nodes which are not xml tag elements.
+     * 
+     * @param nodes an XMLElement[] of the nodes to filter.
+     * @return an XMLElement[] of the remaining nodes.
+     */
+    private static XMLElement[] filterNoneElementNodes(XMLElement[] nodes) {
+        List nodeList = Arrays.asList(nodes);
+        for(Iterator it = nodeList.iterator(); it.hasNext(); ) {            
+            XMLElement node = (XMLElement)it.next();
+            if(node.getLocalName().indexOf('#') > -1) {
+                it.remove();
+            }
+        }
+        XMLElement[] nNodes = new XMLElement[nodeList.size()];
+        nodeList.toArray(nNodes);
+        return nNodes;
+    }
+    
+    //Abstract Methods
+    /**
+     * Tests the element for an id according to the specification at
+     * <a href="http://www.w3.org/TR/xptr-framework/#term-sdi">http://www.w3.org/TR/xptr-framework/#term-sdi</a> and returns a boolean answer.
+     * 
+     * @param element An XMLElement to test for an id.
+     * @param id A String of the id to test for.
+     * @return boolean value of whether the id matches or not.
+     */
+    public abstract boolean testElementShorthand(XMLElement element, String id);
+    
+    //Internal classes
+    /**
+     * DocumentOrderIterator is a implementation of Iterator which iterates in Document Order from a root XMLElement object.
+     * 
+     */
+    private class DocumentOrderIterator implements Iterator {
+        private final Stack stack;
+        
+        public DocumentOrderIterator(XMLElement root) {
+            stack = new Stack();
+            stack.add(root);
+        }
+        
+        public boolean hasNext() {
+            return !stack.isEmpty();
+        }
+        
+        public Object next() {
+            //Get next element.
+            XMLElement element;
+            try {
+                element = (XMLElement)stack.pop(); 
+            } catch (EmptyStackException e) {
+                throw new NoSuchElementException();
+            }
+            //Add children to top of stack in reverse order.
+            List children = Arrays.asList(element.getChildElements());
+            Collections.reverse(children);
+            stack.addAll(children);
+            
+            return element;
+        }
+        
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+    }
+}

Propchange: webservices/woden/branches/woden65/src/org/apache/woden/internal/xpointer/XMLElementEvaluator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/woden/branches/woden65/src/org/apache/woden/types/NCName.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/types/NCName.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/types/NCName.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/types/NCName.java Mon Jan  7 09:36:13 2008
@@ -42,12 +42,7 @@
     }
     
     private String fValue = null;
-    
-    public NCName() 
-    {
-        super();
-    }
-    
+
     /**
      * 
      * @param value String representing an NCName
@@ -55,6 +50,9 @@
      */
     public NCName(String value)
     {
+        if (value == null) {
+            throw new IllegalArgumentException();
+        }
         setValue(value);
     }
     

Added: webservices/woden/branches/woden65/src/org/apache/woden/types/NamespaceDeclaration.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/types/NamespaceDeclaration.java?rev=609714&view=auto
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/types/NamespaceDeclaration.java (added)
+++ webservices/woden/branches/woden65/src/org/apache/woden/types/NamespaceDeclaration.java Mon Jan  7 09:36:13 2008
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.types;
+
+import java.net.URI;
+
+/**
+ * Represents an XML namespace declaration, consisting of a namespace prefix
+ * and a namespace URI. This is an immutable class.
+ * 
+ * @author John Kaputin (jkaputin@apache.org)
+ */
+public class NamespaceDeclaration {
+    
+    public static final String XMLNS_NS_STRING = "http://www.w3.org/2000/xmlns/";
+    
+    public static final URI XMLNS_NS_URI  = URI.create("http://www.w3.org/2000/xmlns/");
+    
+    private final String prefix;
+    private final URI namespaceURI;
+    
+    public NamespaceDeclaration(String prefix, URI namespaceURI) {
+        this.prefix = prefix;
+        this.namespaceURI = namespaceURI;
+    }
+    
+    public String getPrefix() {
+        return this.prefix;
+    }
+    
+    public URI getNamespaceURI() {
+        return this.namespaceURI;
+    }
+
+}

Propchange: webservices/woden/branches/woden65/src/org/apache/woden/types/NamespaceDeclaration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/woden/branches/woden65/src/org/apache/woden/types/QNameTokenUnion.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/types/QNameTokenUnion.java?rev=609714&view=auto
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/types/QNameTokenUnion.java (added)
+++ webservices/woden/branches/woden65/src/org/apache/woden/types/QNameTokenUnion.java Mon Jan  7 09:36:13 2008
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.types;
+
+import javax.xml.namespace.QName;
+
+/**
+ * This class represents the data type "Union of xs:QName and xs:Token" 
+ * where the token values are #any, #none, or #other.
+ *
+ * @author Dan Harvey, danharvey42@gmail.com
+ *
+ */
+public class QNameTokenUnion {
+    private final QName qname;
+    private final String token;
+    public static final QNameTokenUnion ANY = new QNameTokenUnion("#any");
+    public static final QNameTokenUnion NONE = new QNameTokenUnion("#none");
+    public static final QNameTokenUnion OTHER = new QNameTokenUnion("#other");
+
+    /*
+     * Constructs a QNameTokenUnion as a 'token' type with the specified token value.
+     * This constructor has been declared private so that it cannot be used to specify
+     * arbitrary tokens. It is used only to create an enumeration of static variables 
+     * representing the token types #any, #none and #other.
+     */
+    private QNameTokenUnion(String token) {
+        this.token = token.intern();
+        this.qname = null;
+    }
+    
+    /**
+     * Constructs a QNameTokenUnion as a 'QName' type with the specified qname value.
+     * The qname parameter must not be null.
+     * 
+     * @param qname the QName to set as its value.
+     * @throws NullPointerException if qname is null
+     */
+    public QNameTokenUnion(QName qname) {
+        if (qname != null) {
+            this.qname = qname;
+            this.token = null;
+        } else {
+            throw new NullPointerException("QName=null");
+        }
+    }
+    
+    /**
+     * Returns the QName if it exists otherwise null.
+     * 
+     * @return a QName if it exists otherwise null.
+     */
+    public QName getQName() {
+        return qname;
+    }
+    
+    /**
+     * Returns the token value if it exists otherwise null.
+     * 
+     * @return a String value of the token if it exists otherwise null.
+     */
+    public String getToken() {
+        return token;
+    }
+    
+    /**
+     * Returns True if a QName exists, otherwise it returns False;
+     * 
+     * @return a boolean representing if this has a QName value.
+     */
+    public boolean isQName() {
+        return qname != null;
+    }
+    
+    /**
+     * Returns True is a token value exists, otherwise it returns False.
+     * 
+     * @return a boolean representing if this has a token value.
+     */
+    public boolean isToken() {
+        return token != null;
+    }
+}

Propchange: webservices/woden/branches/woden65/src/org/apache/woden/types/QNameTokenUnion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ComponentExtensions.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ComponentExtensions.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ComponentExtensions.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ComponentExtensions.java Mon Jan  7 09:36:13 2008
@@ -44,10 +44,10 @@
     /**
      * Namespace URIs for extensions defined by WSDL 2.0 Specification.
      */
-    public static final URI URI_NS_SOAP = URI.create("http://www.w3.org/ns/wsdl/soap");
-    public static final URI URI_NS_HTTP = URI.create("http://www.w3.org/ns/wsdl/http");
-    public static final URI URI_NS_RPC = URI.create("http://www.w3.org/ns/wsdl/rpc");
-    public static final URI URI_NS_EXTENSIONS = URI.create("http://www.w3.org/ns/wsdl-extensions");
+    public static final URI NS_URI_SOAP = URI.create("http://www.w3.org/ns/wsdl/soap");
+    public static final URI NS_URI_HTTP = URI.create("http://www.w3.org/ns/wsdl/http");
+    public static final URI NS_URI_RPC = URI.create("http://www.w3.org/ns/wsdl/rpc");
+    public static final URI NS_URI_WSDL_EXTENSIONS = URI.create("http://www.w3.org/ns/wsdl-extensions");
      
     /**
      * @return the non-WSDL URI shared by this group of extension properties

Added: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ExtensionRegistrar.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ExtensionRegistrar.java?rev=609714&view=auto
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ExtensionRegistrar.java (added)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ExtensionRegistrar.java Mon Jan  7 09:36:13 2008
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.wsdl20.extensions;
+
+/**
+ * Registers Woden extensions with an existing registry.
+ * 
+ * @author Peter Danielsen 
+ *
+ */
+public interface ExtensionRegistrar {
+	
+	/**
+	 * Registers Woden extensions with an existing registry.
+	 * @param registry
+	 */
+	public void registerExtensions(ExtensionRegistry registry);
+}

Propchange: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ExtensionRegistrar.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java Mon Jan  7 09:36:13 2008
@@ -19,7 +19,9 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -28,6 +30,7 @@
 import org.apache.woden.ErrorReporter;
 import org.apache.woden.WSDLException;
 import org.apache.woden.XMLElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
 import org.apache.woden.wsdl20.xml.WSDLElement;
 import org.apache.woden.xml.UnknownAttr;
 import org.apache.woden.xml.XMLAttr;
@@ -59,8 +62,23 @@
     this.errorReporter = errorReporter;  
     setDefaultSerializer(new UnknownExtensionSerializer());
     setDefaultDeserializer(new UnknownExtensionDeserializer());
+    registerResourceBundle(CORE_RESOURCE_BUNDLE);
   }
 
+  /**
+   * The property containing the comma-separated listed of ExtensionRegistrars.
+   * The property name is <code>org.apache.woden.extensionregistrars</code>.
+   */
+    public static final String REGISTRAR_PROPERTY = "org.apache.woden.extensionregistrars";
+
+  /**
+   * This property specifies the resource bundle containing the
+   * core Woden extension registry error messages.
+   * 
+   * TODO extract these errors to a new public (non-internal) bundle.
+   */
+    static final private String CORE_RESOURCE_BUNDLE = "org.apache.woden.internal.Messages";
+    
   /*
     This is a Map of Maps. The top-level Map is keyed by (Class)parentType,
     and the inner Maps are keyed by (QName)elementQN.
@@ -91,14 +109,12 @@
    */
   protected Map compExtReg = new Hashtable();
   
-  private ErrorReporter errorReporter = null;
+  /*
+   * Error message property files.
+   */
+  private List fResourceBundleNames = new ArrayList();
   
-  /*JKctx
-  public void setErrorReporter(ErrorReporter errRpt)
-  {
-      this.errorReporter = errRpt;
-  }
-  */
+  private ErrorReporter errorReporter = null;
   
   public ErrorReporter getErrorReporter()
   {
@@ -731,4 +747,14 @@
       return compExt;
   }
   
+    public void registerResourceBundle(String resourceBundleName) {
+        fResourceBundleNames.add(resourceBundleName);
+    }
+    
+    public String[] queryResourceBundleNames() {
+        String[] array = new String[fResourceBundleNames.size()];
+        fResourceBundleNames.toArray(array);
+        return array;
+    }
+    
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingFaultPart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingFaultPart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingFaultPart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingFaultPart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -19,7 +19,6 @@
 
 import javax.xml.namespace.QName;
 import org.apache.woden.types.NCName;
-import org.apache.woden.xpointer.XPointer;
 /**
  * <code>BindingFaultPart</code> is a Binding Fault Pointer Part for the Binding Fault WSDL 2.0 component.
  * See the specification at <a href="http://www.w3.org/TR/wsdl20/#wsdl.bindingFault">http://www.w3.org/TR/wsdl20/#wsdl.bindingFault</a>
@@ -46,8 +45,8 @@
         this.fault = fault; 
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        fault = xpointer.prefixQNameNamespace(fault);
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return new BindingFaultPart(binding, fragmentIdentifier.prefixQNameNamespace(fault));
     }
 
     /**

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingFaultReferencePart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingFaultReferencePart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingFaultReferencePart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingFaultReferencePart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -19,7 +19,6 @@
 
 import javax.xml.namespace.QName;
 import org.apache.woden.types.NCName;
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>BindingFaultReferencePart</code> is a Binding Fault Reference Pointer Part for the Binding Fault Reference WSDL 2.0 component.
@@ -53,9 +52,10 @@
         this.fault = fault;
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        operation = xpointer.prefixQNameNamespace(operation);
-        fault = xpointer.prefixQNameNamespace(fault);
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        QName nOperation = fragmentIdentifier.prefixQNameNamespace(operation);
+        QName nFault = fragmentIdentifier.prefixQNameNamespace(fault);
+        return new BindingFaultReferencePart(binding, nOperation, message, nFault);
     }
     
     /**

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingMessageReferencePart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingMessageReferencePart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingMessageReferencePart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingMessageReferencePart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -19,7 +19,6 @@
 
 import javax.xml.namespace.QName;
 import org.apache.woden.types.NCName;
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>BindingMessageReferencePart</code> is a Binding Message Reference Pointer Part for the Binding Message Reference WSDL 2.0 component.
@@ -50,8 +49,8 @@
         this.message = message;
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        operation = xpointer.prefixQNameNamespace(operation);
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return new BindingMessageReferencePart(binding, fragmentIdentifier.prefixQNameNamespace(operation), message);
     }
     
     /**

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingOperationPart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingOperationPart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingOperationPart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingOperationPart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -19,7 +19,6 @@
 
 import javax.xml.namespace.QName;
 import org.apache.woden.types.NCName;
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>BindingOperationPart</code> is a Binding Operation Pointer Part for the Binding Operation WSDL 2.0 component.
@@ -47,8 +46,8 @@
         this.operation = operation;
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        operation = xpointer.prefixQNameNamespace(operation);
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return new BindingOperationPart(binding, fragmentIdentifier.prefixQNameNamespace(operation));
     }
     
     /**

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingPart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingPart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingPart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/BindingPart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -20,7 +20,6 @@
 import org.apache.woden.types.NCName;
 
 import org.apache.woden.wsdl20.Binding;
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>BindingPart</code> is a Binding Pointer Part for the Binding WSDL 2.0 component.
@@ -66,24 +65,7 @@
         return "wsdl.binding(" + binding + ")";
     }
     
-    /**
-     * An Idea...
-     * 
-     * @param string
-     * @return
-     */
-    public static BindingPart fromString(String string) {
-        //Properties to parse.
-        NCName binding;
-        
-        //Parse and get values.
-        binding = new NCName(string);
-        
-        //Return new BindingPart.
-        return new BindingPart(binding);
-    }
-    
-    public void prefixNamespaces(XPointer xpointer) {
-        //This PointerPart does not have any namespaces.
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return this;
     }
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ComponentPart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ComponentPart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ComponentPart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ComponentPart.java Mon Jan  7 09:36:13 2008
@@ -25,7 +25,16 @@
  * @author Dan Harvey (danharvey42@gmail.com)
  *
  */
-
 public interface ComponentPart extends PointerPart {
 
+    /**
+     * Checks that the namespace prefixes used in this PointerPart are consistent with those in the WSDL Fragment Identifier.
+     * It returns a identical copy of this object with the required changes.
+     * This method is called by the add method on WSDL Fragment Identifier when PointerParts are added to it.
+     * 
+     * @param fragmentIdentifier a Fragment Identifier which the namespace prefixes are checked against.
+     * @return a ComponentPart which has been checked with changed namespaces if needed.
+     */
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier);
+    
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/DescriptionPart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/DescriptionPart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/DescriptionPart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/DescriptionPart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -17,7 +17,6 @@
 
 package org.apache.woden.wsdl20.fragids;
 
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>DescriptionPart</code> is a Description Pointer Part for the Description WSDL 2.0 component.
@@ -37,8 +36,8 @@
         return "wsdl.description()";
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        //This PointerPart does not have any namespaces.
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return this;
     }
     
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ElementDeclarationPart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ElementDeclarationPart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ElementDeclarationPart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ElementDeclarationPart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -20,7 +20,6 @@
 import javax.xml.namespace.QName;
 
 import org.apache.woden.WSDLReader;
-import org.apache.woden.xpointer.XPointer;
 
 import java.net.URI;
 
@@ -54,10 +53,6 @@
         }
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        element = xpointer.prefixQNameNamespace(element);
-    }
-    
     /**
      * Constructs a ElementDeclarationPart class for an Element Declaration component with another type system.
      * 
@@ -70,6 +65,18 @@
         }
         this.element = element;
         this.system = null;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.woden.wsdl20.fragids.ComponentPart#prefixNamespaces(org.apache.woden.wsdl20.fragids.FragmentIdentifier)
+     */
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        if (system == null) {
+            return new ElementDeclarationPart(fragmentIdentifier.prefixQNameNamespace(element));
+        } else {
+            return new ElementDeclarationPart(fragmentIdentifier.prefixQNameNamespace(element), system);
+        }
     }
     
     /**

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/EndpointPart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/EndpointPart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/EndpointPart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/EndpointPart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -18,7 +18,6 @@
 package org.apache.woden.wsdl20.fragids;
 
 import org.apache.woden.types.NCName;
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>EndpointPart</code> is a Endpoint Pointer Part for the Endpoint WSDL 2.0 component.
@@ -35,7 +34,7 @@
      * Constructs an EndpointPart class from the values given.
      * 
      * @param service the local name of the parent Service component.
-     * @param service the  name of the Endpoint component.
+     * @param endpoint the name of the Endpoint component.
      * @throws IllegalArgumentException if service or endpoint are null.
      */
     public EndpointPart(NCName service, NCName endpoint) {
@@ -55,8 +54,8 @@
         return "wsdl.endpoint(" + service + "/" + endpoint + ")";
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        //This PointerPart does not have any namespaces.
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return this;
     }
 
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ExtensionsPart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ExtensionsPart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ExtensionsPart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ExtensionsPart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -19,7 +19,6 @@
 
 import java.net.URI;
 
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>ExtensionPart</code> is a Extension Pointer Part for the Extension WSDL 2.0 component.
@@ -46,6 +45,10 @@
         this.namespace = namespace;
         this.identifier = identifier;
     }
+    
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return this;
+    }
 
     /**
      * Returns a String of the serialised Extension Pointer Part.
@@ -54,10 +57,5 @@
      */
     public String toString() {
         return "wsdl.extension(" + namespace + "/" + identifier + ")";
-    }
-    
-    public void prefixNamespaces(XPointer xpointer) {
-        //This PointerPart does not have any namespaces.
-    }
-    
+    } 
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/FragmentIdentifier.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/FragmentIdentifier.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/FragmentIdentifier.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/FragmentIdentifier.java Mon Jan  7 09:36:13 2008
@@ -17,8 +17,12 @@
 
 package org.apache.woden.wsdl20.fragids;
 
+import javax.xml.namespace.QName;
+
+import org.apache.woden.types.NCName;
 import org.apache.woden.wsdl20.fragids.ComponentPart;
 import org.apache.woden.xpointer.XPointer;
+import org.apache.woden.xpointer.XmlnsPointerPart;
 
 /**
  * This Class extends the XPointer class to work with WSDL fragment identifiers which are WSDL XPointer in effect.
@@ -30,26 +34,82 @@
  *
  */
 
-public class FragmentIdentifier extends XPointer{
-
+public class FragmentIdentifier {
+    private static XPointer xpointer;
+    
     /**
      * Constructs a new empty Fragment Identifier
      * 
-     * @param wsdlpart The WSDL2.0 component pointer part for this fragment identifier.
+     * @param wsdlPart The WSDL2.0 component pointer part for this fragment identifier.
      * 
-     * TODO add support for leading XPointer parts when we support embedded WSDL 2.0
      */
-    public FragmentIdentifier(ComponentPart wsdlpart) {
-        super();
-        addPart(wsdlpart);
+    public FragmentIdentifier(ComponentPart wsdlPart) {
+        xpointer = new XPointer();
+        wsdlPart = wsdlPart.prefixNamespaces(this); //Prefix namespaces if needed.
+        xpointer.addPointerPart(wsdlPart);
     }
-    
+
     /**
      * Returns a String serialisation of this fragment identifier.
      * 
      * @return a String fragment identifier
      */
     public String toString() {
-        return super.toString();
+        return xpointer.toString();
+    }
+    
+    /** Namespace management code **/
+    /**
+     * Returns the prefix for the Xml namespace of the QName in the XPointer.
+     * If the namespace does not have a prefix in the XPointer it will create a new prefix
+     * with the prefix from the QName or one of the form nsXX and add a xmlns Pointer Part, then return that.
+     * 
+     * @param qname The QName containing the namespace and a prefix.
+     * @return a NCName of the prefix for the namespace.
+     */
+    public NCName getXmlNamespacePrefix(QName qname) {
+        return getXmlNamespacePrefix(qname.getNamespaceURI());
+    }
+
+    /**
+     * Returns the prefix for the Xml namespace in the XPointer.
+     * If the namespace does not have a prefix in the XPointer it will create a new prefix
+     * of the form nsXX and add a xmlns Pointer Part, then return that.
+     * 
+     * @param namespace The namespace to get the prefix for.
+     * @return a NCName of the prefix for the namespace.
+     */
+    public NCName getXmlNamespacePrefix(String namespace) {
+        //Lookup prefix
+        NCName prefix = (NCName)xpointer.getNamespaceBinding(namespace);
+        if (prefix == null) {
+            //The namespace does not have a prefix yet so lets add one.
+            //Find next available nsXXX prefix
+            int i = 1;
+            do {
+                prefix = new NCName("ns" + i);
+                i++;
+            } while (xpointer.hasPrefixBinding(prefix));
+            
+            //Add prefix pointer part.
+            xpointer.addPointerPart(new XmlnsPointerPart(prefix, namespace));
+            
+            //Add to our binding contex. 
+            xpointer.addPrefixNamespaceBinding(prefix, namespace);
+        }
+        return prefix;
+    }
+    
+    /**
+     * Returns a QName prefixed from the map of local namespaces and prefixes.
+     * The namespace and localpart remain unchanged.
+     * 
+     * @param qname the QName used to lookup the namespace and copy.
+     * @return a QName with the new prefix, but same namespace and localpart.
+     */
+    public QName prefixQNameNamespace(QName qname) {
+        //Get prefix for the fault QName in the XPointer.
+        NCName prefix = getXmlNamespacePrefix(qname);
+        return new QName(qname.getNamespaceURI(), qname.getLocalPart(), prefix.toString());
     }
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceFaultPart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceFaultPart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceFaultPart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceFaultPart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -18,7 +18,6 @@
 package org.apache.woden.wsdl20.fragids;
 
 import org.apache.woden.types.NCName;
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>InterfaceFaultPart</code> is a Interface Fault Pointer Part for the Interface Fault WSDL 2.0 component.
@@ -55,8 +54,8 @@
         return "wsdl.interfaceFault(" + interfaceName + "/" + fault + ")";
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        //This PointerPart does not have any namespaces.
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return this;
     }
     
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceFaultReferencePart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceFaultReferencePart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceFaultReferencePart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceFaultReferencePart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -19,7 +19,6 @@
 
 import javax.xml.namespace.QName;
 import org.apache.woden.types.NCName;
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>InterfaceFaultReferencePart</code> is a Interface Fault Reference Pointer Part for the Interface Fault Reference WSDL 2.0 component.
@@ -53,8 +52,8 @@
         this.fault = fault;
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        fault = xpointer.prefixQNameNamespace(fault);
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return new InterfaceFaultReferencePart(interfaceName, operation, message, fragmentIdentifier.prefixQNameNamespace(fault));
     }
     
     /**

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceMessageReferencePart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceMessageReferencePart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceMessageReferencePart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceMessageReferencePart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -18,7 +18,6 @@
 package org.apache.woden.wsdl20.fragids;
 
 import org.apache.woden.types.NCName;
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>InterfaceMessageReferencePart</code> is a Interface Message Reference Pointer Part for the Interface Message Reference WSDL 2.0 component.
@@ -58,8 +57,8 @@
         return "wsdl.interfaceMessageReference(" + interfaceName + "/" + operation + "/" + message + ")";
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        //This PointerPart does not have any namespaces.
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return this;
     }
 
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceOperationPart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceOperationPart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceOperationPart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfaceOperationPart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -18,7 +18,6 @@
 package org.apache.woden.wsdl20.fragids;
 
 import org.apache.woden.types.NCName;
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>InterfaceOperationPart</code> is a Interface Operation Pointer Part for the Interface Operation WSDL 2.0 component.
@@ -55,7 +54,7 @@
         return "wsdl.interfaceOperation(" + interfaceName + "/" + operation + ")";
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        //This PointerPart does not have any namespaces.
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return this;
     }
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfacePart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfacePart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfacePart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/InterfacePart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -18,7 +18,6 @@
 package org.apache.woden.wsdl20.fragids;
 
 import org.apache.woden.types.NCName;
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>InterfacePart</code> is a Interface Pointer Part for the Interface WSDL 2.0 component.
@@ -52,7 +51,7 @@
         return "wsdl.interface(" + interfaceName + ")";
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        //This PointerPart does not have any namespaces.
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return this;
     }
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ServicePart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ServicePart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ServicePart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/ServicePart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -18,7 +18,6 @@
 package org.apache.woden.wsdl20.fragids;
 
 import org.apache.woden.types.NCName;
-import org.apache.woden.xpointer.XPointer;
 
 /**
  * <code>ServicePart</code> is a Service Pointer Part for the Service WSDL 2.0 component.
@@ -52,8 +51,8 @@
         return "wsdl.service(" + service + ")";
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        //This PointerPart does not have any namespaces.
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        return this;
     }
 
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/TypeDefinitionPart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/TypeDefinitionPart.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/TypeDefinitionPart.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/fragids/TypeDefinitionPart.java Mon Jan  7 09:36:13 2008
@@ -1,4 +1,4 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -19,7 +19,6 @@
 
 import javax.xml.namespace.QName;
 
-import org.apache.woden.xpointer.XPointer;
 
 import java.net.URI;
 
@@ -63,8 +62,16 @@
         this.system = null;
     }
     
-    public void prefixNamespaces(XPointer xpointer) {
-        type = xpointer.prefixQNameNamespace(type);
+    /*
+     * (non-Javadoc)
+     * @see org.apache.woden.wsdl20.fragids.ComponentPart#prefixNamespaces(org.apache.woden.wsdl20.fragids.FragmentIdentifier)
+     */
+    public ComponentPart prefixNamespaces(FragmentIdentifier fragmentIdentifier) {
+        if (system == null) {
+            return new TypeDefinitionPart(fragmentIdentifier.prefixQNameNamespace(type));
+        } else {
+            return new TypeDefinitionPart(fragmentIdentifier.prefixQNameNamespace(type), system);
+        }
     }
     
     /**

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/BindingFaultReferenceElement.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/BindingFaultReferenceElement.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/BindingFaultReferenceElement.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/BindingFaultReferenceElement.java Mon Jan  7 09:36:13 2008
@@ -51,11 +51,11 @@
     
     /**
      * Return the InterfaceFaultReferenceElement referred to by this BindingFaultReferenceElement.
-     * This equates to the interface operation &lt;infault&gt; or &lt;outfault&gt; element 
-     * referred to by the <code>ref</code> attribute of the binding operation &lt;infault&gt; 
-     * or &lt;outfault&gt; element.
-     * If this reference cannot be resolved to an InterfaceFaultReferenceElement, this method will
-     * return null.
+     * This equates to an &lt;infault&gt; or &lt;outfault&gt; element of the interface operation being
+     * bound whose message label is equal to the effective message label of this binding fault
+     * reference and whose associated interface fault is identified by the <code>ref</code> attribute
+     * if this binding fault reference.
+     * If such an element does not exist, this method will return null.
      * 
      * @return the InterfaceFaultReferenceElement
      */

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/BindingMessageReferenceElement.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/BindingMessageReferenceElement.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/BindingMessageReferenceElement.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/BindingMessageReferenceElement.java Mon Jan  7 09:36:13 2008
@@ -68,4 +68,16 @@
      * @return NCName the message label
      */
     public NCName getMessageLabel();
-}
+    
+    /**
+     * Return the InterfaceMessageReferenceElement associated with this BindingMessageReferenceElement.
+     * This equates to an &lt;input&gt; or &lt;output&gt; element of the interface operation being
+     * bound whose message label is equal to the effective message label of this binding message
+     * reference.
+     * If such an element does not exist, this method will return null.
+     * 
+     * @return the InterfaceMessageReferenceElement
+     */
+    public InterfaceMessageReferenceElement getInterfaceMessageReferenceElement();
+    
+  }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/DescriptionElement.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/DescriptionElement.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/DescriptionElement.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/DescriptionElement.java Mon Jan  7 09:36:13 2008
@@ -17,7 +17,6 @@
 package org.apache.woden.wsdl20.xml;
 
 import java.net.URI;
-import java.util.Map;
 
 import org.apache.woden.WSDLException;
 import org.apache.woden.wsdl20.Description;
@@ -73,54 +72,6 @@
      */
     public URI getTargetNamespace();
 
-    /**
-     * Associate the specified prefix with the specified namespace URI.
-     * This equates to adding an <code>xmlns</code> namespace declaration to the 
-     * &lt;description&gt; element. 
-     * To define the default namespace, specify null or the empty string "" for the prefix.
-     * If null is specified for the namespace URI, the prefix/namespace association will be
-     * removed (i.e. the same behaviour as the <code>removeNamespace</code> method).
-     * If the specified prefix is already associated with a namespace URI, 
-     * that association will be replaced by the specified prefix/namespace association. 
-     *
-     * @param prefix the prefix String associated with <code>namespace</code>
-     * @param namespace the namespace URI associated with <code>prefix</code>
-     */
-    public void addNamespace(String prefix, URI namespace);
-    
-    /**
-     * Remove the namespace URI associated with the specified prefix.
-     * This equates to removing an <code>xmlns</code> namespace declaration from the 
-     * &lt;description&gt; element.
-     * To remove the default namespace, specify null or the empty string "" for the prefix.
-     * If the specified prefix is not associated with a namespace, no action is performed.
-     * 
-     * @param prefix the prefix String associated with a namespace
-     */
-    public void removeNamespace(String prefix);
-    
-    /**
-     * Return the namespace URI associated with the specified prefix.
-     * This equates to an <code>xmlns</code> namespace declaration on the 
-     * &lt;description&gt; element.
-     * To return the default namespace, specify null or the empty string "" for the prefix.
-     * If the specified prefix is not associated with a namespace, null is returned.
-     * 
-     * @param prefix the prefix String associated with a namespace
-     */
-    public URI getNamespace(String prefix);
-    
-    /**
-     * Return the set of all prefix/namespace URI associations.
-     * This equates to all of the <code>xmlns</code> namespace declaration on the 
-     * &lt;description&gt; element.
-     * 
-     * @deprecated in M7, to be replaced in M8 with a type-safe return type (WODEN-140)
-     * 
-     * @return a Map of prefix String / namespace URI pairs 
-     */
-    public Map getNamespaces(); //TODO type-safe return type
-    
     /*
      * Element factory methods
      */

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java Mon Jan  7 09:36:13 2008
@@ -19,6 +19,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 
 /**
@@ -47,24 +48,24 @@
     public QName getName();
     
     /**
-     * Specify the name of the global schema element declaration referred to by this 
+     * Specify the union of the xs:token and xs:QName of the global schema element declaration referred to by this 
      * InterfaceFaultElement.
      * The specified QName corresponds to the <code>element</code> attribute of the interface 
      * &lt;fault&gt; element.
      *
-     * @param elementName the QName of the element declaration
+     * @param elementName the QNameTokenUnion of the element declaration
      */
-    public void setElementName(QName elementName);
+    public void setElement(QNameTokenUnion elementName);
     
     /**
-     * Return the name of the global schema element declaration referred to by this 
+     * Return the union of the xs:token and xs:QName of the global schema element declaration referred to by this 
      * InterfaceFaultElement.
      * This corresponds to the <code>element</code> attribute of the interface 
      * &lt;fault&gt; element.
      * 
-     * @return the QName of the element declaration
+     * @return the QNameTokenUnion of the element declaration
      */
-    public QName getElementName();
+    public QNameTokenUnion getElement();
     
     /**
      * Return the XmlSchemaElement representing the global schema element declaration
@@ -78,6 +79,6 @@
      * 
      * @return the XmlSchemaElement
      */
-    public XmlSchemaElement getElement();
+    public XmlSchemaElement getXmlSchemaElement();
 
 }

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java Mon Jan  7 09:36:13 2008
@@ -19,6 +19,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
 import org.apache.woden.wsdl20.enumeration.Direction;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 
@@ -54,37 +55,24 @@
     public NCName getMessageLabel();
     
     /**
-     * @deprecated This is a property of the component model, not the infoset, so it is deprecated in M7
-     * and will be removed for M8 (WODEN-136) 
-     */
-    public void setMessageContentModel(String nmToken);
-    
-    
-    /**
-     * @deprecated This is a property of the component model, not the infoset, so it is deprecated in M7
-     * and will be removed for M8 (WODEN-136) 
-     */
-    public String getMessageContentModel();
-    
-    /**
-     * Specify the name of the global schema element declaration referred to by this 
+     * Specify the union of the xs:token and xs:QName of the global schema element declaration referred to by this 
      * InterfaceMessageReferenceElement.
-     * The specified QName corresponds to the <code>element</code> attribute of the interface 
+     * The specified QNameTokenEnum corresponds to the <code>element</code> attribute of the interface 
      * operation &lt;input&gt; or &lt;output&gt; element.
      *
-     * @param elementName the QName of the element declaration
+     * @param element the QNameTokenEnum of the element declaration.
      */
-    public void setElementName(QName elementName);
+    public void setElement(QNameTokenUnion element);
     
     /**
-     * Return the name of the global schema element declaration referred to by this 
+     * Return the union of the xs:token and xs:QName of the global schema element declaration referred to by this 
      * InterfaceMessageReferenceElement.
      * This corresponds to the <code>element</code> attribute of the interface 
      * operation &lt;input&gt; or &lt;output&gt; element.
      * 
-     * @return the QName of the element declaration
+     * @return the QNameTokenEnum of the element declaration
      */
-    public QName getElementName();
+    public QNameTokenUnion getElement();
     
     /**
      * Return the XmlSchemaElement representing the global schema element declaration
@@ -98,7 +86,7 @@
      * 
      * @return the XmlSchemaElement
      */
-    public XmlSchemaElement getElement();
+    public XmlSchemaElement getXmlSchemaElement();
     
     /**
      * Set the message direction using the specified enumerated type, Direction,

Modified: webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/WSDLElement.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/WSDLElement.java?rev=609714&r1=609713&r2=609714&view=diff
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/WSDLElement.java (original)
+++ webservices/woden/branches/woden65/src/org/apache/woden/wsdl20/xml/WSDLElement.java Mon Jan  7 09:36:13 2008
@@ -16,6 +16,8 @@
  */
 package org.apache.woden.wsdl20.xml;
 
+import java.net.URI;
+import org.apache.woden.types.NamespaceDeclaration;
 import org.apache.woden.wsdl20.extensions.AttributeExtensible;
 import org.apache.woden.wsdl20.extensions.ElementExtensible;
 
@@ -32,4 +34,72 @@
      * element extensibility, so by inheriting directly or indirectly from this 
      * interface they also inherit the extensibility interfaces.
      */
+    
+    /**
+     * Associate the specified prefix with the specified namespace URI to this WSDL element.
+     * This equates to adding an <code>xmlns</code> namespace declaration to this 
+     * WSDL element. 
+     * To define the default namespace, specify null or the empty string "" for the prefix.
+     * If null is specified for the namespace URI, the prefix/namespace association will be
+     * removed (i.e. the same behaviour as the <code>removeNamespace</code> method).
+     * If the specified prefix is already associated with a namespace URI, 
+     * that association will be replaced by the specified prefix/namespace association. 
+     *
+     * @param prefix the prefix String associated with <code>namespaceURI</code>
+     * @param namespaceURI the namespace URI associated with <code>prefix</code>
+     */
+    public void addNamespace(String prefix, URI namespaceURI);
+    
+    /**
+     * Remove the namespace URI associated with the specified prefix from this WSDL element.
+     * This equates to removing an <code>xmlns</code> namespace declaration from this
+     * WSDL element.
+     * To remove the default namespace, specify null or the empty string "" for the prefix.
+     * 
+     * @param prefix the prefix String associated with the namespace to be removed
+     * @return the removed namespace URI or null if no prefix/namespace association exists
+     */
+    public URI removeNamespace(String prefix);
+    
+    
+    /**
+     * Return the namespace URI associated with the specified prefix.
+     * The scope of the search correponds to the scope of namespace declarations 
+     * in XML. That is, from the current element upwards to the root element
+     * (to the wsdl:description).
+     *  
+     * @param prefix the prefix whose associated namespace URI is required
+     * @return the associated namespace URI
+     */
+    public URI getNamespaceURI(String prefix);
+    
+    /**
+     * Return the prefix associated with the specified namespace URI.
+     * The scope of the search corresponds to the scope of namespace declarations
+     * in XML. That is, from the current element upwards to the root element
+     * (to the wsdl:description).
+     * 
+     * @param namespaceURI the namespace URI whose associated prefix is required
+     * @return the associated prefix String
+     */
+    public String getNamespacePrefix(URI namespaceURI);
+    
+    /**
+     * Return the namespaces and their associated prefixes declared directly
+     * within this WSDL element.
+     * 
+     * @return an array of NamespaceDeclaration
+     */
+    public NamespaceDeclaration[] getDeclaredNamespaces();
+    
+    /**
+     * Return all namespaces and their associated prefixes that are in-scope
+     * to this WSDL element. That is, those declared directly within this element
+     * and those declared in ancestor elements upwards to the root element
+     * (to the wsdl:description).
+     * 
+     * @return an array of NamespaceDeclaration
+     */
+    public NamespaceDeclaration[] getInScopeNamespaces();
+    
 }

Added: webservices/woden/branches/woden65/src/org/apache/woden/xpointer/ElementPointerPart.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/xpointer/ElementPointerPart.java?rev=609714&view=auto
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/xpointer/ElementPointerPart.java (added)
+++ webservices/woden/branches/woden65/src/org/apache/woden/xpointer/ElementPointerPart.java Mon Jan  7 09:36:13 2008
@@ -0,0 +1,264 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.xpointer;
+
+import org.apache.woden.types.NCName;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.lang.StringBuffer;
+
+import java.lang.NumberFormatException;
+
+/**
+ * ElementPointerPart is a class which represents the element() scheme for the XPointer Framework.
+ * The specification is defined at <a href="http://www.w3.org/TR/xptr-element/">http://www.w3.org/TR/xptr-element/</a>
+ * 
+ * This class is immutable.
+ * 
+ * @author Dan Harvey (danharvey42@gmail.com)
+ *
+ */
+public class ElementPointerPart implements PointerPart {
+    private final NCName ncname;
+    private final List childSequence;
+    
+    /**
+     * Constructs an ElementPointerPart with only an elementID NCName.
+     * 
+     * @param elementID an NCName of the elementID to reference.
+     * @throws NullPointerException is a null elementID is given.
+     */
+    public ElementPointerPart(NCName elementID) {
+        if(elementID == null) {
+            throw new NullPointerException("The elementID argument is null.");
+        }
+        this.ncname = elementID;
+        this.childSequence = null;
+    }
+    
+    /**
+     * Constructs an ElementPointerPart with only a childSequence.
+     * 
+     * @param childSequence a List of Integers representing the child sequence.
+     * @throws NullPointerException if childSequence is null.
+     * @throws IllegalArgumentException if childSequence is empty or contains elements other than Integers.
+     */
+    public ElementPointerPart(List childSequence) {
+        if(childSequence == null) {
+            throw new NullPointerException("The childSequence argument is null.");
+        }
+        if(childSequence.isEmpty()) {
+            throw new IllegalArgumentException("The childSequence list is empty.");
+        }
+        for(Iterator it = childSequence.iterator(); it.hasNext();) {
+            if(!(it.next() instanceof Integer)){
+                throw new IllegalArgumentException("The childSequence list must only contain Integers.");
+            }
+        }
+        this.ncname = null;
+        this.childSequence = childSequence;
+    }
+    
+    /**
+     * Constructs an ElementPointerPart with both an NCName and a childSequence.
+     * 
+     * @param elementID an NCName of the elementID to reference.
+     * @param childSequence a List of Integers representing the child sequence.
+     * @throws NullPointerException if elementID or childSequence are null.
+     * @throws IllegalArgumentException if childSequence is empty or contains elements other than Integers.
+     */
+    public ElementPointerPart(NCName elementID, List childSequence) {
+        if(elementID == null) {
+            throw new NullPointerException("The elementID argument is null.");
+        }
+        if(childSequence == null) {
+            throw new NullPointerException("The childSequence argument is null.");
+        }
+        if(childSequence.isEmpty()) {
+            throw new IllegalArgumentException("The childSequence list is empty.");
+        }
+        for(Iterator it = childSequence.iterator(); it.hasNext();) {
+            Object integer = it.next();
+            if(!(integer instanceof Integer)){
+                throw new IllegalArgumentException("the childSequence list must only contain Integers.");
+            } else if (((Integer)integer).intValue() == 0){
+                throw new IllegalArgumentException("the childSequence list must only contain Integers bigger than 0.");
+            }
+        }
+        this.ncname = elementID;
+        this.childSequence = childSequence;
+    }
+    
+    /**
+     * Returns the NCName for this Element PointerPart.
+     * 
+     * @return an NCName if it exists in this Element PointerPart, otherwise null.
+     */
+    public NCName getNCName() {
+        return ncname;
+    }
+    
+    /**
+     * Returns the child sequence of this Element PointerPart.
+     * 
+     * @return a Integer[] of the child sequence for this element pointer part, or an empty array if none exists. 
+     */
+    public Integer[] getChildSequence() {
+        int size = childSequence.size();
+        Integer[] sequence = new Integer[size];
+        for(int i=0; i<size; i++) {
+            sequence[i] = (Integer)childSequence.get(i);
+        }
+        return sequence;
+    }
+    
+    /**
+     * Checks if this Element PointerPart has a NCName or not.
+     * 
+     * @return a boolean, true if it has a NCName or false if not.
+     */
+    public boolean hasNCName() {
+        return ncname != null;
+    }
+    
+    /**
+     * Checks if this Element PointerPart has a childSequence or not.
+     * 
+     * @return a boolean, true if this has a childSequence or false if not.
+     */
+    public boolean hasChildSequence() {
+        return childSequence != null;
+    }
+    
+    /*
+     *(non-Javadoc)
+     * @see org.apache.woden.xpointer.PointerPart#toString()
+     */
+    public String toString() {
+        String schemeData;
+        if (childSequence == null) {
+            schemeData = ncname.toString();
+        } else if (ncname == null) {
+            schemeData = serialiseChildSequence();
+        } else {
+            schemeData = ncname.toString() + serialiseChildSequence();
+        }
+        return "element(" + schemeData + ")";
+    }
+    
+    /**
+     * Serialises the child sequence and returns it as a string.
+     * 
+     * @return a String of the serialised child sequence.
+     */
+    private String serialiseChildSequence() {
+        StringBuffer buffer = new StringBuffer();
+        for(Iterator it = childSequence.iterator(); it.hasNext();) {
+            Integer child = (Integer)it.next();
+            buffer.append("/" + child.toString());
+        }
+        return buffer.toString();
+    }
+    
+    /**
+     * Deserialises the schemaData for an ElementPointerPart and constructs a new ElementPointerPart from it.
+     * 
+     * @param schemeData a String of the schemeaData parsed from the string XPointer.
+     * @return an ElementPointerPart representing the parsed schemaData.
+     * @throws IllegalArgumentException if the schemeData has invalid scheme syntax.
+     */
+    public static ElementPointerPart parseFromString(final String schemeData) throws InvalidXPointerException {
+        List childSequence = null;
+        NCName elementID = null;
+        int startChar;
+        int endChar;
+        
+        //Find an NCName if it exists?
+        startChar = schemeData.indexOf("/");
+        // -1 Only an NCName. 0 No NCName. > 1 An NCName.
+        
+        switch (startChar) {
+            case -1: //Only an NCName.
+                try {
+                    elementID = new NCName(schemeData);
+                }
+                catch (IllegalArgumentException e) {
+                    throw new InvalidXPointerException("Invalid NCName in the XPointer", schemeData);
+                }
+                return new ElementPointerPart(elementID);
+            case 0: //No NCName.
+                break;
+            default: //An NCName.
+                try {
+                    elementID = new NCName(schemeData.substring(0, startChar));
+                } catch (IllegalArgumentException e) {
+                    throw new InvalidXPointerException("Invalid NCName in the XPointer", schemeData, 0, startChar);
+                }
+                break;
+        }
+        
+        //Find remaining child sequence.
+        childSequence = new ArrayList();
+        
+        endChar = schemeData.indexOf("/", startChar+1);
+        // -1 Only single child sequence element. > 0 A childSequence.
+        
+        if (endChar < 0) { //Only single child sequence element.
+            childSequence.add(parseIntegerFromChildSequence(schemeData, startChar+1, schemeData.length()));
+        } else { //Multiple child sequence elements.
+            while(true) {
+                if (endChar < 0) {//Last integer.
+                    childSequence.add(parseIntegerFromChildSequence(schemeData, startChar+1, schemeData.length()));
+                    break;
+                } else { //Inner sequence integer.
+                    childSequence.add(parseIntegerFromChildSequence(schemeData, startChar+1, endChar));
+                    startChar = endChar;
+                    endChar = schemeData.indexOf("/", startChar+1);
+                }
+            }
+        }
+
+        if (elementID == null) { //Only a childSequence
+            return new ElementPointerPart(childSequence);
+        } else { //Both NCName and childSequence
+            return new ElementPointerPart(elementID, childSequence);
+        }
+    }
+
+    /**
+     * Parses a String for an integer between two indices and returns this as an Integer.
+     * 
+     * @param string a String to parse.
+     * @param start an int char index to the start of the Integer.
+     * @param end an int char index to the end of the Integer.
+     * @return an Integer resulting from parsing the given String in the index range.
+     * @throws IllegalArgumentException if the given char range does not contain an integer.
+     */
+    private static Integer parseIntegerFromChildSequence(String string, int start, int end) throws InvalidXPointerException{
+        if (start < end) { //Make sure sub string is not of zero length.
+            try { //Make sure the integer is valid.
+                return new Integer(string.substring(start, end));
+            } catch (NumberFormatException e) {
+                throw new InvalidXPointerException("The child sequence part contained a invalid integer.", string,  start, end);
+            }
+        } else {
+            throw new InvalidXPointerException("The child sequence part contained a empty item at " + String.valueOf(start), string, start, end);
+        }
+    }
+}

Propchange: webservices/woden/branches/woden65/src/org/apache/woden/xpointer/ElementPointerPart.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/woden/branches/woden65/src/org/apache/woden/xpointer/InvalidXPointerException.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden65/src/org/apache/woden/xpointer/InvalidXPointerException.java?rev=609714&view=auto
==============================================================================
--- webservices/woden/branches/woden65/src/org/apache/woden/xpointer/InvalidXPointerException.java (added)
+++ webservices/woden/branches/woden65/src/org/apache/woden/xpointer/InvalidXPointerException.java Mon Jan  7 09:36:13 2008
@@ -0,0 +1,141 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.woden.xpointer;
+
+/**
+ * This class represents Exceptions that can happen during parsing an XPointer Expression.
+ * 
+ * @author Dan Harvey <da...@gmail.com>
+ *
+ */
+public class InvalidXPointerException extends Exception {
+    private static final long serialVersionUID = 0;
+    private final String fragment;
+    private final Integer startChar;
+    private final Integer endChar;
+    
+    /**
+     * Constructs a InvalidXPointerException with a message and fragment properties.
+     * 
+     * @param message a String message of error.
+     * @param fragment a String fragment of the cause.
+     */
+    public InvalidXPointerException(String message, String fragment) {
+        this(message, fragment, null, null, null);
+    }
+    
+    /**
+     * Constructs a InvalidXPointerException with a message and fragment properties.
+     * 
+     * It also has a Throwable argument to support exception chaining.
+     * 
+     * @param message a String message of error.
+     * @param fragment a String fragment of the cause of the error.
+     * @param cause a Throwable which caused this exception to be thrown.
+     */
+    public InvalidXPointerException(String message, String fragment, Throwable cause) {
+        this(message, fragment, null, null, cause);
+    }
+    
+    /**
+     * Constructs a InvalidXPointerException with a message and fragment properties,
+     * and index to the cause inside the fragment.
+     * 
+     * @param message a String message of error.
+     * @param fragment a String fragment of the cause of the error.
+     * @param startChar a int char index to the start of the cause in the fragment.
+     * @param endChar a int char index to the end of the cause in the fragment.
+     */
+    public InvalidXPointerException(String message, String fragment, int startChar, int endChar) {
+        this(message, fragment, new Integer(startChar), new Integer(endChar), null);
+    }
+    
+    /**
+     * Constructs a InvalidXPointerException with a message and fragment properties,
+     * and index to the cause inside the fragment.
+     * 
+     * It also has a Throwable argument to support exception chaining.
+     * 
+     * @param message a String message of error.
+     * @param fragment a String fragment of the cause of the error.
+     * @param startChar an int char index to the start of the cause in the fragment.
+     * @param endChar an int char index to the end of the cause in the fragment.
+     * @param cause a Throwable which caused the exception to be thrown.
+     */
+    public InvalidXPointerException(String message, String fragment, int startChar, int endChar, Throwable cause) {
+        this(message, fragment, new Integer(startChar), new Integer(endChar), cause);
+    }
+
+    /**
+     * Constructs a new InvalidXPointerException.
+     * This constructor is called by all of the above constructors and stores the in indexes and Integers internally.
+     * 
+     * @param message a String message of error.
+     * @param fragment a String fragment of the cause of the error.
+     * @param startChar an Integer char index to the start of the cause in the fragment.
+     * @param endChar an Integer char index to the end of the cause in the fragment.
+     * @param cause a Throwable which caused the exception to be thrown.
+     */
+    private InvalidXPointerException(String message, String fragment, Integer startChar, Integer endChar, Throwable cause) {
+        super(message, cause);
+        this.fragment = fragment;
+        this.startChar = startChar;
+        this.endChar = endChar;
+    }
+       
+    /**
+     * Returns the fragment String stored inside this exception.
+     * 
+     * @return a String fragment.
+     */
+    public String getFragment() {
+        return fragment;
+    }
+    
+    /**
+     * Returns the startChar index of the cause of this error in the fragment.
+     * 
+     * @return an Integer of the startChar index if one exists, otherwise null.
+     */
+    public Integer getStartChar() {
+        return startChar;
+    }
+    
+    /**
+     * Returns the endChar index of the cause of this error in the fragment.
+     * 
+     * @return an Integer of the startChar index if one exists, otherwise null.
+     */
+    public Integer getEndChar() {
+        return endChar;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see java.lang.Throwable#toString()
+     */
+    public String toString() {
+        String postString;
+        if (startChar != null && endChar!= null) {
+            postString = "{XPointer: " + fragment + ", start: " + startChar.toString()+ ", end: " + endChar.toString() + ", substr: " + fragment.substring(startChar.intValue(), endChar.intValue()) + "}";
+        } else {
+            postString = "{XPointer: " + fragment + "}";
+        }
+        return "InvalidXPointerException: " + getMessage() + ". " + postString;
+    }
+
+}

Propchange: webservices/woden/branches/woden65/src/org/apache/woden/xpointer/InvalidXPointerException.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org