else if (child.getNodeName().equalsIgnoreCase("image")) {
else if ("image".equalsIgnoreCase(child.getNodeName())) {
    private TileSet unmarshalTileset(Node t) throws Exception {        String source = getAttributeValue(t, "source");        String basedir = getAttributeValue(t, "basedir");        int firstGid = getAttribute(t, "firstgid", 1);        String tilesetBaseDir = xmlPath;        if (basedir != null) {            tilesetBaseDir = basedir; //makeUrl(basedir);        }        if (source != null) {            String filename = tilesetBaseDir + source;            //if (Util.checkRoot(source)) {            //    filename = makeUrl(source);            //}            TileSet ext = null;            try {                //just a little check for tricky people...                String extention = source.substring(source.lastIndexOf('.') + 1);                if (!extention.toLowerCase().equals("tsx")) {                	logger.warn("tileset files should end in .tsx! ("+source+")");                }                InputStream in = new URL(makeUrl(filename)).openStream();                ext = unmarshalTilesetFile(in, filename);            } catch (FileNotFoundException fnf) {            	logger.error("Could not find external tileset file " +                        filename);            }            if (ext == null) {            	logger.error("tileset "+source+" was not loaded correctly!");                ext = new TileSet();            }            ext.setFirstGid(firstGid);            return ext;        }        else {            int tileWidth = getAttribute(t, "tilewidth", map != null ? map.getTileWidth() : 0);            int tileHeight = getAttribute(t, "tileheight", map != null ? map.getTileHeight() : 0);            int tileSpacing = getAttribute(t, "spacing", 0);            TileSet set = new TileSet();            set.setName(getAttributeValue(t, "name"));            set.setBaseDir(basedir);            set.setFirstGid(firstGid);            boolean hasTileElements = false;            NodeList children = t.getChildNodes();            // Do an initial pass to see if any tile elements are specified            for (int i = 0; i < children.getLength(); i++) {                Node child = children.item(i);                if (child.getNodeName().equalsIgnoreCase("tile")) {                    hasTileElements = true;                }            }            for (int i = 0; i < children.getLength(); i++) {                Node child = children.item(i);                if (child.getNodeName().equalsIgnoreCase("tile")) {                    set.addTile(unmarshalTile(set, child, tilesetBaseDir));                }                else if (child.getNodeName().equalsIgnoreCase("image")) {                    String imgSource = getAttributeValue(child, "source");                    String id = getAttributeValue(child, "id");                    String transStr = getAttributeValue(child, "trans");                    if (imgSource != null && id == null) {                        // Not a shared image, but an entire set in one image                        // file                        // FIXME: importTileBitmap does not fully support URLs                        String sourcePath = imgSource;                        if (!Util.checkRoot(imgSource)) {                            sourcePath = tilesetBaseDir + imgSource;                        }                        logger.info("Importing " + sourcePath + "...");                        BufferedImage tilesetImage = ImageIO.read(new File(sourcePath));                        if (transStr != null) {                            // In this case, the tileset image needs special                            // handling for transparency                            Color color = new Color(                                    Integer.parseInt(transStr, 16));                            Toolkit tk = Toolkit.getDefaultToolkit();                            Image trans = tk.createImage(                                    new FilteredImageSource(tilesetImage.getSource(),                                        new TransparentImageFilter(                                            color.getRGB())));                            BufferedImage img = new BufferedImage(                                    trans.getWidth(null),                                    trans.getHeight(null),                                    BufferedImage.TYPE_INT_ARGB);                            img.getGraphics().drawImage(trans, 0, 0, null);                            tilesetImage = img;                            set.setTransparentColor(color);                        }                        set.importTileBitmap(tilesetImage, new BasicTileCutter(                                tileWidth, tileHeight, tileSpacing, 0),                            !hasTileElements);                        set.setTilesetImageFilename(sourcePath);                    } else {                        set.addImage(unmarshalImage(child, tilesetBaseDir),                                Integer.parseInt(getAttributeValue(child, "id")));                    }                }            }            return set;        }    }