View | Details | Raw Unified | Return to bug 8031
Collapse All | Expand All

(-)src/main/org/apache/tools/ant/AntClassLoader.java (-2 / +5 lines)
Lines 69-74 Link Here
69
import java.util.zip.ZipEntry;
69
import java.util.zip.ZipEntry;
70
import java.util.zip.ZipFile;
70
import java.util.zip.ZipFile;
71
import org.apache.tools.ant.types.Path;
71
import org.apache.tools.ant.types.Path;
72
import org.apache.tools.ant.util.FileUtils;
72
import org.apache.tools.ant.util.JavaEnvUtils;
73
import org.apache.tools.ant.util.JavaEnvUtils;
73
import org.apache.tools.ant.util.LoaderUtils;
74
import org.apache.tools.ant.util.LoaderUtils;
74
75
Lines 929-936 Link Here
929
930
930
                if (resource.exists()) {
931
                if (resource.exists()) {
931
                    try {
932
                    try {
932
                        return new URL("file:" + resource.toString());
933
                        return new URL(FileUtils.newFileUtils().toURI(resource.getAbsolutePath()));
933
                    } catch (MalformedURLException ex) {
934
                    } catch (MalformedURLException ex) {
935
                        ex.printStackTrace(); // not expected
934
                        return null;
936
                        return null;
935
                    }
937
                    }
936
                }
938
                }
Lines 944-952 Link Here
944
                ZipEntry entry = zipFile.getEntry(resourceName);
946
                ZipEntry entry = zipFile.getEntry(resourceName);
945
                if (entry != null) {
947
                if (entry != null) {
946
                    try {
948
                    try {
947
                        return new URL("jar:file:" + file.toString()
949
                        return new URL("jar:" + FileUtils.newFileUtils().toURI(file.getAbsolutePath())
948
                            + "!/" + entry);
950
                            + "!/" + entry);
949
                    } catch (MalformedURLException ex) {
951
                    } catch (MalformedURLException ex) {
952
                        ex.printStackTrace(); // not expected
950
                        return null;
953
                        return null;
951
                    }
954
                    }
952
                }
955
                }
(-)src/main/org/apache/tools/ant/launch/Locator.java (-2 / +39 lines)
Lines 124-139 Link Here
124
    /**
124
    /**
125
     * Constructs a file path from a <code>file:</code> URI.
125
     * Constructs a file path from a <code>file:</code> URI.
126
     *
126
     *
127
     * <p>Will be an absolute path if the given URI is absolute.</p>
127
     * <p>Will be an absolute path if the given URI is absolute (required on Java 1.4).</p>
128
     *
128
     *
129
     * <p>Swallows '%' that are not followed by two characters,
129
     * <p>Prior to Java 1.4, swallows '%' that are not followed by two characters,
130
     * doesn't deal with non-ASCII characters.</p>
130
     * doesn't deal with non-ASCII characters.</p>
131
     *
131
     *
132
     * @param uri the URI designating a file in the local filesystem.
132
     * @param uri the URI designating a file in the local filesystem.
133
     * @return the local file system path for the file.
133
     * @return the local file system path for the file.
134
     * @throws IllegalArgumentException if the URI is malformed or not a legal file: URL
134
     * @since Ant 1.6
135
     * @since Ant 1.6
135
     */
136
     */
136
    public static String fromURI(String uri) {
137
    public static String fromURI(String uri) {
138
139
        // #8031: first try Java 1.4.
140
        Class uriClazz = null;
141
        try {
142
            uriClazz = Class.forName("java.net.URI");
143
        } catch (ClassNotFoundException cnfe) {
144
            // Fine, Java 1.3 or earlier, do it by hand.
145
        }
146
        // Also check for properly formed URIs. Ant formerly recommended using
147
        // nonsense URIs such as "file:./foo.xml" in XML includes. You shouldn't
148
        // do that (just "foo.xml" is correct) but for compatibility we special-case
149
        // things when the path is not absolute, and fall back to the old parsing behavior.
150
        if (uriClazz != null && uri.startsWith("file:/")) {
151
            try {
152
                java.lang.reflect.Method createMethod = uriClazz.getMethod("create", new Class[] {String.class});
153
                Object uriObj = createMethod.invoke(null, new Object[] {uri});
154
                java.lang.reflect.Constructor fileConst = File.class.getConstructor(new Class[] {uriClazz});
155
                File f = (File)fileConst.newInstance(new Object[] {uriObj});
156
                return f.getAbsolutePath();
157
            } catch (java.lang.reflect.InvocationTargetException e) {
158
                Throwable e2 = e.getTargetException();
159
                if (e2 instanceof IllegalArgumentException) {
160
                    // Bad URI, pass this on.
161
                    throw (IllegalArgumentException)e2;
162
                } else {
163
                    // Unexpected target exception? Should not happen.
164
                    e2.printStackTrace();
165
                }
166
            } catch (Exception e) {
167
                // Reflection problems? Should not happen, debug.
168
                e.printStackTrace();
169
            }
170
        }
171
        
172
        // Fallback method for Java 1.3 or earlier.
173
137
        if (!uri.startsWith("file:")) {
174
        if (!uri.startsWith("file:")) {
138
            throw new IllegalArgumentException("Can only handle file: URIs");
175
            throw new IllegalArgumentException("Can only handle file: URIs");
139
        }
176
        }
(-)src/main/org/apache/tools/ant/loader/AntClassLoader2.java (-1 / +1 lines)
Lines 243-249 Link Here
243
243
244
        if (sealedString != null && sealedString.equalsIgnoreCase("true")) {
244
        if (sealedString != null && sealedString.equalsIgnoreCase("true")) {
245
            try {
245
            try {
246
                sealBase = new URL("file:" + container.getPath());
246
                sealBase = new URL(FileUtils.newFileUtils().toURI(container.getAbsolutePath()));
247
            } catch (MalformedURLException e) {
247
            } catch (MalformedURLException e) {
248
                // ignore
248
                // ignore
249
            }
249
            }
(-)src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java (-11 / +1 lines)
Lines 1-7 Link Here
1
/*
1
/*
2
 * The Apache Software License, Version 1.1
2
 * The Apache Software License, Version 1.1
3
 *
3
 *
4
 * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
4
 * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
5
 * reserved.
5
 * reserved.
6
 *
6
 *
7
 * Redistribution and use in source and binary forms, with or without
7
 * Redistribution and use in source and binary forms, with or without
Lines 65-80 Link Here
65
 * @since Ant 1.1
65
 * @since Ant 1.1
66
 */
66
 */
67
public interface XSLTLiaison {
67
public interface XSLTLiaison {
68
69
    /**
70
     * the file protocol prefix for systemid.
71
     * This file protocol must be appended to an absolute path.
72
     * Typically: <tt>FILE_PROTOCOL_PREFIX + file.getAbsolutePath()</tt>
73
     * Note that on Windows, an extra '/' must be appended to the
74
     * protocol prefix so that there is always 3 consecutive slashes.
75
     * @since Ant 1.4
76
     */
77
    String FILE_PROTOCOL_PREFIX = "file://";
78
68
79
    /**
69
    /**
80
     * set the stylesheet to use for the transformation.
70
     * set the stylesheet to use for the transformation.
(-)src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java (-2 / +3 lines)
Lines 84-89 Link Here
84
import org.apache.tools.ant.taskdefs.XSLTLogger;
84
import org.apache.tools.ant.taskdefs.XSLTLogger;
85
import org.apache.tools.ant.taskdefs.XSLTLoggerAware;
85
import org.apache.tools.ant.taskdefs.XSLTLoggerAware;
86
import org.apache.tools.ant.types.XMLCatalog;
86
import org.apache.tools.ant.types.XMLCatalog;
87
import org.apache.tools.ant.util.FileUtils;
87
import org.apache.tools.ant.util.JAXPUtils;
88
import org.apache.tools.ant.util.JAXPUtils;
88
import org.xml.sax.EntityResolver;
89
import org.xml.sax.EntityResolver;
89
import org.xml.sax.InputSource;
90
import org.xml.sax.InputSource;
Lines 401-408 Link Here
401
            String systemid = locator.getSystemId();
402
            String systemid = locator.getSystemId();
402
            if (systemid != null) {
403
            if (systemid != null) {
403
                String url = systemid;
404
                String url = systemid;
404
                if (url.startsWith("file:///")) {
405
                if (url.startsWith("file:")) {
405
                    url = url.substring(8);
406
                    url = FileUtils.newFileUtils().fromURI(url);
406
                }
407
                }
407
                msg.append(url);
408
                msg.append(url);
408
            } else {
409
            } else {
(-)src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java (-5 / +7 lines)
Lines 70-75 Link Here
70
import org.apache.tools.ant.taskdefs.MatchingTask;
70
import org.apache.tools.ant.taskdefs.MatchingTask;
71
import org.apache.tools.ant.types.Path;
71
import org.apache.tools.ant.types.Path;
72
import org.apache.tools.ant.types.Reference;
72
import org.apache.tools.ant.types.Reference;
73
import org.apache.tools.ant.util.FileUtils;
73
import org.apache.tools.ant.util.depend.DependencyAnalyzer;
74
import org.apache.tools.ant.util.depend.DependencyAnalyzer;
74
75
75
/**
76
/**
Lines 417-430 Link Here
417
                            if (classURL != null) {
418
                            if (classURL != null) {
418
                                if (classURL.getProtocol().equals("jar")) {
419
                                if (classURL.getProtocol().equals("jar")) {
419
                                    String jarFilePath = classURL.getFile();
420
                                    String jarFilePath = classURL.getFile();
421
                                    int classMarker = jarFilePath.indexOf('!');
422
                                    jarFilePath = jarFilePath.substring(0, classMarker);
420
                                    if (jarFilePath.startsWith("file:")) {
423
                                    if (jarFilePath.startsWith("file:")) {
421
                                        int classMarker = jarFilePath.indexOf('!');
424
                                        classpathFileObject = new File(FileUtils.newFileUtils().fromURI(jarFilePath));
422
                                        jarFilePath = jarFilePath.substring(5, classMarker);
425
                                    } else {
426
                                        throw new IOException("Bizarre nested path in jar: protocol: " + jarFilePath);
423
                                    }
427
                                    }
424
                                    classpathFileObject = new File(jarFilePath);
425
                                } else if (classURL.getProtocol().equals("file")) {
428
                                } else if (classURL.getProtocol().equals("file")) {
426
                                    String classFilePath = classURL.getFile();
429
                                    classpathFileObject = new File(FileUtils.newFileUtils().fromURI(classURL.toExternalForm()));
427
                                    classpathFileObject = new File(classFilePath);
428
                                }
430
                                }
429
                                log("Class " + className
431
                                log("Class " + className
430
                                    + " depends on " + classpathFileObject
432
                                    + " depends on " + classpathFileObject
(-)src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java (-1 / +2 lines)
Lines 70-75 Link Here
70
import org.apache.tools.ant.Task;
70
import org.apache.tools.ant.Task;
71
import org.apache.tools.ant.types.FileSet;
71
import org.apache.tools.ant.types.FileSet;
72
import org.apache.tools.ant.util.DOMElementWriter;
72
import org.apache.tools.ant.util.DOMElementWriter;
73
import org.apache.tools.ant.util.FileUtils;
73
import org.apache.tools.ant.util.StringUtils;
74
import org.apache.tools.ant.util.StringUtils;
74
import org.w3c.dom.Document;
75
import org.w3c.dom.Document;
75
import org.w3c.dom.Element;
76
import org.w3c.dom.Element;
Lines 271-277 Link Here
271
                // will investigate later. It does not use the given directory but
272
                // will investigate later. It does not use the given directory but
272
                // the vm dir instead ? Works fine with crimson.
273
                // the vm dir instead ? Works fine with crimson.
273
                Document testsuiteDoc
274
                Document testsuiteDoc
274
                    = builder.parse("file:///" + files[i].getAbsolutePath());
275
                    = builder.parse(FileUtils.newFileUtils().toURI(files[i].getAbsolutePath()));
275
                Element elem = testsuiteDoc.getDocumentElement();
276
                Element elem = testsuiteDoc.getDocumentElement();
276
                // make sure that this is REALLY a testsuite.
277
                // make sure that this is REALLY a testsuite.
277
                if (TESTSUITE.equals(elem.getNodeName())) {
278
                if (TESTSUITE.equals(elem.getNodeName())) {
(-)src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java (-1 / +1 lines)
Lines 395-401 Link Here
395
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
395
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
396
                transformer.setOutputProperty(OutputKeys.METHOD, "xml");
396
                transformer.setOutputProperty(OutputKeys.METHOD, "xml");
397
                Source src = new DOMSource(doc);
397
                Source src = new DOMSource(doc);
398
                Result res = new StreamResult("file:///" + tofile.toString());
398
                Result res = new StreamResult(tofile);
399
                transformer.transform(src, res);
399
                transformer.transform(src, res);
400
            } catch (Exception e) {
400
            } catch (Exception e) {
401
                throw new BuildException("Error while performing enhanced XML "
401
                throw new BuildException("Error while performing enhanced XML "
(-)src/main/org/apache/tools/ant/taskdefs/optional/sitraka/XMLReport.java (-1 / +4 lines)
Lines 67-72 Link Here
67
import org.apache.tools.ant.taskdefs.optional.sitraka.bytecode.ClassPathLoader;
67
import org.apache.tools.ant.taskdefs.optional.sitraka.bytecode.ClassPathLoader;
68
import org.apache.tools.ant.taskdefs.optional.sitraka.bytecode.MethodInfo;
68
import org.apache.tools.ant.taskdefs.optional.sitraka.bytecode.MethodInfo;
69
import org.apache.tools.ant.taskdefs.optional.sitraka.bytecode.Utils;
69
import org.apache.tools.ant.taskdefs.optional.sitraka.bytecode.Utils;
70
import org.apache.tools.ant.util.FileUtils;
70
import org.w3c.dom.Document;
71
import org.w3c.dom.Document;
71
import org.w3c.dom.Element;
72
import org.w3c.dom.Element;
72
import org.w3c.dom.Node;
73
import org.w3c.dom.Node;
Lines 213-220 Link Here
213
        DocumentBuilder dbuilder = newBuilder();
214
        DocumentBuilder dbuilder = newBuilder();
214
        InputSource is = new InputSource(new FileInputStream(file));
215
        InputSource is = new InputSource(new FileInputStream(file));
215
        if (jprobeHome != null) {
216
        if (jprobeHome != null) {
217
            // XXX this is an abuse of setSystemId...
218
            // probably wanted to make an EntityResolver instead!
216
            File dtdDir = new File(jprobeHome, "dtd");
219
            File dtdDir = new File(jprobeHome, "dtd");
217
            is.setSystemId("file:///" + dtdDir.getAbsolutePath() + "/");
220
            is.setSystemId(FileUtils.newFileUtils().toURI(dtdDir.getAbsolutePath()) + "/");
218
        }
221
        }
219
        report = dbuilder.parse(is);
222
        report = dbuilder.parse(is);
220
        report.normalize();
223
        report.normalize();
(-)src/main/org/apache/tools/ant/util/FileUtils.java (-3 / +33 lines)
Lines 1268-1282 Link Here
1268
     * Constructs a <code>file:</code> URI that represents the
1268
     * Constructs a <code>file:</code> URI that represents the
1269
     * external form of the given pathname.
1269
     * external form of the given pathname.
1270
     *
1270
     *
1271
     * <p>Will be an absolute URI if the given path is absolute.</p>
1271
     * <p>Will be an absolute URI. If the incoming path is not
1272
     * absolute, it will be absolutized relative to Java's
1273
     * current directory, as by {@link File#getAbsolutePath}.</p>
1272
     *
1274
     *
1273
     * <p>This code doesn't handle non-ASCII characters properly.</p>
1275
     * <p>This code doesn't handle non-ASCII characters properly prior to Java 1.4.</p>
1274
     *
1276
     *
1275
     * @param path the path in the local file system
1277
     * @param path the path in the local file system
1276
     * @return the URI version of the local path.
1278
     * @return the URI version of the local path.
1277
     * @since Ant 1.6
1279
     * @since Ant 1.6
1278
     */
1280
     */
1279
    public String toURI(String path) {
1281
    public String toURI(String path) {
1282
        
1283
        // #8031: first try Java 1.4.
1284
        Class uriClazz = null;
1285
        try {
1286
            uriClazz = Class.forName("java.net.URI");
1287
        } catch (ClassNotFoundException e) {
1288
            // OK, Java 1.3.
1289
        }
1290
        if (uriClazz != null) {
1291
            try {
1292
                File f = new File(path).getAbsoluteFile();
1293
                java.lang.reflect.Method toURIMethod = File.class.getMethod("toURI", new Class[0]);
1294
                Object uriObj = toURIMethod.invoke(f, null);
1295
                return uriObj.toString();
1296
            } catch (Exception e) {
1297
                // Reflection problems? Should not happen, debug.
1298
                e.printStackTrace();
1299
            }
1300
        }
1301
        
1302
        // Fallback for Java 1.3.
1303
        
1304
        File f = new File(path);
1305
        if (!f.isAbsolute()) {
1306
            f = f.getAbsoluteFile();
1307
            path = f.getAbsolutePath();
1308
        }
1309
        
1280
        boolean isDir = (new File(path)).isDirectory();
1310
        boolean isDir = (new File(path)).isDirectory();
1281
1311
1282
        StringBuffer sb = new StringBuffer("file:");
1312
        StringBuffer sb = new StringBuffer("file:");
Lines 1291-1297 Link Here
1291
            }
1321
            }
1292
1322
1293
        } catch (BuildException e) {
1323
        } catch (BuildException e) {
1294
            // relative path
1324
            e.printStackTrace(); // relative path - should not happen
1295
        }
1325
        }
1296
1326
1297
        path = path.replace('\\', '/');
1327
        path = path.replace('\\', '/');
(-)src/testcases/org/apache/tools/ant/util/FileUtilsTest.java (-10 / +32 lines)
Lines 436-441 Link Here
436
     * test toUri
436
     * test toUri
437
     */
437
     */
438
    public void testToURI() {
438
    public void testToURI() {
439
        // Tricky because the syntax of a file: URI is platform-dependent and
440
        // not fully specified by Java.
439
        String dosRoot = null;
441
        String dosRoot = null;
440
        if (Os.isFamily("dos")) {
442
        if (Os.isFamily("dos")) {
441
            dosRoot = System.getProperty("user.dir").charAt(0) + ":/";
443
            dosRoot = System.getProperty("user.dir").charAt(0) + ":/";
Lines 445-463 Link Here
445
            dosRoot = "";
447
            dosRoot = "";
446
        }
448
        }
447
        if (Os.isFamily("dos")) {
449
        if (Os.isFamily("dos")) {
448
            assertEquals("file:///C:/foo", fu.toURI("c:\\foo"));
450
            assertEquals("file:/C:/foo", removeExtraneousAuthority(fu.toURI("c:\\foo")));
449
        }
451
        }
450
        if (Os.isFamily("netware")) {
452
        if (Os.isFamily("netware")) {
451
            assertEquals("file:///SYS:/foo", fu.toURI("sys:\\foo"));
453
            assertEquals("file:/SYS:/foo", removeExtraneousAuthority(fu.toURI("sys:\\foo")));
454
        }
455
        if (File.pathSeparatorChar == '/') {
456
            assertEquals("file:/foo", removeExtraneousAuthority(fu.toURI("/foo")));
457
            assertTrue("file: URIs must name absolute paths", fu.toURI("./foo").startsWith("file:/"));
458
            assertTrue(fu.toURI("./foo").endsWith("/foo"));
459
            assertEquals("file:/" + dosRoot + "foo%20bar", removeExtraneousAuthority(fu.toURI("/foo bar")));
460
            assertEquals("file:/" + dosRoot + "foo%23bar", removeExtraneousAuthority(fu.toURI("/foo#bar")));
461
        } else if (File.pathSeparatorChar == '\\') {
462
            assertEquals("file:/" + dosRoot + "foo", removeExtraneousAuthority(fu.toURI("\\foo")));
463
            assertTrue("file: URIs must name absolute paths", fu.toURI(".\\foo").startsWith("file:/"));
464
            assertTrue(fu.toURI(".\\foo").endsWith("/foo"));
465
            assertEquals("file:/" + dosRoot + "foo%20bar", removeExtraneousAuthority(fu.toURI("\\foo bar")));
466
            assertEquals("file:/" + dosRoot + "foo%23bar", removeExtraneousAuthority(fu.toURI("\\foo#bar")));
467
        }
468
    }
469
    
470
    /**
471
     * Authority field is unnecessary, but harmless, in file: URIs.
472
     * Java 1.4 does not produce it when using File.toURI.
473
     */
474
    private static String removeExtraneousAuthority(String uri) {
475
        String prefix = "file:///";
476
        if (uri.startsWith(prefix)) {
477
            return "file:/" + uri.substring(prefix.length());
478
        } else {
479
            return uri;
452
        }
480
        }
453
        assertEquals("file:///" + dosRoot + "foo", fu.toURI("/foo"));
454
        assertEquals("file:./foo",  fu.toURI("./foo"));
455
        assertEquals("file:///" + dosRoot + "foo", fu.toURI("\\foo"));
456
        assertEquals("file:./foo",  fu.toURI(".\\foo"));
457
        assertEquals("file:///" + dosRoot + "foo%20bar", fu.toURI("/foo bar"));
458
        assertEquals("file:///" + dosRoot + "foo%20bar", fu.toURI("\\foo bar"));
459
        assertEquals("file:///" + dosRoot + "foo%23bar", fu.toURI("/foo#bar"));
460
        assertEquals("file:///" + dosRoot + "foo%23bar", fu.toURI("\\foo#bar"));
461
    }
481
    }
462
482
463
    /**
483
    /**
Lines 471-478 Link Here
471
            assertEqualsIgnoreDriveCase("C:\\foo", fu.fromURI("file:///c:/foo"));
491
            assertEqualsIgnoreDriveCase("C:\\foo", fu.fromURI("file:///c:/foo"));
472
        }
492
        }
473
        assertEqualsIgnoreDriveCase(localize("/foo"), fu.fromURI("file:///foo"));
493
        assertEqualsIgnoreDriveCase(localize("/foo"), fu.fromURI("file:///foo"));
494
        /* Illegal URI.
474
        assertEquals("." + File.separator + "foo",
495
        assertEquals("." + File.separator + "foo",
475
                     fu.fromURI("file:./foo"));
496
                     fu.fromURI("file:./foo"));
497
         */
476
        assertEqualsIgnoreDriveCase(localize("/foo bar"), fu.fromURI("file:///foo%20bar"));
498
        assertEqualsIgnoreDriveCase(localize("/foo bar"), fu.fromURI("file:///foo%20bar"));
477
        assertEqualsIgnoreDriveCase(localize("/foo#bar"), fu.fromURI("file:///foo%23bar"));
499
        assertEqualsIgnoreDriveCase(localize("/foo#bar"), fu.fromURI("file:///foo%23bar"));
478
    }
500
    }
(-)src/testcases/org/apache/tools/ant/util/JAXPUtilsTest.java (-2 / +2 lines)
Lines 1-7 Link Here
1
/*
1
/*
2
 * The Apache Software License, Version 1.1
2
 * The Apache Software License, Version 1.1
3
 *
3
 *
4
 * Copyright (c) 2002 The Apache Software Foundation.  All rights
4
 * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
5
 * reserved.
5
 * reserved.
6
 *
6
 *
7
 * Redistribution and use in source and binary forms, with or without
7
 * Redistribution and use in source and binary forms, with or without
Lines 74-80 Link Here
74
            file = new File("/user/local/bin");
74
            file = new File("/user/local/bin");
75
        }
75
        }
76
        String systemid = JAXPUtils.getSystemId(file);
76
        String systemid = JAXPUtils.getSystemId(file);
77
        assertTrue("SystemIDs should start by file:///", systemid.startsWith("file:///"));
77
        assertTrue("SystemIDs should start by file:/", systemid.startsWith("file:/"));
78
        assertTrue("SystemIDs should not start with file:////", !systemid.startsWith("file:////"));
78
        assertTrue("SystemIDs should not start with file:////", !systemid.startsWith("file:////"));
79
    }
79
    }
80
}
80
}
(-)xdocs/faq.xml (-3 / +7 lines)
Lines 836-842 Link Here
836
<?xml version="1.0"?>
836
<?xml version="1.0"?>
837
837
838
<!DOCTYPE project [
838
<!DOCTYPE project [
839
    <!ENTITY common SYSTEM "file:./common.xml">
839
    <!ENTITY common SYSTEM "common.xml">
840
]>
840
]>
841
841
842
<project name="test" default="test" basedir=".">
842
<project name="test" default="test" basedir=".">
Lines 855-865 Link Here
855
        <p>will literally include the contents of <code>common.xml</code> where
855
        <p>will literally include the contents of <code>common.xml</code> where
856
        you&apos;ve placed the <code>&amp;common;</code> entity.</p>
856
        you&apos;ve placed the <code>&amp;common;</code> entity.</p>
857
857
858
        <p>(The filename <code>common.xml</code> in this example is resolved
859
        relative to the containing XML file by the XML parser. You may also use
860
        an absolute <code>file:</code> protocol URI.)</p>
861
858
        <p>In combination with a DTD, this would look like this:</p>
862
        <p>In combination with a DTD, this would look like this:</p>
859
863
860
        <source><![CDATA[
864
        <source><![CDATA[
861
<!DOCTYPE project PUBLIC "-//ANT//DTD project//EN" "file:./ant.dtd" [
865
<!DOCTYPE project PUBLIC "-//ANT//DTD project//EN" "ant.dtd" [
862
   <!ENTITY include SYSTEM "file:./header.xml">
866
   <!ENTITY include SYSTEM "header.xml">
863
]>
867
]>
864
]]></source>
868
]]></source>
865
869

Return to bug 8031