Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcsalter2005-11-20 00:35:29 +0000
committercsalter2005-11-20 00:35:29 +0000
commitd971729e1ec06a473be4b077ecbca0b21cf17520 (patch)
tree53c77244c511a91b400ae8f6422f6b855b7d5862
parentc040dc54a41a25b2d69976e2890c668ea891d9fd (diff)
downloadwebtools.sourceediting-d971729e1ec06a473be4b077ecbca0b21cf17520.tar.gz
webtools.sourceediting-d971729e1ec06a473be4b077ecbca0b21cf17520.tar.xz
webtools.sourceediting-d971729e1ec06a473be4b077ecbca0b21cf17520.zip
[113537] bug fixes to make physical resolution occur at the right places (where streams are opened)
-rw-r--r--bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDParser.java32
-rw-r--r--bundles/org.eclipse.wst.dtd.core/src-validation/org/eclipse/wst/dtd/core/internal/validation/Validator.java23
2 files changed, 27 insertions, 28 deletions
diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDParser.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDParser.java
index fee3129bfa..7d02d85ef2 100644
--- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDParser.java
+++ b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDParser.java
@@ -25,6 +25,7 @@ import javax.xml.parsers.SAXParserFactory;
import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
+import org.eclipse.wst.xml.core.internal.validation.core.LazyURLInputStream;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.ErrorHandler;
@@ -110,18 +111,20 @@ public class DTDParser extends DefaultHandler implements ContentHandler, DTDHand
}
/* Prints the output from the SAX callbacks. */
- public void parse(String uri) {
- try {
- boolean isReadable = URIHelper.isReadableURI(uri, true);
+ public void parse(String logicalURI) {
+ try {
+ // CS ensure that the physical URI is considered where streams are required
+ // and the logicalURI is used as the DTD's baseLocation
+ String physicalURI = URIResolverPlugin.createResolver().resolvePhysicalLocation("", "", logicalURI);
+ boolean isReadable = URIHelper.isReadableURI(physicalURI, true);
if (!isReadable) {
- throw new Exception("DTD parse error. Can not read the specified URI : " + uri); //$NON-NLS-1$
- }
-
- String document = "<!DOCTYPE root SYSTEM \"" + uri + "\"><root/>"; //$NON-NLS-1$ //$NON-NLS-2$
+ throw new Exception("DTD parse error. Can not read the specified URI : " + logicalURI); //$NON-NLS-1$
+ }
+ String document = "<!DOCTYPE root SYSTEM \"" + physicalURI + "\"><root/>"; //$NON-NLS-1$ //$NON-NLS-2$
entityDepth = 0;
- currentDTD = new DTD(uri);
+ currentDTD = new DTD(logicalURI);
InputSource inputSource = new InputSource(new StringReader(document));
- inputSource.setSystemId(uri + ".xml"); //$NON-NLS-1$
+ inputSource.setSystemId(logicalURI + ".xml"); //$NON-NLS-1$
reader.parse(inputSource);
}
catch (SAXParseException se) {
@@ -654,11 +657,12 @@ public class DTDParser extends DefaultHandler implements ContentHandler, DTDHand
public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
InputSource result = null;
URIResolver idResolver = URIResolverPlugin.createResolver();
- String uri = idResolver.resolve(currentDTD.getName(), publicId, systemId);
- if(uri == null){
- uri = systemId;
- }
- result = new InputSource(uri);
+ String logicalURI = idResolver.resolve(currentDTD.getName(), publicId, systemId);
+ // bug 113537, ensure physical resolution gets done here
+ // right before we attempt to open a stream
+ String physicalURI = idResolver.resolvePhysicalLocation(currentDTD.getName(), publicId, logicalURI);
+ result = new InputSource(logicalURI);
+ result.setByteStream(new LazyURLInputStream(physicalURI));
return result;
}
diff --git a/bundles/org.eclipse.wst.dtd.core/src-validation/org/eclipse/wst/dtd/core/internal/validation/Validator.java b/bundles/org.eclipse.wst.dtd.core/src-validation/org/eclipse/wst/dtd/core/internal/validation/Validator.java
index 51fea6d9b7..289b46c96f 100644
--- a/bundles/org.eclipse.wst.dtd.core/src-validation/org/eclipse/wst/dtd/core/internal/validation/Validator.java
+++ b/bundles/org.eclipse.wst.dtd.core/src-validation/org/eclipse/wst/dtd/core/internal/validation/Validator.java
@@ -13,19 +13,20 @@ package org.eclipse.wst.dtd.core.internal.validation;
import java.io.IOException;
import java.io.StringReader;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
import java.util.StringTokenizer;
+
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
+
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
+import org.eclipse.wst.xml.core.internal.validation.core.LazyURLInputStream;
import org.eclipse.wst.xml.core.internal.validation.core.ValidationInfo;
import org.eclipse.wst.xml.core.internal.validation.core.ValidationReport;
import org.xml.sax.ContentHandler;
@@ -95,18 +96,12 @@ public class Validator {
InputSource is = null;
if (location != null && !location.equals("")) //$NON-NLS-1$
{
- try {
- String physical = fURIResolver.resolvePhysicalLocation(fBaseLocation, publicId, location);
- URL url = new URL(physical);
- is = new InputSource(location);
- is.setByteStream(url.openStream());
- }
- catch (MalformedURLException e) {
- throw new IOException(e.getMessage());
- }
- catch (Exception e)
- {
- }
+ // CS : while working on bug 113537 I noticed we're not using the LazyURLInputStream
+ // so fixed this to avoid leaking file handles
+ //
+ String physical = fURIResolver.resolvePhysicalLocation(fBaseLocation, publicId, location);
+ is = new InputSource(location);
+ is.setByteStream(new LazyURLInputStream(physical));
}
return is;
}

Back to the top