private void scanTranslates(File file, Map<String, Set<TranslateEntity>> translates)
     throws XmlPullParserException, IOException {
   XmlPullParser parser = PlatformUtil.newXMLPullParser();
   parser.setInput(new FileReader(file));
   int tok;
   TranslateEntity te = null;
   while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
     if (tok == XmlPullParser.START_TAG) {
       String name = parser.getName();
       if (name.equals("way") || name.equals("node") || name.equals("relation")) {
         te = new TranslateEntity(name);
       } else if (name.equals("tag") && te != null) {
         Map<String, String> attrs = new LinkedHashMap<String, String>();
         for (int i = 0; i < parser.getAttributeCount(); i++) {
           attrs.put(parser.getAttributeName(i), parser.getAttributeValue(i));
         }
         te.tm.put(attrs.get("k"), attrs.get("v"));
       }
     } else if (tok == XmlPullParser.END_TAG) {
       String name = parser.getName();
       if (name.equals("way") || name.equals("node") || name.equals("relation")) {
         if (!te.isEmpty()) {
           Iterator<Entry<String, String>> it = te.tm.entrySet().iterator();
           addTranslate(translates, te, "entity=" + te.name);
           while (it.hasNext()) {
             Entry<String, String> e = it.next();
             addTranslate(
                 translates, te, e.getKey().toLowerCase() + "=" + e.getValue().toLowerCase());
           }
         }
         te = null;
       }
     }
   }
 }
 public CountryRegion parseRegionStructure(String repo)
     throws XmlPullParserException, IOException {
   String regionsXml = repo + "/resources/countries-info/regions.xml";
   XmlPullParser parser = PlatformUtil.newXMLPullParser();
   parser.setInput(new FileReader(regionsXml));
   int tok;
   CountryRegion global = new CountryRegion();
   List<CountryRegion> stack = new ArrayList<CountryOcbfGeneration.CountryRegion>();
   stack.add(global);
   CountryRegion current = global;
   while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
     if (tok == XmlPullParser.START_TAG) {
       String name = parser.getName();
       if (name.equals("region")) {
         Map<String, String> attrs = new LinkedHashMap<String, String>();
         for (int i = 0; i < parser.getAttributeCount(); i++) {
           attrs.put(parser.getAttributeName(i), parser.getAttributeValue(i));
         }
         CountryRegion cr = createRegion(current, attrs);
         stack.add(cr);
         current = cr;
       }
     } else if (tok == XmlPullParser.END_TAG) {
       String name = parser.getName();
       if (name.equals("region")) {
         stack.remove(stack.size() - 1);
         current = stack.get(stack.size() - 1);
       }
     }
   }
   return global;
 }
  public static RoutingConfiguration.Builder parseFromInputStream(InputStream is)
      throws IOException, XmlPullParserException {
    XmlPullParser parser = PlatformUtil.newXMLPullParser();
    final RoutingConfiguration.Builder config = new RoutingConfiguration.Builder();
    GeneralRouter currentRouter = null;
    String previousKey = null;
    String previousTag = null;
    int tok;
    parser.setInput(is, "UTF-8");
    while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
      if (tok == XmlPullParser.START_TAG) {
        String name = parser.getName();
        if ("osmand_routing_config".equals(name)) {
          config.defaultRouter = parser.getAttributeValue("", "defaultProfile");
        } else if ("routingProfile".equals(name)) {
          currentRouter = parseRoutingProfile(parser, config);
        } else if ("attribute".equals(name)) {
          parseAttribute(parser, config, currentRouter);
          previousKey = parser.getAttributeValue("", "name");
          previousTag = name;
        } else if ("specialization".equals(name)) {
          parseSpecialization(parser, currentRouter, previousKey, previousTag);
        } else {
          previousKey =
              parser.getAttributeValue("", "tag") + "$" + parser.getAttributeValue("", "value");
          previousTag = name;
          if (parseCurrentRule(parser, currentRouter, previousKey, name)) {

          } else {

          }
        }
      }
    }
    return config;
  }