Project

Profile

Help

Revision 903ef4c2

Added by Michael Kay over 12 years ago

fix 2807363 resolve-uri() on .NET; plus version changes for Saxon 9.1.0.7

View differences:

latest9.1/bj/net/sf/saxon/Version.java
6 6

  
7 7
public final class Version {
8 8

  
9
    private static final int[] STRUCTURED_VERSION = {9,1,0,6};
10
    private static final String VERSION = "9.1.0.6";
11
    private static final String BUILD = "031609"; //mmddhh
12
    private static final String RELEASE_DATE = "2009-03-16";
9
    private static final int[] STRUCTURED_VERSION = {9,1,0,7};
10
    private static final String VERSION = "9.1.0.7";
11
    private static final String BUILD = "061620"; //mmddhh
12
    private static final String RELEASE_DATE = "2009-06-16";
13 13

  
14 14
    private Version() {
15 15
        // class is never instantiated
latest9.1/bj/net/sf/saxon/dotnet/DotNetPlatform.java
6 6
import cli.System.Xml.*;
7 7
import net.sf.saxon.*;
8 8
import net.sf.saxon.event.PipelineConfiguration;
9
import net.sf.saxon.functions.FunctionLibrary;
10
import net.sf.saxon.functions.FunctionLibraryList;
11
import net.sf.saxon.functions.JavaExtensionFunctionFactory;
12
import net.sf.saxon.functions.JavaExtensionLibrary;
9
import net.sf.saxon.functions.*;
13 10
import net.sf.saxon.om.NamespaceConstant;
14 11
import net.sf.saxon.om.Validation;
15 12
import net.sf.saxon.pull.PullProvider;
......
19 16
import net.sf.saxon.sort.NamedCollation;
20 17
import net.sf.saxon.sort.StringCollator;
21 18
import net.sf.saxon.trans.XPathException;
19
import net.sf.saxon.trans.Err;
22 20
import net.sf.saxon.type.SchemaType;
23 21

  
24 22
import javax.xml.transform.Source;
......
28 26
import java.io.Reader;
29 27
import java.net.URI;
30 28
import java.net.URISyntaxException;
29
import java.net.URL;
30
import java.net.MalformedURLException;
31 31
import java.util.Properties;
32 32
import java.util.StringTokenizer;
33 33

  
......
107 107
     * @throws java.net.URISyntaxException
108 108
     */
109 109

  
110
    public URI makeAbsolute(String relativeURI, String base) throws URISyntaxException {
110
    public URI makeAbsoluteOLD(String relativeURI, String base) throws URISyntaxException {
111 111

  
112 112
        // It's not entirely clear why the .NET product needs a different version of this method.
113 113
        // Possibly because of bugs in GNU classpath.
......
127 127
            else {
128 128
                fulluri = resolver.ResolveUri(null, relativeURI.replaceAll("file:", ""));
129 129
            }
130
            return new URI(fulluri.ToString());
130
            return new URI(fulluri.get_AbsoluteUri());
131 131
        } catch (cli.System.UriFormatException e) {
132 132
            throw new URISyntaxException(base + " + " + relativeURI, e.getMessage());
133 133
        }
134 134
    }
135 135

  
136
    public URI makeAbsolute(String relativeURI, String base) throws URISyntaxException {
137
            URI absoluteURI;
138
            // System.err.println("makeAbsolute " + relativeURI + " against base " + base);
139
            if (relativeURI == null) {
140
                absoluteURI = new URI(ResolveURI.escapeSpaces(base));
141
                if (!absoluteURI.isAbsolute()) {
142
                    throw new URISyntaxException(base, "Relative URI not supplied, so base URI must be absolute");
143
                } else {
144
                    return absoluteURI;
145
                }
146
            }
147
            relativeURI = ResolveURI.escapeSpaces(relativeURI);
148
            base = ResolveURI.escapeSpaces(base);
149
            try {
150
                if (base==null || base.length() == 0) {
151
                    absoluteURI = new URI(relativeURI);
152
                    if (!absoluteURI.isAbsolute()) {
153
                        String expandedBase = ResolveURI.tryToExpand(base);
154
                        if (!expandedBase.equals(base)) { // prevent infinite recursion
155
                            return makeAbsolute(relativeURI, expandedBase);
156
                        }
157
                    }
158
                } else if (base != null && (base.startsWith("jar:") || base.startsWith("file:////"))) {
159

  
160
                    // jar: URIs can't be resolved by the java.net.URI class, because they don't actually
161
                    // conform with the RFC standards for hierarchic URI schemes (quite apart from not being
162
                    // a registered URI scheme). But they seem to be widely used.
163

  
164
                    // URIs starting file://// are accepted by the java.net.URI class, they are used to
165
                    // represent Windows UNC filenames. However, the java.net.URI algorithm for resolving
166
                    // a relative URI against such a base URI fails to produce a usable UNC filename (it's not
167
                    // clear whether Java is implementing RFC 3986 correctly here, it depends on interpretation).
168
                    // So we use the java.net.URL algorithm for this case too, because it works.
169

  
170
                    try {
171
                        URL baseURL = new URL(base);
172
                        URL absoluteURL = new URL(baseURL, relativeURI);
173
                        absoluteURI = new URI(absoluteURL.toString());
174
                            // TODO: JDK1.5: use absoluteURL.toURI()
175
                    } catch (MalformedURLException err) {
176
                        throw new URISyntaxException(base + " " + relativeURI, err.getMessage());
177
                    }
178
                } else {
179
                    URI baseURI;
180
                    try {
181
                        baseURI = new URI(base);
182
                    } catch (URISyntaxException e) {
183
                        throw new URISyntaxException(base, "Invalid base URI: " + e.getMessage());
184
                    }
185
                    try {
186
                        new URI(relativeURI);   // for validation only
187
                    } catch (URISyntaxException e) {
188
                        throw new URISyntaxException(base, "Invalid relative URI: " + e.getMessage());
189
                    }
190
                    absoluteURI = (relativeURI.length()==0 ?
191
                                     baseURI :
192
                                     baseURI.resolve(relativeURI)
193
                                 );
194
                }
195
            } catch (IllegalArgumentException err0) {
196
                // can be thrown by resolve() when given a bad URI
197
                throw new URISyntaxException(relativeURI, "Cannot resolve URI against base " + Err.wrap(base));
198
            }
199

  
200
            return absoluteURI;
201
        }
202
    
203

  
136 204
    /**
137 205
     * Get the platform version
138 206
     */

Also available in: Unified diff