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 2007/09/11 01:04:05 UTC

svn commit: r574400 [2/2] - in /incubator/woden/trunk/java: src/org/apache/woden/internal/ src/org/apache/woden/internal/util/om/ src/org/apache/woden/internal/xpointer/ src/org/apache/woden/wsdl20/fragids/ src/org/apache/woden/xpointer/ test/org/apach...

Modified: incubator/woden/trunk/java/src/org/apache/woden/xpointer/XPointer.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/xpointer/XPointer.java?rev=574400&r1=574399&r2=574400&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/xpointer/XPointer.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/xpointer/XPointer.java Mon Sep 10 16:04:02 2007
@@ -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,128 +18,239 @@
 package org.apache.woden.xpointer;
 
 import java.util.List;
-import java.util.LinkedList;
+import java.util.ArrayList;
+import java.util.Map;
 import java.util.HashMap;
 
 import java.util.Iterator;
 import java.lang.StringBuffer;
 
 import org.apache.woden.types.NCName;
-import javax.xml.namespace.QName;
-import org.apache.woden.xpointer.XmlnsPart;
-
 
 /**
- * Represents a fragment identifier conforming to the XML Pointer Language Framework.
+ * XPointer is a class which represents an XPointer defined in the XPointer Framework.
+ * This is specified at <a href="http://www.w3.org/TR/xptr-framework/">http://www.w3.org/TR/xptr-framework/</a>
  * 
- * This class is based upon a class of the same name in the Apache Cocoon.
- *
  * @author Dan Harvey (danharvey42@gmail.com)
  * 
- * TODO Add a constructor to create a XPointer from a String by deserialisation.
- * 
  */
-
 public class XPointer {
+    private final Map prefixBindingContex;
+    private final Map namespaceBindingContex;
+    private NCName shorthandPointer;
     private final List pointerParts;
-    private final HashMap xmlnses;
+    
     private static final NCName emptyNCName = new NCName("");
-    private static String NS_URI_XML = "http://www.w3.org/XML/1998/namespace";
-    private static String NS_URI_XMLNS = "http://www.w3.org/2000/xmlns/";
+    
+    private static final String NS_URI_XML = "http://www.w3.org/XML/1998/namespace";
+    private static final String NS_URI_XMLNS = "http://www.w3.org/2000/xmlns/";
+    private static final NCName NS_PREFIX_XMLNS = new NCName("xmlns");
 
     /**
-     * Constructs a new Fragment Identifier.
+     * Constructs a new XPointer.
      * 
      */
     public XPointer() {
-        pointerParts = new LinkedList();
-        xmlnses = new HashMap();
+        pointerParts = new ArrayList();
+        shorthandPointer = emptyNCName;
+        
+        //Setup prefix/namespace binding context.
+        prefixBindingContex = new HashMap();
+        namespaceBindingContex = new HashMap();
+        addPrefixNamespaceBinding(new NCName("xml"), NS_URI_XML);
+    }
+    
+    /**
+     * Constructs a new XPointer from the serialised string.
+     * 
+     * @param xpointerString a String form of the XPointer to deserialise.
+     */
+    public XPointer(String xpointerString) throws InvalidXPointerException {
+        this(); //Construct a new XPointer.
+        if (xpointerString == null || xpointerString.equals(""))
+            throw new InvalidXPointerException("The XPointer string is either null or empty", "");
+        XPointerParser.parseXPointer(xpointerString, this); //Parse the string and add the Pointers to the new XPointer.
     }
     
     /**
      * Appends a pointer part to the end of this XPointer.
      * 
      * @param pointerPart the Pointer Part to append.
+     * @throws UnsupportedOperationException() if a Shorthand Pointer is already set.
      */
-    public void addPart(PointerPart pointerPart) {
-        pointerParts.add(pointerPart);
-        //Make sure the PointerPart's namespaces are in line with this XPointer.
-        pointerPart.prefixNamespaces(this); 
+    public void addPointerPart(PointerPart pointerPart) {
+        if(!shorthandPointer.equals(emptyNCName)) {
+            throw new UnsupportedOperationException("A Shortname Pointer already exists for this XPointer.");
+        } else {
+            pointerParts.add(pointerPart); 
+        }
     }
     
     /**
-     * Returns a String serialisation of this XPointer.
+     * Inserts a pointer part at index of this XPointer.
      * 
-     * @return a String containing the serialisation of this XPointer
+     * @param pointerPart the Pointer Part to inserted.
+     * @param index an integer specifying the point to insert the pointer part.
+     * @throws UnsupportedOperationException() if a Shorthand Pointer is already set.
      */
-    public String toString() {
-        StringBuffer buffer = new StringBuffer();
-        Iterator parts = pointerParts.iterator();
-        while (parts.hasNext()) {
-            buffer.append(parts.next());
+    public void addPointerPart(int index, PointerPart pointerPart) {
+        if(hasShorthandPointer()) {
+            throw new UnsupportedOperationException("A Shortname Pointer already exists for this XPointer.");
         }
-        return buffer.toString();
+        if(index < 0 || index > pointerParts.size()) {
+            throw new IndexOutOfBoundsException("The index you gave is out of the bounds of the list of XPointers");
+        }
+        pointerParts.add(index, pointerPart); 
     }
     
-    /** 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.
+     * Returns the pointer parts in this XPointer.
      * 
-     * @param qname The QName containing the namespace and a prefix.
-     * @return a NCName of the prefix for the namespace.
+     * @return a PointerPart[] of type Object[] containing the pointer parts in this XPointer.
+     * @throws IllegalStateException if this XPointer has a shorthand pointer.
      */
-    public NCName getXmlNamespacePrefix(QName qname) {
-        return getXmlNamespacePrefix(qname.getNamespaceURI());
+    public Object[] getPointerParts() {
+        if (hasPointerParts()) {
+            int size = pointerParts.size();
+            Object[] parts = new Object[size]; //Ugly but it will have to do for Java 1.4
+            for(int i=0; i<size; i++) {
+                parts[i] = pointerParts.get(i);
+            }
+            return parts;
+        } else {
+            throw new IllegalStateException("This XPointer has a shorthand pointer.");
+        }
     }
-
+    
     /**
-     * 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.
+     * Sets the Shorthand Pointer of this XPointer to the NCName given as an argument.
      * 
-     * @param namespace The namespace to get the prefix for.
-     * @return a NCName of the prefix for the namespace.
+     * @param shorthandPointer an NCName of the Shorthand Pointer to set.
+     * @throws UnsupportedOperationException() is a PointerPart Pointer is already set.
      */
-    public NCName getXmlNamespacePrefix(String namespace) {
-        //If its the xml namespace no prefix is needed.
-        if (namespace.equals(NS_URI_XML)) {
-            return emptyNCName;
+    public void setShorthandPointer(NCName shorthandPointer) {
+        if (hasPointerParts()) {
+            throw new UnsupportedOperationException("A PointerPart Pointer already exists for this XPointer");
         }
-        //If its the xmlns namespace you shouldn't be using it!
-        if (namespace.equals(NS_URI_XMLNS)) {
-            return emptyNCName;
+        if (shorthandPointer.equals(null)) {
+            throw new NullPointerException("The shorthandPointer argument is null");
         }
-        //Lookup prefix
-        NCName prefix = (NCName)xmlnses.get(namespace);
-        if (prefix == null) {
-            //The namespace does not have a prefix yet so lets add one.
-            //Find next available nsXXX prefix
-            prefix = new NCName("ns" + Integer.toString(xmlnses.size()+1));
-            for (int i = 1; xmlnses.containsKey(prefix); i++) {
-                prefix = new NCName("ns" + Integer.toString(xmlnses.size() + i));
-            }
-            //Add prefix pointer part.
-            pointerParts.add(xmlnses.size(), new XmlnsPart(prefix, namespace));
-            
-            //Add to Map.
-            xmlnses.put(namespace, prefix);
+        
+        this.shorthandPointer = shorthandPointer;
+    }
+    
+    /**
+     * Returns the shorthandPointer in this XPointer.
+     * 
+     * @return an NCName containing the shorthand pointer for this XPointer.
+     * @throws IllegalStateException if this XPointer has a shorthand pointer.
+     */
+    public NCName getShorthandPointer() {
+        if (hasShorthandPointer()) {
+            return shorthandPointer;
+        } else {
+            throw new IllegalStateException("This XPointer has scheme based pointers.");
         }
-        return prefix;
     }
     
     /**
-     * Returns a QName prefixed from the map of local namespaces and prefixes.
-     * The namespace and localpart remain unchanged.
+     * Adds a Prefix/Namespace binding to this XPointers contex.
+     * 
+     * @param prefix a NCName of the prefix too bind to the namespace.
+     * @param namespace a String of the namespace to bind to the prefix.
+     * @throws NullPointerException if the prefix or namespace arguments are null.
+     * @throws IllegalArgumentException if the prefix or namespace are invalid as specified at <a href="http://www.w3.org/TR/xptr-framework/#nsContext">http://www.w3.org/TR/xptr-framework/#nsContext</a>
+     */
+    public void addPrefixNamespaceBinding(NCName prefix, String namespace) {
+        if (prefix == null)
+            throw new NullPointerException("The prefix argument provided has a null pointer.");
+        if (namespace == null)
+            throw new NullPointerException("The namespace argument provided has a null pointer.");
+        if (prefix.equals(NS_PREFIX_XMLNS))
+            throw new IllegalArgumentException("The xmlns prefix must not be bound to any namespace.");
+        if (namespace.equals(NS_URI_XMLNS))
+            throw new IllegalArgumentException("The " + NS_URI_XMLNS + " namespace must not be bound to any prefix.");
+        //Its a valid binding so add it to the binding contex.
+        prefixBindingContex.put(prefix, namespace);
+        namespaceBindingContex.put(namespace, prefix);
+    }
+    
+    /**
+     * Gets the Namespace the Prefix is bound to if the binding exists,
+     * otherwise it will return null.
+     * 
+     * @param prefix a NCName of the prefix bound to the namespace.
+     * @return A String of the namespace bound to this prefix or null if none exists.
+     */
+    public String getPrefixBinding(NCName prefix) {
+        return (String)prefixBindingContex.get(prefix);
+    }
+    
+    /**
+     * Gets Prefix the Namespace is bound to if the binding exists,
+     * otherwise it will return null.
+     * 
+     * @param namespace a String of the prefix bound to the prefix.
+     * @return A NCName of the prefix bound to this namespace or null if none exists.
+     */
+    public NCName getNamespaceBinding(String namespace) {
+        return (NCName)namespaceBindingContex.get(namespace);
+    }
+    
+    /**
+     * Checks whether a prefix is bound or not.
+     * 
+     * @param prefix A NCName of the prefix to check.
+     * @return a boolean value that is true if the binding exists, or false otherwise.
+     */
+    public boolean hasPrefixBinding(NCName prefix) {
+        return prefixBindingContex.containsKey(prefix);
+    }
+    
+    /**
+     * Checks whether a namespace is bound or not.
+     * 
+     * @param namespace A String of the namespace to check.
+     * @return a boolean value that is true if the binding exists, or false otherwise.
+     */
+    public boolean hasNamespaceBinding(String namespace) {
+        return namespaceBindingContex.containsKey(namespace);
+    }
+
+    /**
+     * Tests whether this XPointer has a shorthand pointer or not.
+     * 
+     * @return a boolean which is true if this XPointer contains an shorthand pointer, false otherwise.
+     */
+    public boolean hasShorthandPointer() {
+        return !shorthandPointer.equals(emptyNCName);
+    }
+    
+    /**
+     * Tests whether this XPointer has scheme based pointers or not.
      * 
-     * @param qname the QName used to lookup the namespace and copy.
-     * @return a QName with the new prefix, but same namespace and localpart.
+     * @return a boolean which is true if this XPointer contains scheme based pointers, false otherwise.
      */
-    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());
+    public boolean hasPointerParts() {
+        return !pointerParts.isEmpty();
     }
-}
+    
+    /**
+     * Returns a String serialisation of this XPointer.
+     * 
+     * @return a String containing the serialisation of this XPointer
+     */
+    public String toString() {
+        if (shorthandPointer.equals(emptyNCName)) {
+            StringBuffer buffer = new StringBuffer();
+            Iterator parts = pointerParts.iterator();
+            while (parts.hasNext()) {
+                buffer.append(parts.next());
+            }
+            return buffer.toString();
+        } else {
+            return shorthandPointer.toString();
+        }
+    }
+    
+}
\ No newline at end of file

Added: incubator/woden/trunk/java/src/org/apache/woden/xpointer/XPointerParser.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/xpointer/XPointerParser.java?rev=574400&view=auto
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/xpointer/XPointerParser.java (added)
+++ incubator/woden/trunk/java/src/org/apache/woden/xpointer/XPointerParser.java Mon Sep 10 16:04:02 2007
@@ -0,0 +1,635 @@
+/**
+ * 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 java.util.Hashtable;
+
+import org.apache.woden.types.XMLChar;
+import org.apache.woden.types.NCName;
+
+/**
+ * This class parses a String to the XPointer Framework specification for shorthand and scheme based pointers.
+ * For scheme based pointers each know pointer part 
+ * 
+ * See the <a href="http://www.w3.org/TR/xptr-framework/">XPointer Framework Recommendation</a> for
+ * more information on the XPointer Framework, ShortHand and Scheme based Pointers.
+ * 
+ * This class based on the org.apache.xerces.xpointer.XPointerHandler class in the Apache Xerces Project
+ * for the core XPointer parsing code. It has been modified to be used inside the Woden XPointer model.
+ * 
+ * @author Dan Harvey (danharvey42@gmail.com)
+ *
+ */
+final class XPointerParser {
+
+    /**
+     * Parses a String XPointer and stores the results into the given XPointer object.
+     * 
+     * @param xpointerString
+     * @param xpointer
+     * @throws InvalidXPointerException if the XPointer being parsed contains invalid syntax.
+     */
+    public static void parseXPointer(String xpointerString, XPointer xpointer) throws InvalidXPointerException{
+        final String ELEMENT_SCHEME_NAME = "element"; // Supported schemes
+        
+        final Tokens tokens = new Tokens(); // tokens
+
+        // scan the XPointer expression
+        int length = xpointerString.length();
+        boolean success = Scanner.scanExpr(tokens, xpointerString, 0, length);
+
+        if (!success)
+            throw new InvalidXPointerException("Invalid XPointer expression", xpointerString);
+
+        while (tokens.hasMore()) {
+            int token = tokens.nextToken();
+
+            switch (token) {
+            case Tokens.XPTRTOKEN_SHORTHAND: {
+
+                // The shorthand name
+                token = tokens.nextToken();
+                String shortHandPointerName = tokens.getTokenString(token);
+
+                if (shortHandPointerName == null)
+                    throw new InvalidXPointerException("Invalid Shorthand XPointer", xpointerString);
+
+                xpointer.setShorthandPointer(new NCName(shortHandPointerName));
+                break;
+                }
+            case Tokens.XPTRTOKEN_SCHEMENAME: {
+
+                // Retrieve the local name and prefix to form the scheme name
+                token = tokens.nextToken();
+                String prefix = tokens.getTokenString(token);
+                token = tokens.nextToken();
+                String localName = tokens.getTokenString(token);
+
+                String schemeName = prefix + localName;
+
+                // The next character should be an open parenthesis
+                int openParenCount = 0;
+                int closeParenCount = 0;
+
+                token = tokens.nextToken();
+                String openParen = tokens.getTokenString(token);
+                if (openParen != "XPTRTOKEN_OPEN_PAREN") {
+
+                    // can not have more than one ShortHand Pointer
+                    if (token == Tokens.XPTRTOKEN_SHORTHAND) {
+                        throw new InvalidXPointerException("MultipleShortHandPointers", xpointerString);
+                    } else {
+                        throw new InvalidXPointerException("Invalid XPointer Expression", xpointerString);
+                    }
+                }
+                openParenCount++;
+
+                // followed by zero or more ( and  the schemeData
+                String schemeData = null;
+                while (tokens.hasMore()) {
+                    token = tokens.nextToken();
+                    schemeData = tokens.getTokenString(token);
+                    if (schemeData != "XPTRTOKEN_OPEN_PAREN") {
+                        break;
+                    }
+                    openParenCount++;
+                }
+                token = tokens.nextToken();
+                schemeData = tokens.getTokenString(token);
+
+                // followed by the same number of )
+                if (tokens.hasMore()) {
+                    token = tokens.nextToken();
+                    String closeParen = tokens.getTokenString(token);
+                    if (closeParen != "XPTRTOKEN_CLOSE_PAREN")
+                        new InvalidXPointerException("SchemeDataNotFollowedByCloseParenthesis", xpointerString);
+                } else {
+                    new InvalidXPointerException("SchemeDataNotFollowedByCloseParenthesis", xpointerString);
+                }
+                
+                closeParenCount++;
+
+                while (tokens.hasMore()) {
+                    if (tokens.getTokenString(tokens.peekToken()) != "XPTRTOKEN_OPEN_PAREN") {
+                        break;
+                    }
+                    closeParenCount++;
+                }
+
+                // check if the number of open parenthesis are equal to the number of close parenthesis
+                if (openParenCount != closeParenCount) {
+                    throw new InvalidXPointerException("UnbalancedParenthesisInXPointerExpression", xpointerString);
+                }
+
+                // Perform scheme specific parsing of the pointer part, make this more generic for any pointer part?
+                if (schemeName.equals(ELEMENT_SCHEME_NAME)) {
+                    PointerPart elementSchemePointer = ElementPointerPart.parseFromString(schemeData);
+                    xpointer.addPointerPart(elementSchemePointer);
+                } //Else an unknown scheme.
+                break;
+            }
+            default:
+                throw new InvalidXPointerException("InvalidXPointerExpression", xpointerString);
+            }
+        }
+
+    }
+
+    /**
+     * List of XPointer Framework tokens.
+     * 
+     */
+    private static class Tokens {
+
+        /**
+         * XPointer Framework tokens
+         * [1] Pointer     ::= Shorthand | SchemeBased 
+         * [2] Shorthand   ::= NCName 
+         * [3] SchemeBased ::= PointerPart (S? PointerPart)* 
+         * [4] PointerPart ::= SchemeName '(' SchemeData ')' 
+         * [5] SchemeName  ::= QName 
+         * [6] SchemeData  ::= EscapedData* 
+         * [7] EscapedData ::= NormalChar | '^(' | '^)' | '^^' | '(' SchemeData ')' 
+         * [8] NormalChar  ::= UnicodeChar - [()^] 
+         * [9] UnicodeChar ::= [#x0-#x10FFFF]
+         *  
+         */
+        private static final int XPTRTOKEN_OPEN_PAREN = 0,
+                XPTRTOKEN_CLOSE_PAREN = 1, XPTRTOKEN_SHORTHAND = 2,
+                XPTRTOKEN_SCHEMENAME = 3, XPTRTOKEN_SCHEMEDATA = 4;
+
+        // Token count
+        private static final int INITIAL_TOKEN_COUNT = 1 << 8;
+
+        private int[] fTokens = new int[INITIAL_TOKEN_COUNT];
+
+        private int fTokenCount = 0;
+
+        // Current token position
+        private int fCurrentTokenIndex;
+
+        private Hashtable fTokenNames = new Hashtable();
+
+        /**
+         * Constructor 
+         * 
+         */
+        private Tokens() {
+
+            fTokenNames.put(new Integer(XPTRTOKEN_OPEN_PAREN),
+                    "XPTRTOKEN_OPEN_PAREN");
+            fTokenNames.put(new Integer(XPTRTOKEN_CLOSE_PAREN),
+                    "XPTRTOKEN_CLOSE_PAREN");
+            fTokenNames.put(new Integer(XPTRTOKEN_SHORTHAND),
+                    "XPTRTOKEN_SHORTHAND");
+            fTokenNames.put(new Integer(XPTRTOKEN_SCHEMENAME),
+                    "XPTRTOKEN_SCHEMENAME");
+            fTokenNames.put(new Integer(XPTRTOKEN_SCHEMEDATA),
+                    "XPTRTOKEN_SCHEMEDATA");
+        }
+
+        /**
+         * Returns the token String 
+         * @param token The index of the token
+         * @return String The token string
+         */
+        private String getTokenString(int token) {
+            return (String) fTokenNames.get(new Integer(token));
+        }
+
+        /**
+         * Add the specified string as a token
+         *  
+         * @param token The token string
+         */
+        private void addToken(String tokenStr) {
+            Integer tokenInt = (Integer) fTokenNames.get(tokenStr);
+            if (tokenInt == null) {
+                tokenInt = new Integer(fTokenNames.size());
+                fTokenNames.put(tokenInt, tokenStr);
+            }
+            addToken(tokenInt.intValue());
+        }
+
+        /**
+         * Add the specified int token
+         *  
+         * @param token The int specifying the token
+         */
+        private void addToken(int token) {
+            try {
+                fTokens[fTokenCount] = token;
+            } catch (ArrayIndexOutOfBoundsException ex) {
+                int[] oldList = fTokens;
+                fTokens = new int[fTokenCount << 1];
+                System.arraycopy(oldList, 0, fTokens, 0, fTokenCount);
+                fTokens[fTokenCount] = token;
+            }
+            fTokenCount++;
+        }
+
+
+
+        /**
+         * Returns true if the {@link #getNextToken()} method
+         * returns a valid token.
+         */
+        private boolean hasMore() {
+            return fCurrentTokenIndex < fTokenCount;
+        }
+
+        /**
+         * Obtains the token at the current position, then advance
+         * the current position by one.
+         * 
+         * throws If there's no such next token, this method throws
+         * <tt>new XNIException("XPointerProcessingError");</tt>.
+         */
+        private int nextToken() {
+            if (fCurrentTokenIndex == fTokenCount) {
+                throw new IndexOutOfBoundsException("There are no more tokens to return.");
+            }
+            return fTokens[fCurrentTokenIndex++];
+        }
+
+        /**
+         * Obtains the token at the current position, without advancing
+         * the current position.
+         * 
+         * If there's no such next token, this method throws
+         * <tt>new XNIException("XPointerProcessingError");</tt>.
+         */
+        private int peekToken() {
+            if (fCurrentTokenIndex == fTokenCount) {
+                throw new IndexOutOfBoundsException("There are no more tokens to return.");
+            }
+            return fTokens[fCurrentTokenIndex];
+        }
+    }
+
+    /**
+     * The XPointer expression scanner.  Scans the XPointer framework expression.
+     * 
+     */
+    private static class Scanner {
+
+        /**
+         * 7-bit ASCII subset
+         *
+         *  0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
+         *  0,  0,  0,  0,  0,  0,  0,  0,  0, HT, LF,  0,  0, CR,  0,  0,  // 0
+         *  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 1
+         * SP,  !,  ",  #,  $,  %,  &,  ',  (,  ),  *,  +,  ,,  -,  .,  /,  // 2
+         *  0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  :,  ;,  <,  =,  >,  ?,  // 3
+         *  @,  A,  B,  C,  D,  E,  F,  G,  H,  I,  J,  K,  L,  M,  N,  O,  // 4
+         *  P,  Q,  R,  S,  T,  U,  V,  W,  X,  Y,  Z,  [,  \,  ],  ^,  _,  // 5
+         *  `,  a,  b,  c,  d,  e,  f,  g,  h,  i,  j,  k,  l,  m,  n,  o,  // 6
+         *  p,  q,  r,  s,  t,  u,  v,  w,  x,  y,  z,  {,  |,  },  ~, DEL  // 7
+         */
+        private static final byte CHARTYPE_INVALID = 0, // invalid XML character
+                CHARTYPE_OTHER = 1, // not special - one of "#%&;?\`{}~" or DEL
+                CHARTYPE_WHITESPACE = 2, // one of "\t\n\r " (0x09, 0x0A, 0x0D, 0x20)
+                CHARTYPE_CARRET = 3, // ^
+                CHARTYPE_OPEN_PAREN = 4, // '(' (0x28)
+                CHARTYPE_CLOSE_PAREN = 5, // ')' (0x29)
+                CHARTYPE_MINUS = 6, // '-' (0x2D)
+                CHARTYPE_PERIOD = 7, // '.' (0x2E)
+                CHARTYPE_SLASH = 8, // '/' (0x2F)
+                CHARTYPE_DIGIT = 9, // '0'-'9' (0x30 to 0x39)
+                CHARTYPE_COLON = 10, // ':' (0x3A)
+                CHARTYPE_EQUAL = 11, // '=' (0x3D)
+                CHARTYPE_LETTER = 12, // 'A'-'Z' or 'a'-'z' (0x41 to 0x5A and 0x61 to 0x7A)
+                CHARTYPE_UNDERSCORE = 13, // '_' (0x5F)
+                CHARTYPE_NONASCII = 14; // Non-ASCII Unicode codepoint (>= 0x80)
+
+        private static final byte[] fASCIICharMap = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2,
+                0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+                2, 1, 1, 1, 1, 1, 1, 1, 4, 5, 1, 1, 1, 6, 7, 8, 9, 9, 9, 9, 9,
+                9, 9, 9, 9, 9, 10, 1, 1, 11, 1, 1, 1, 12, 12, 12, 12, 12, 12,
+                12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+                12, 12, 12, 12, 1, 1, 1, 3, 13, 1, 12, 12, 12, 12, 12, 12, 12,
+                12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+                12, 12, 12, 1, 1, 1, 1, 1 };
+
+        /**
+         * Scans the XPointer Expression
+         * 
+         */
+        private static boolean scanExpr(Tokens tokens, String data, int currentOffset, int endOffset) throws InvalidXPointerException {
+            int ch;
+            int openParen = 0;
+            int closeParen = 0;
+            int nameOffset, dataOffset;
+            boolean isQName = false;
+            String name = null;
+            String prefix = null;
+            String schemeData = null;
+            StringBuffer schemeDataBuff = new StringBuffer();
+
+            while (true) {
+
+                if (currentOffset == endOffset) {
+                    break;
+                }
+                ch = data.charAt(currentOffset);
+
+                // 
+                while (ch == ' ' || ch == 0x0A || ch == 0x09 || ch == 0x0D) {
+                    if (++currentOffset == endOffset) {
+                        break;
+                    }
+                    ch = data.charAt(currentOffset);
+                }
+                if (currentOffset == endOffset) {
+                    break;
+                }
+
+                // 
+                // [1]    Pointer      ::=    Shorthand | SchemeBased  
+                // [2]    Shorthand    ::=    NCName  
+                // [3]    SchemeBased  ::=    PointerPart (S? PointerPart)* 
+                // [4]    PointerPart  ::=    SchemeName '(' SchemeData ')' 
+                // [5]    SchemeName   ::=    QName  
+                // [6]    SchemeData   ::=    EscapedData*  
+                // [7]    EscapedData  ::=    NormalChar | '^(' | '^)' | '^^' | '(' SchemeData ')'  
+                // [8]    NormalChar   ::=    UnicodeChar - [()^]  
+                // [9]    UnicodeChar  ::=    [#x0-#x10FFFF]
+                // [?]    QName        ::=    (NCName ':')? NCName
+                // [?]    NCName       ::=    (Letter | '_') (NCNameChar)*
+                // [?]    NCNameChar   ::=    Letter | Digit | '.' | '-' | '_'  (ascii subset of 'NCNameChar')
+                // [?]    Letter       ::=    [A-Za-z]                              (ascii subset of 'Letter')
+                // [?]    Digit        ::=    [0-9]                                  (ascii subset of 'Digit')
+                // 
+                byte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
+                        : fASCIICharMap[ch];
+
+                switch (chartype) {
+
+                case CHARTYPE_OPEN_PAREN: // '('
+                    addToken(tokens, Tokens.XPTRTOKEN_OPEN_PAREN);
+                    openParen++;
+                    ++currentOffset;
+                    break;
+
+                case CHARTYPE_CLOSE_PAREN: // ')'
+                    addToken(tokens, Tokens.XPTRTOKEN_CLOSE_PAREN);
+                    closeParen++;
+                    ++currentOffset;
+                    break;
+
+                case CHARTYPE_CARRET:
+                case CHARTYPE_COLON:
+                case CHARTYPE_DIGIT:
+                case CHARTYPE_EQUAL:
+                case CHARTYPE_LETTER:
+                case CHARTYPE_MINUS:
+                case CHARTYPE_NONASCII:
+                case CHARTYPE_OTHER:
+                case CHARTYPE_PERIOD:
+                case CHARTYPE_SLASH:
+                case CHARTYPE_UNDERSCORE:
+                case CHARTYPE_WHITESPACE:
+                    // Scanning SchemeName | Shorthand                   
+                    if (openParen == 0) {
+                        nameOffset = currentOffset;
+                        currentOffset = scanNCName(data, endOffset,
+                                currentOffset);
+
+                        if (currentOffset == nameOffset)
+                            throw new InvalidXPointerException("InvalidShortHandPointer", data);
+
+                        if (currentOffset < endOffset) {
+                            ch = data.charAt(currentOffset);
+                        } else {
+                            ch = -1;
+                        }
+
+                        name = data.substring(nameOffset, currentOffset).intern();
+                        prefix = "".intern();
+
+                        // The name is a QName => a SchemeName
+                        if (ch == ':') {
+                            if (++currentOffset == endOffset) {
+                                return false;
+                            }
+
+                            ch = data.charAt(currentOffset);
+                            prefix = name;
+                            nameOffset = currentOffset;
+                            currentOffset = scanNCName(data, endOffset,
+                                    currentOffset);
+
+                            if (currentOffset == nameOffset) {
+                                return false;
+                            }
+
+                            if (currentOffset < endOffset) {
+                                ch = data.charAt(currentOffset);
+                            } else {
+                                ch = -1;
+                            }
+
+                            isQName = true;
+                            name = data.substring(nameOffset, currentOffset).intern();
+                        }
+
+                        // REVISIT:
+                        if (currentOffset != endOffset) {
+                            addToken(tokens, Tokens.XPTRTOKEN_SCHEMENAME);
+                            tokens.addToken(prefix);
+                            tokens.addToken(name);
+                            isQName = false;
+                        } else if (currentOffset == endOffset) {
+                            // NCName => Shorthand
+                            addToken(tokens, Tokens.XPTRTOKEN_SHORTHAND);
+                            tokens.addToken(name);
+                            isQName = false;
+                        }
+
+                        // reset open/close paren for the next pointer part
+                        closeParen = 0;
+
+                        break;
+
+                    } else if (openParen > 0 && closeParen == 0 && name != null) {
+                        // Scanning SchemeData
+                        dataOffset = currentOffset;
+                        currentOffset = scanData(data, schemeDataBuff,
+                                endOffset, currentOffset);
+
+                        if (currentOffset == dataOffset)
+                            throw new InvalidXPointerException("InvalidSchemeDataInXPointer", data);
+
+                        if (currentOffset < endOffset) {
+                            ch = data.charAt(currentOffset);
+                        } else {
+                            ch = -1;
+                        }
+
+                        schemeData = schemeDataBuff.toString().intern();
+                        addToken(tokens, Tokens.XPTRTOKEN_SCHEMEDATA);
+                        tokens.addToken(schemeData);
+
+                        // reset open/close paren for the next pointer part
+                        openParen = 0;
+                        schemeDataBuff.delete(0, schemeDataBuff.length());
+
+                    } else {
+                        // ex. schemeName()
+                        // Should we throw an exception with a more suitable message instead??
+                        return false;
+                    }
+                }
+            } // end while
+            return true;
+        }
+
+        /** 
+         * Scans a NCName.  
+         * From Namespaces in XML 
+         * [5] NCName ::= (Letter | '_') (NCNameChar)*
+         * [6] NCNameChar ::= Letter | Digit | '.' | '-' | '_' | CombiningChar | Extender
+         * 
+         * @param data A String containing the XPointer expression
+         * @param endOffset The int XPointer expression length  
+         * @param currentOffset An int representing the current position of the XPointer expression pointer
+         */
+        private static int scanNCName(String data, int endOffset, int currentOffset) {
+            int ch = data.charAt(currentOffset);
+            if (ch >= 0x80) {
+                if (!XMLChar.isNameStart(ch)) {
+                    return currentOffset;
+                }
+            } else {
+                byte chartype = fASCIICharMap[ch];
+                if (chartype != CHARTYPE_LETTER
+                        && chartype != CHARTYPE_UNDERSCORE) {
+                    return currentOffset;
+                }
+            }
+
+            //while (currentOffset++ < endOffset) {
+            while (++currentOffset < endOffset) {
+                ch = data.charAt(currentOffset);
+                if (ch >= 0x80) {
+                    if (!XMLChar.isName(ch)) {
+                        break;
+                    }
+                } else {
+                    byte chartype = fASCIICharMap[ch];
+                    if (chartype != CHARTYPE_LETTER
+                            && chartype != CHARTYPE_DIGIT
+                            && chartype != CHARTYPE_PERIOD
+                            && chartype != CHARTYPE_MINUS
+                            && chartype != CHARTYPE_UNDERSCORE) {
+                        break;
+                    }
+                }
+            }
+            return currentOffset;
+        }
+
+        /**
+         * Scans the SchemeData.
+         * [6]    SchemeData   ::=    EscapedData*  
+         * [7]    EscapedData  ::=    NormalChar | '^(' | '^)' | '^^' | '(' SchemeData ')'  
+         * [8]    NormalChar   ::=    UnicodeChar - [()^]  
+         * [9]    UnicodeChar  ::=    [#x0-#x10FFFF]
+         * 
+         */
+        private static int scanData(String data, StringBuffer schemeData,
+                int endOffset, int currentOffset) {
+            while (true) {
+
+                if (currentOffset == endOffset) {
+                    break;
+                }
+
+                int ch = data.charAt(currentOffset);
+                byte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
+                        : fASCIICharMap[ch];
+
+                if (chartype == CHARTYPE_OPEN_PAREN) {
+                    schemeData.append(ch);
+                    //schemeData.append(Tokens.XPTRTOKEN_OPEN_PAREN);
+                    currentOffset = scanData(data, schemeData, endOffset,
+                            ++currentOffset);
+                    if (currentOffset == endOffset) {
+                        return currentOffset;
+                    }
+
+                    ch = data.charAt(currentOffset);
+                    chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
+                            : fASCIICharMap[ch];
+
+                    if (chartype != CHARTYPE_CLOSE_PAREN) {
+                        return endOffset;
+                    }
+                    schemeData.append((char) ch);
+                    ++currentOffset;//
+
+                } else if (chartype == CHARTYPE_CLOSE_PAREN) {
+                    return currentOffset;
+                    
+                } else  if (chartype == CHARTYPE_CARRET) {
+                    ch = data.charAt(++currentOffset);
+                    chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
+                            : fASCIICharMap[ch];
+
+                    if (chartype != CHARTYPE_CARRET
+                            && chartype != CHARTYPE_OPEN_PAREN
+                            && chartype != CHARTYPE_CLOSE_PAREN) {
+                        break;
+                    }
+                    schemeData.append((char) ch);
+                    ++currentOffset;
+
+                } else {
+                    schemeData.append((char) ch);
+                    ++currentOffset;//
+                }
+            }
+
+            return currentOffset;
+        }
+
+        //
+        // Protected methods
+        //
+
+        /**
+         * This method adds the specified token to the token list. By
+         * default, this method allows all tokens. However, subclasses
+         * of the XPathExprScanner can override this method in order
+         * to disallow certain tokens from being used in the scanned
+         * XPath expression. This is a convenient way of allowing only
+         * a subset of XPath.
+         */
+        protected static void addToken(Tokens tokens, int token) {
+            if (token == Tokens.XPTRTOKEN_OPEN_PAREN
+                || token == Tokens.XPTRTOKEN_CLOSE_PAREN
+                || token == Tokens.XPTRTOKEN_SCHEMENAME
+                || token == Tokens.XPTRTOKEN_SCHEMEDATA
+                || token == Tokens.XPTRTOKEN_SHORTHAND) {
+            tokens.addToken(token);
+            return;
+            }
+            throw new IllegalArgumentException("InvalidXPointerToken");
+        }
+
+    } // class Scanner
+}

Propchange: incubator/woden/trunk/java/src/org/apache/woden/xpointer/XPointerParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: incubator/woden/trunk/java/src/org/apache/woden/xpointer/XmlnsPointerPart.java (from r573600, incubator/woden/trunk/java/src/org/apache/woden/xpointer/XmlnsPart.java)
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/xpointer/XmlnsPointerPart.java?p2=incubator/woden/trunk/java/src/org/apache/woden/xpointer/XmlnsPointerPart.java&p1=incubator/woden/trunk/java/src/org/apache/woden/xpointer/XmlnsPart.java&r1=573600&r2=574400&rev=574400&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/xpointer/XmlnsPart.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/xpointer/XmlnsPointerPart.java Mon Sep 10 16:04:02 2007
@@ -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.
@@ -26,11 +26,11 @@
  *
  * @author Dan Harvey (danharvey42@gmail.com)
  */
-public class XmlnsPart implements PointerPart {
+public class XmlnsPointerPart implements PointerPart {
     private final NCName prefix;
     private final String namespace;
 
-    public XmlnsPart(NCName prefix, String namespace) {
+    public XmlnsPointerPart(NCName prefix, String namespace) {
         if (prefix == null | namespace == null) {
             throw new IllegalArgumentException();
         }

Modified: incubator/woden/trunk/java/test/org/apache/woden/OMWSDLReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/OMWSDLReaderTest.java?rev=574400&r1=574399&r2=574400&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/OMWSDLReaderTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/OMWSDLReaderTest.java Mon Sep 10 16:04:02 2007
@@ -70,4 +70,51 @@
             e.getMessage().indexOf("WSDL501") > -1);
         }
     }
+    
+    public void testReadEmbeddedWSDLSourceFromOM() {
+        Description desc = null;
+        //Load in a WSDL 2.0 file
+        URL wsdlURL = getClass().getClassLoader().getResource("org/apache/woden/embeded.xml");
+
+        //Good Tests.
+        String[] goodFragids = new String[]{
+                //Shorthand
+                "#wsdlRoot", 
+                //element() scheme.
+                "#element(wsdlRoot)", "#element(first/1/2)", "#element(/1/1/2)", "#element(second/2)"
+                };
+
+        //Test fragids
+        for (int i=0; i< goodFragids.length; i++) {
+            try {
+               desc = omWSDLReader.readWSDL(wsdlURL.toString() + goodFragids[i]); 
+            } catch(WSDLException e) {
+               fail("Failed with unexpected exception: " + e);
+            }
+            assertNotNull("Failed to load the embedded wsdl20 description with fragid: " + goodFragids[i], desc);
+        }
+        
+        //Bad Tests - Invalid XPointer. (Can't programmatically see between bad syntax and not pointing unless we modify WSDLException)
+        String[] badFragids = new String[]{
+                //Shorthand - bad syntax.
+                "#wsdl#Root", "#wsd(Root",
+                //Shorthand - don't point.
+                "#wsdlRootElement", "#nonexistentFragment", 
+                //element() scheme. - bad syntax.
+                "#element(wsdlRoot//)", "#element(/wsdlRoot)", "#element(wsdlRoot/)", "#element(wsdl,Root/1/1/2)", "#element(second/a)", 
+                //element() scheme - don't point.
+                "#element(wsdlRoot/20)", "#element(/4/1/2)", "#element(second/3)"
+                };
+
+        //Test fragids
+        for (int i=0; i< badFragids.length; i++) {
+            try {
+               desc = omWSDLReader.readWSDL(wsdlURL.toString() + badFragids[i]); 
+            } catch(WSDLException e) {
+                assertEquals("Expected exception WSDL531 for invalid XPoitner: " + badFragids[i] + ", but got the exception: " + e, "PARSER_ERROR", e.getFaultCode());
+                continue;
+            }
+            fail("XPointer parse didn't not throw exception for invalid fragid: " + badFragids[i]);
+        }
+    }
 }

Modified: incubator/woden/trunk/java/test/org/apache/woden/WSDLReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/WSDLReaderTest.java?rev=574400&r1=574399&r2=574400&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/WSDLReaderTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/WSDLReaderTest.java Mon Sep 10 16:04:02 2007
@@ -155,4 +155,51 @@
       }
       assertNotNull("The description returned is null.", desc);
   }
+  
+  public void testReadEmbeddedWSDLSource() {
+      Description desc = null;
+      //Load in a WSDL 2.0 file
+      URL wsdlURL = getClass().getClassLoader().getResource("org/apache/woden/embeded.xml");
+
+      //Good Tests.
+      String[] goodFragids = new String[]{
+              //Shorthand
+              "#wsdlRoot", 
+              //element() scheme.
+              "#element(wsdlRoot)", "#element(first/1/2)", "#element(/1/1/2)", "#element(second/2)"
+              };
+
+      //Test fragids
+      for (int i=0; i< goodFragids.length; i++) {
+          try {
+             desc = reader.readWSDL(wsdlURL.toString() + goodFragids[i]); 
+          } catch(WSDLException e) {
+             fail("Failed with unexpected exception: " + e);
+          }
+          assertNotNull("Failed to load the embedded wsdl20 description with fragid: " + goodFragids[i], desc);
+      }
+      
+      //Bad Tests - Invalid XPointer. (Can't programmatically see between bad syntax and not pointing unless we modify WSDLException)
+      String[] badFragids = new String[]{
+              //Shorthand - bad syntax.
+              "#wsdl#Root", "#wsd(Root",
+              //Shorthand - don't point.
+              "#wsdlRootElement", "#nonexistentFragment", 
+              //element() scheme. - bad syntax.
+              "#element(wsdlRoot//)", "#element(/wsdlRoot)", "#element(wsdlRoot/)", "#element(wsdl,Root/1/1/2)", "#element(second/a)", 
+              //element() scheme - don't point.
+              "#element(wsdlRoot/20)", "#element(/4/1/2)", "#element(second/3)"
+              };
+
+      //Test fragids
+      for (int i=0; i< badFragids.length; i++) {
+          try {
+             desc = reader.readWSDL(wsdlURL.toString() + badFragids[i]); 
+          } catch(WSDLException e) {
+              assertEquals("Expected exception PARSE_ERROR for invalid XPoitner: " + badFragids[i] + ", but got the exception: " + e, "PARSER_ERROR", e.getFaultCode());
+              continue;
+          }
+          fail("XPointer parse didn't not throw exception for invalid fragid: " + badFragids[i]);
+      }
+  }
 }

Added: incubator/woden/trunk/java/test/org/apache/woden/embeded.xml
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/embeded.xml?rev=574400&view=auto
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/embeded.xml (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/embeded.xml Mon Sep 10 16:04:02 2007
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ !
+ ! 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.
+ !-->
+<root xml:id="first" name="first">
+    <anotherNode xml:id="second">
+        <finalNode xml:id="third" />
+       <description 
+           xml:id="wsdlRoot"
+           xmlns="http://www.w3.org/ns/wsdl"
+           targetNamespace= "http://greath.example.com/2004/wsdl/resSvc" 
+           xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc"
+           xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc"
+           xmlns:wsoap= "http://www.w3.org/ns/wsdl/soap"
+           xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
+           xmlns:wsdlx= "http://www.w3.org/ns/wsdl-extensions">
+       
+         <documentation>
+           This document describes the GreatH Web service.  Additional 
+           application-level requirements for use of this service -- 
+           beyond what WSDL 2.0 is able to describe -- are available 
+           at http://greath.example.com/2004/reservation-documentation.html
+         </documentation>
+       
+         <types>
+           <xs:schema 
+               targetNamespace="http://greath.example.com/2004/schemas/resSvc"
+               xmlns="http://greath.example.com/2004/schemas/resSvc"
+               xmlns:xs="http://www.w3.org/2001/XMLSchema">
+       
+             <xs:element name="checkAvailability" type="tCheckAvailability"/>    
+             <xs:complexType name="tCheckAvailability">     
+               <xs:sequence>      
+                 <xs:element  name="checkInDate" type="xs:date"/>      
+                 <xs:element  name="checkOutDate" type="xs:date"/>      
+                 <xs:element  name="roomType" type="xs:string"/>      
+               </xs:sequence>     
+             </xs:complexType>   
+                   
+             <xs:element name="checkAvailabilityResponse" type="xs:double"/>    
+           
+             <xs:element name="invalidDataError" type="xs:string"/>    
+       
+           </xs:schema>    
+         </types>
+         
+         <interface  name = "reservationInterface" >
+       
+           <fault name = "invalidDataFault"
+                   element = "ghns:invalidDataError"/> 
+          
+           <operation name="opCheckAvailability" 
+                   pattern="http://www.w3.org/ns/wsdl/in-out" 
+                   style="http://www.w3.org/ns/wsdl/style/iri"
+                   wsdlx:safe = "true">
+               <input messageLabel="In" 
+                     element="ghns:checkAvailability" />
+               <output messageLabel="Out" 
+                     element="ghns:checkAvailabilityResponse" />
+               <outfault ref="tns:invalidDataFault" messageLabel="Out"/>
+           </operation>
+       
+         </interface>
+       
+         <binding name="reservationSOAPBinding" 
+                 interface="tns:reservationInterface"
+                 type="http://www.w3.org/ns/wsdl/soap" 
+                 wsoap:version="1.2"
+                 wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">
+        
+           <fault ref="tns:invalidDataFault" 
+             wsoap:code="soap:Sender"/>
+       
+           <operation ref="tns:opCheckAvailability" wsoap:mep="http://www.w3.org/2003/05/soap/mep/soap-response">
+               <input />
+               <output />
+               <outfault ref="tns:invalidDataFault" />
+           </operation>
+       
+         </binding>
+       
+         <service name="reservationService" 
+              interface="tns:reservationInterface">
+       
+            <endpoint name="reservationEndpoint" 
+                      binding="tns:reservationSOAPBinding"
+                      address ="http://greath.example.com/2004/reservation"/>
+               
+         </service>
+       
+       </description>
+   </anotherNode>
+</root>

Propchange: incubator/woden/trunk/java/test/org/apache/woden/embeded.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java?rev=574400&r1=574399&r2=574400&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java Mon Sep 10 16:04:02 2007
@@ -75,6 +75,7 @@
 import org.apache.woden.wsdl20.xml.TypesElementTest;
 import org.apache.woden.xml.IntOrTokenAttrTest;
 import org.apache.woden.xml.TokenAttrTest;
+import org.apache.woden.xpointer.XPointerTest;
 
 import testcase.extensions.foo.FooBindingExtensionsTest;
 
@@ -159,6 +160,7 @@
     addTest(FragmentIdentificationTest.suite());    
     addTest(ExtensionRegistryTest.suite());
     addTest(FooBindingExtensionsTest.suite());
+    addTest(XPointerTest.suite());
     //TODO in-progress 30May06 tests for BindingOpExt and BindingMsgRefExt
   }
 

Modified: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/fragids/FragmentIdentificationTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/fragids/FragmentIdentificationTest.java?rev=574400&r1=574399&r2=574400&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/fragids/FragmentIdentificationTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/fragids/FragmentIdentificationTest.java Mon Sep 10 16:04:02 2007
@@ -1,5 +1,3 @@
-package org.apache.woden.wsdl20.fragids;
-
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -16,6 +14,8 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License.
  */
+package org.apache.woden.wsdl20.fragids;
+
 import java.net.URL;
 
 import org.apache.woden.WSDLFactory;
@@ -115,6 +115,6 @@
         assertEquals("wsdl.endpoint(reservationService/reservationEndpoint)",
                 desc.getService(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationService")).getEndpoints()[0].toString());
         
-        //TODO add tests for BindingMessageReference, BindingFaultReference, Extensions.
+        //TODO add tests for Extensions.
     }
 }

Added: incubator/woden/trunk/java/test/org/apache/woden/xpointer/XPointerTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/xpointer/XPointerTest.java?rev=574400&view=auto
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/xpointer/XPointerTest.java (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/xpointer/XPointerTest.java Mon Sep 10 16:04:02 2007
@@ -0,0 +1,80 @@
+/**
+ * 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 junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class XPointerTest extends TestCase {
+
+    
+    public static Test suite()
+    {
+        return new TestSuite(XPointerTest.class);
+    }
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+    
+    public void testXPointerString() {
+        XPointer xpointer;
+        //Good Tests.
+        String[] goodXPointers = new String[]{
+                //Shorthand
+                "justaShorthandPointer", 
+                //element() scheme.
+                "element(AnNCName)", "element(AnNCName/1)", "element(AnNCName/1/2/34)", "element(/1)", "element(/1/4/43)"
+                };
+
+        //Test XPointers
+        for (int i=0; i< goodXPointers.length; i++) {
+            try {
+                xpointer = new XPointer(goodXPointers[i]);
+                String result = xpointer.toString();
+                assertEquals("The serialisation of XPointer: " + goodXPointers[i] + ", produced a different result: " + result, goodXPointers[i], result);
+            } catch(InvalidXPointerException e) {
+                fail("XPointer: " + goodXPointers[i] + ", is reported as being invalid when it actually is valid.");
+            } catch(Exception e) {
+                fail("Failed with unexpected exception: " + e);
+            }
+        }
+        
+        //Bad Tests.
+        String[] badXPointers = new String[]{
+                //Shorthand
+                "justaShorthand##Pointer", 
+                //element() scheme.
+                "", "element(/)", "element(//)", "element(/1/2/3//)", "element(/1/b/3)", "element(Not!AnNCNa-me)",
+                "element(/ncname)", "element(AnNCName/)", "element(AnNCName//)", "element(AnNCName/1/b)", "element(AnNCName/1/2//)"
+                };
+
+        //Test XPointers
+        for (int i=0; i< badXPointers.length; i++) {
+            try {
+                xpointer = new XPointer(badXPointers[i]);
+                fail("XPointer parser failed to thrown an exception for invalid XPointer: " + badXPointers[i]);
+            } catch(Exception e) { //See if exception is anything other than InvalidXPointerException which we want.
+                if (!(e instanceof InvalidXPointerException)) {
+                    fail("Parsing the XPointer threw an unexpected exception: " + e + ", On XPointer: " + badXPointers[i]);
+                }
+            }
+        }
+    }
+
+}

Propchange: incubator/woden/trunk/java/test/org/apache/woden/xpointer/XPointerTest.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