String xmlPathSave = xmlPath; if (filename.indexOf(File.separatorChar) >= 0) { xmlPath = filename.substring(0, filename.lastIndexOf(File.separatorChar) + 1); }  NodeList tsNodeList = tsDoc.getElementsByTagName("tileset");  for (int itr = 0; (tsNode = tsNodeList.item(itr)) != null; itr++) { set = unmarshalTileset(tsNode); if (set.getSource() != null) { warnings.push( "WARN: Recursive external Tilesets are not supported."); } set.setSource(filename);   break; }  xmlPath = xmlPathSave;
    private TileSet unmarshalTilesetFile(InputStream in, String filename)        throws Exception    {        TileSet set = null;        Node tsNode;        Document tsDoc = null;        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();        try {            DocumentBuilder builder = factory.newDocumentBuilder();            tsDoc = builder.parse(in, ".");        } catch (FileNotFoundException fnf) {            // TODO: Have a popup and ask the user to browse to the file...            warnings.push("ERROR: Could not find external tileset file " +                    filename);        }        String xmlPathSave = xmlPath;        if (filename.indexOf(File.separatorChar) >= 0) {            xmlPath = filename.substring(0,                    filename.lastIndexOf(File.separatorChar) + 1);        }        NodeList tsNodeList = tsDoc.getElementsByTagName("tileset");        for (int itr = 0; (tsNode = tsNodeList.item(itr)) != null; itr++) {            set = unmarshalTileset(tsNode);            if (set.getSource() != null) {                warnings.push(                        "WARN: Recursive external Tilesets are not supported.");            }            set.setSource(filename);            // NOTE: This is a deliberate break. multiple tilesets per TSX are            // not supported yet (maybe never)...            break;        }        xmlPath = xmlPathSave;        return set;    }