Node child = children.item(i);
Node c = children.item(i);
    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 (!"tsx".equals(extention.toLowerCase())) {                	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);            NodeList children = t.getChildNodes();            for (int i = 0; i < children.getLength(); i++) {                Node child = children.item(i);                if ("tile".equalsIgnoreCase(child.getNodeName())) {                    String id = getAttributeValue(child, "id");                    Tile tile = set.getTile(Integer.parseInt(id));                    if (tile == null) {                        // Tile not defined yet                        set.addTile(unmarshalTile(set, child, tilesetBaseDir));                    } else {                        // Reference to existing tile, just load properties                        Properties tileProps = tile.getProperties();                        NodeList children2 = child.getChildNodes();                        for (int i2 = 0; i2 < children2.getLength(); i2++) {                            Node child2 = children2.item(i2);                            if ("property".equalsIgnoreCase(child2.getNodeName())) {                                tileProps.setProperty(                                        getAttributeValue(child2, "name"),                                        getAttributeValue(child2, "value"));                            }                        }                    }                }                else if ("image".equalsIgnoreCase(child.getNodeName())) {                    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);                        }                        // todo: Store additional information to be able to                        // todo: determine whether tiles should be created                        // todo: at this time. Now defaults to creation since                        // todo: this used to be the only possible behaviour.                        set.importTileBitmap(tilesetImage, new BasicTileCutter(                                tileWidth, tileHeight, tileSpacing, 0),                                             true);                        set.setTilesetImageFilename(sourcePath);                    } else {                        set.addImage(unmarshalImage(child, tilesetBaseDir),                                Integer.parseInt(getAttributeValue(child, "id")));                    }                }            }            return set;        }    }