src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/AbstractReferenceFinderImpl.java

Print this page

        

@@ -23,33 +23,31 @@
  * questions.
  */
 
 package com.sun.tools.internal.xjc.reader.internalizer;
 
-import java.io.IOException;
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-
 import com.sun.istack.internal.SAXParseException2;
-
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.XMLFilterImpl;
 
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
 /**
  * XMLFilter that finds references to other schema files from
  * SAX events.
- *
+ * <p/>
  * This implementation is a base implementation for typical case
  * where we just need to look for a particular attribute which
  * contains an URL to another schema file.
  *
- * @author
- *  Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
+ * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
  */
 public abstract class AbstractReferenceFinderImpl extends XMLFilterImpl {
 
     protected final DOMForest parent;
 

@@ -59,16 +57,13 @@
 
     /**
      * IF the given element contains a reference to an external resource,
      * return its URL.
      *
-     * @param nsURI
-     *      Namespace URI of the current element
-     * @param localName
-     *      Local name of the current element
-     * @return
-     *      It's OK to return a relative URL.
+     * @param nsURI     Namespace URI of the current element
+     * @param localName Local name of the current element
+     * @return It's OK to return a relative URL.
      */
     protected abstract String findExternalResource(String nsURI, String localName, Attributes atts);
 
     @Override
     public void startElement(String namespaceURI, String localName, String qName, Attributes atts)

@@ -81,10 +76,14 @@
         }
         try {
             // absolutize URL.
             String lsi = locator.getSystemId();
             String ref;
+            URI relRefURI = new URI(relativeRef);
+            if (relRefURI.isAbsolute())
+                ref = relativeRef;
+            else {
             if (lsi.startsWith("jar:")) {
                 int bangIdx = lsi.indexOf('!');
                 if (bangIdx > 0) {
                     ref = lsi.substring(0, bangIdx + 1)
                             + new URI(lsi.substring(bangIdx + 1)).resolve(new URI(relativeRef)).toString();

@@ -92,10 +91,11 @@
                     ref = relativeRef;
                 }
             } else {
                 ref = new URI(lsi).resolve(new URI(relativeRef)).toString();
             }
+            }
 
             // then parse this schema as well,
             // but don't mark this document as a root.
             if (parent != null) { // this is there to allow easier testing
                 parent.parse(ref, false);

@@ -119,13 +119,14 @@
 
             fatalError(spe);
             throw spe;
         }
     }
+
     private Locator locator;
 
     @Override
     public void setDocumentLocator(Locator locator) {
         super.setDocumentLocator(locator);
         this.locator = locator;
     }
-};
+}