src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/AbstractReferenceFinderImpl.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
equal deleted inserted replaced
366:8c0b6bccfe47 368:0989ad8c0860
1 /* 1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
68 * @return 68 * @return
69 * It's OK to return a relative URL. 69 * It's OK to return a relative URL.
70 */ 70 */
71 protected abstract String findExternalResource( String nsURI, String localName, Attributes atts); 71 protected abstract String findExternalResource( String nsURI, String localName, Attributes atts);
72 72
73 @Override
73 public void startElement(String namespaceURI, String localName, String qName, Attributes atts) 74 public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
74 throws SAXException { 75 throws SAXException {
75 super.startElement(namespaceURI, localName, qName, atts); 76 super.startElement(namespaceURI, localName, qName, atts);
76 77
77 String relativeRef = findExternalResource(namespaceURI,localName,atts); 78 String relativeRef = findExternalResource(namespaceURI,localName,atts);
78 if(relativeRef==null) return; // non found 79 if(relativeRef==null) return; // non found
79 80
80 try { 81 try {
81 // absolutize URL. 82 // absolutize URL.
82 String lsi = locator.getSystemId(); 83 assert locator != null;
83 String ref; 84 String lsi = locator.getSystemId();
84 if (lsi.startsWith("jar:")) { 85 String ref;
85 int bangIdx = lsi.indexOf('!'); 86 if (lsi.startsWith("jar:")) {
86 if (bangIdx > 0) { 87 int bangIdx = lsi.indexOf('!');
87 ref = new URL(new URL(lsi), relativeRef).toString(); 88 if (bangIdx > 0) {
88 } else 89 ref = new URL(new URL(lsi), relativeRef).toString();
89 ref = relativeRef; 90 } else
90 } else 91 ref = relativeRef;
91 ref = new URI(lsi).resolve(new URI(relativeRef)).toString(); 92 } else
93 ref = new URI(lsi).resolve(new URI(relativeRef)).toString();
92 94
93 // then parse this schema as well, 95 // then parse this schema as well,
94 // but don't mark this document as a root. 96 // but don't mark this document as a root.
95 parent.parse(ref,false); 97 parent.parse(ref,false);
96 } catch( URISyntaxException e ) { 98 } catch( URISyntaxException e ) {
110 } 112 }
111 } 113 }
112 114
113 private Locator locator; 115 private Locator locator;
114 116
117 @Override
115 public void setDocumentLocator(Locator locator) { 118 public void setDocumentLocator(Locator locator) {
116 super.setDocumentLocator(locator); 119 super.setDocumentLocator(locator);
117 this.locator = locator; 120 this.locator = locator;
118 } 121 }
119 } 122 }

mercurial