[tiled] r771 - in trunk: . src/tiled/io/xml src/tiled/mapeditor/resources
tiled-svn at biggeruniverse.com
tiled-svn at biggeruniverse.com
Sat Jul 12 12:48:42 PDT 2008
Author: bjorn
Date: 2008-07-12 14:48:41 -0500 (Sat, 12 Jul 2008)
New Revision: 771
Added:
trunk/src/tiled/mapeditor/resources/map.dtd
Removed:
trunk/map.dtd
Modified:
trunk/src/tiled/io/xml/XMLMapTransformer.java
Log:
Fixed the doctype entity problem relying on internet being available
The entity is now resolved locally when recognized. Moved the DTD file back to
the resources directory since it should be included in the .jar file. It is probably
visible enough now that it is saved in each map file. The DTD is now the one
by Olivier that was also added to the website.
The question is whether other people will have similar problems with such an
entity. I also wonder why setting setExpandEntityReferences to false is not enough
to make it not resolve the entities. Probably it means something else.
Deleted: trunk/map.dtd
===================================================================
--- trunk/map.dtd 2008-07-11 18:02:11 UTC (rev 770)
+++ trunk/map.dtd 2008-07-12 19:48:41 UTC (rev 771)
@@ -1,64 +0,0 @@
-<!DOCTYPE TiledMap [
-
-<!ELEMENT map (property+, tileset*, (layer | objectgroup)*)>
-<!ATTLIST map
- id ID #IMPLIED
- orientation (orthogonal | isometric | hexagonal | oblique) #REQUIRED
- version CDATA #IMPLIED
- width CDATA #REQUIRED
- height CDATA #REQUIRED
- tilewidth CDATA #REQUIRED
- tileheight CDATA #REQUIRED
->
-
-<!ELEMENT tileset (image+ | tile+ | EMPTY)>
-<!ATTLIST tileset
- name CDATA #IMPLIED
- source CDATA #IMPLIED
- basedir CDATA #IMPLIED
- firstgid CDATA #REQUIRED
- tilewidth CDATA #IMPLIED
- tileheight CDATA #IMPLIED
->
-
-<!ELEMENT tile (image, property+)>
-<!ATTLIST tile
- id ID #REQUIRED
- source CDATA #IMPLIED
->
-
-<!ELEMENT layer (data)>
-<!ATTLIST layer
- x CDATA #IMPLIED
- y CDATA #IMPLIED
- width CDATA #IMPLIED
- height CDATA #IMPLIED
- name CDATA #IMPLIED
- visible CDATA #IMPLIED
- opacity CDATA #IMPLIED
->
-
-<!ELEMENT objectgroup (object*) >
-<!ELEMENT object (properties?)>
-
-<!ELEMENT image (data | EMPTY)>
-<!ATTLIST image
- format CDATA #IMPLIED
- source CDATA #IMPLIED
- trans CDATA #IMPLIED
->
-
-<!ELEMENT properties (property*) >
-<!ELEMENT property EMPTY>
-<!ATTLIST property
- name CDATA #REQUIRED
- value CDATA #REQUIRED
->
-
-<!ELEMENT data (#PCDATA)>
-<!ATTLIST data
- encoding CDATA #REQUIRED
- compression CDATA #IMPLIED
->
-
-]>
Modified: trunk/src/tiled/io/xml/XMLMapTransformer.java
===================================================================
--- trunk/src/tiled/io/xml/XMLMapTransformer.java 2008-07-11 18:02:11 UTC (rev 770)
+++ trunk/src/tiled/io/xml/XMLMapTransformer.java 2008-07-12 19:48:41 UTC (rev 771)
@@ -32,11 +32,13 @@
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import org.xml.sax.EntityResolver;
import tiled.core.*;
import tiled.io.ImageHelper;
import tiled.io.MapReader;
import tiled.io.PluginLogger;
import tiled.mapeditor.util.cutter.BasicTileCutter;
+import tiled.mapeditor.Resources;
import tiled.util.Base64;
import tiled.util.Util;
@@ -48,6 +50,7 @@
private Map map;
private String xmlPath;
private PluginLogger logger;
+ private final EntityResolver entityResolver = new MapEntityResolver();
public XMLMapTransformer() {
logger = new PluginLogger();
@@ -737,6 +740,7 @@
factory.setIgnoringElementContentWhitespace(true);
factory.setExpandEntityReferences(false);
DocumentBuilder builder = factory.newDocumentBuilder();
+ builder.setEntityResolver(entityResolver);
InputSource insrc = new InputSource(in);
insrc.setSystemId(xmlPath);
insrc.setEncoding("UTF8");
@@ -845,4 +849,15 @@
public void setLogger(PluginLogger logger) {
this.logger = logger;
}
+
+ private class MapEntityResolver implements EntityResolver
+ {
+ public InputSource resolveEntity(String publicId, String systemId) {
+ if (systemId.equals("http://mapeditor.org/dtd/1.0/map.dtd")) {
+ return new InputSource(Resources.class.getResourceAsStream(
+ "resources/map.dtd"));
+ }
+ return null;
+ }
+ }
}
Copied: trunk/src/tiled/mapeditor/resources/map.dtd (from rev 767, trunk/map.dtd)
===================================================================
--- trunk/src/tiled/mapeditor/resources/map.dtd (rev 0)
+++ trunk/src/tiled/mapeditor/resources/map.dtd 2008-07-12 19:48:41 UTC (rev 771)
@@ -0,0 +1,112 @@
+<?xml encoding="utf-8"?>
+
+<!--
+ format 0.7.0 by
+ Tiled Developers (mapeditor.org)
+ documented in dtd form originally by
+ Olivier.Beaton at quadir.net
+ Creative Commons Attribution 3.0
+ http://creativecommons.org/licenses/by/3.0/
+ last updated on
+ 2008-06-25
+-->
+
+<!ELEMENT map (properties?, tileset*, (layer | objectgroup)*)>
+<!ATTLIST map
+ version CDATA #REQUIRED
+ orientation (orthogonal | isometric | hexagonal | oblique) #REQUIRED
+ width CDATA #REQUIRED
+ height CDATA #REQUIRED
+ tilewidth CDATA #REQUIRED
+ tileheight CDATA #REQUIRED
+>
+
+<!ELEMENT properties (property*)>
+
+<!ELEMENT property EMPTY>
+<!ATTLIST property
+ name CDATA #REQUIRED
+ value CDATA #REQUIRED
+>
+
+<!--
+ data is required when a child of tilset
+ data is not valid when a child of tile
+-->
+<!ELEMENT image (data?)>
+<!--
+ format is required when a child of tileset
+ format is not valid when a child of tile
+ source here is required when tileset tileheight/tilewidth -> image is used and you are referencing an outside image
+-->
+<!ATTLIST image
+ format CDATA #IMPLIED
+ id CDATA #IMPLIED
+ source CDATA #IMPLIED
+ trans CDATA #IMPLIED
+>
+
+<!--
+ #PCDATA when data is child of image
+ tile* when data is child of layer without compression
+-->
+<!ELEMENT data (#PCDATA | tile)*>
+<!ATTLIST data
+ encoding CDATA #IMPLIED
+ compression CDATA #IMPLIED
+>
+
+<!ELEMENT tileset (image*, tile*)>
+<!--
+ name REQUIRED only if source tsx not present
+ source here refers to a TSX
+-->
+<!ATTLIST tileset
+ name CDATA #IMPLIED
+ firstgid CDATA #REQUIRED
+ source CDATA #IMPLIED
+ tilewidth CDATA #IMPLIED
+ tileheight CDATA #IMPLIED
+ spacing CDATA #IMPLIED
+>
+
+<!--
+ image required when child of all but layer -> data
+ image not valid when child of layer -> data
+-->
+<!ELEMENT tile (properties?, image?)>
+<!--
+ id required when child of all but layer -> data
+ id not valid when child of layer -> data
+ gid required when child of layer -> data
+ gid not valid when not child of layer -> data
+-->
+<!ATTLIST tile
+ id CDATA #IMPLIED
+ gid CDATA #IMPLIED
+>
+
+<!ELEMENT layer (properties?, data)>
+<!ATTLIST layer
+ name CDATA #REQUIRED
+ width CDATA #REQUIRED
+ height CDATA #REQUIRED
+ opacity CDATA #IMPLIED
+>
+
+<!ELEMENT objectgroup (object*)>
+<!ATTLIST objectgroup
+ name CDATA #REQUIRED
+ width CDATA #IMPLIED
+ height CDATA #IMPLIED
+>
+
+<!ELEMENT object (properties?)>
+<!ATTLIST object
+ name CDATA #REQUIRED
+ type CDATA #REQUIRED
+ x CDATA #REQUIRED
+ y CDATA #REQUIRED
+ width CDATA #IMPLIED
+ height CDATA #IMPLIED
+>
More information about the tiled-commit
mailing list