@Override
  public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
    try {
    //log.debug("S: '" + uri + "' " + qName);
    // ----- <xfml> -----------------------------------------------------------
    if (EL_XFML.equals(qName)) {
      String version = atts.getValue("version");
      if (version == null)
        log.warn("No version attribute on 'xfml' element");
      if (!"1.0".equals(version))
        log.warn("Unsupported XFML version: " + version);
      String mapurl = atts.getValue("url");
      if (mapurl == null)
        log.warn("No url attribute on 'xfml' element");
      else {
        try {
          map_uri = new URILocator(mapurl);
          TopicMapStoreIF store = topicmap.getStore();
          if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
            ((AbstractTopicMapStore) store).setBaseAddress(map_uri);
          doc_address = map_uri;
          // Add this document to the list of processed documents.
          processed_documents_accumulated.add(getBaseAddress());
        } catch (MalformedURLException e) {
          log.warn("Invalid xfml base URL: " + mapurl);
        }
      }
      // FIXME: what to do about language?
    }
    // ----- <facet> ----------------------------------------------------------
    else if (EL_FACET.equals(qName)) {
      String id = atts.getValue("id");
      // FIXME: complain if no id
      current_topic = builder.makeTopic();
      registerSourceLocator(current_topic, id);
      keep_content = true;
    }
    // ----- <topic> ----------------------------------------------------------
    else if (EL_TOPIC.equals(qName)) {
      String id = atts.getValue("id");
      // FIXME: complain if no id
      current_topic = builder.makeTopic();
      registerSourceLocator(current_topic, id);
      String parentid = atts.getValue("parentTopicid");
      if (parentid == null)
        parentid = atts.getValue("facetid");
      // FIXME: complain if no refs
      TopicIF parent = resolveTopicRef("#" + parentid);
      parentBuilder.makeAssociation(parent, current_topic);
    }
    // ----- <page> -----------------------------------------------------------
    else if (EL_PAGE.equals(qName)) {
      String url = atts.getValue("url");
      // FIXME: complain if no url
      current_topic = builder.makeTopic();
      current_topic.addSubjectLocator(createLocator(url));
    }
    // ----- <occurrence>------------------------------------------------------
    else if (EL_OCCURRENCE.equals(qName)) {
      String topicid = atts.getValue("topicid");
      // FIXME: complain if none
      TopicIF subject = resolveTopicRef("#" + topicid);
      occursBuilder.makeAssociation(subject, current_topic);
    }
    // ----- <name> -----------------------------------------------------------
    // ----- <psi> ------------------------------------------------------------
    // ----- <description> ----------------------------------------------------
    // ----- <title> ----------------------------------------------------------
    // ----- <connect> --------------------------------------------------------
    else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
            EL_TITLE.equals(qName) || EL_CONNECT.equals(qName)) 
      keep_content = true;   
    } catch (RuntimeException e) {
      e.printStackTrace();
      throw e;
    }
  }
@Override
  public void startElement (String uri, String name, String qName, Attributes atts) throws SAXException {
    try {
   
   
    if (EL_XFML.equals(qName)) {
      String version = atts.getValue("version");
      if (version == null)
        log.warn("No version attribute on 'xfml' element");
      if (!"1.0".equals(version))
        log.warn("Unsupported XFML version: " + version);
      String mapurl = atts.getValue("url");
      if (mapurl == null)
        log.warn("No url attribute on 'xfml' element");
      else {
        try {
          map_uri = new URILocator(mapurl);
          TopicMapStoreIF store = topicmap.getStore();
          if (store instanceof AbstractTopicMapStore && store.getBaseAddress() == null)
            ((AbstractTopicMapStore) store).setBaseAddress(map_uri);
          doc_address = map_uri;
         
          processed_documents_accumulated.add(getBaseAddress());
        } catch (MalformedURLException e) {
          log.warn("Invalid xfml base URL: " + mapurl);
        }
      }
     
    }
   
    else if (EL_FACET.equals(qName)) {
      String id = atts.getValue("id");
     
      current_topic = builder.makeTopic();
      registerSourceLocator(current_topic, id);
      keep_content = true;
    }
   
    else if (EL_TOPIC.equals(qName)) {
      String id = atts.getValue("id");
     
      current_topic = builder.makeTopic();
      registerSourceLocator(current_topic, id);
      String parentid = atts.getValue("parentTopicid");
      if (parentid == null)
        parentid = atts.getValue("facetid");
     
      TopicIF parent = resolveTopicRef("#" + parentid);
      parentBuilder.makeAssociation(parent, current_topic);
    }
   
    else if (EL_PAGE.equals(qName)) {
      String url = atts.getValue("url");
     
      current_topic = builder.makeTopic();
      current_topic.addSubjectLocator(createLocator(url));
    }
   
    else if (EL_OCCURRENCE.equals(qName)) {
      String topicid = atts.getValue("topicid");
     
      TopicIF subject = resolveTopicRef("#" + topicid);
      occursBuilder.makeAssociation(subject, current_topic);
    }
   
   
   
   
   
    else if (EL_NAME.equals(qName) || EL_PSI.equals(qName) || EL_DESCRIPTION.equals(qName) ||
            EL_TITLE.equals(qName) || EL_CONNECT.equals(qName)) 
      keep_content = true;   
    } catch (RuntimeException e) {
      e.printStackTrace();
      throw e;
    }
  }
@override public void startelement (string uri, string name, string qname, attributes atts) throws saxexception { try { if (el_xfml.equals(qname)) { string version = atts.getvalue("version"); if (version == null) log.warn("no version attribute on 'xfml' element"); if (!"1.0".equals(version)) log.warn("unsupported xfml version: " + version); string mapurl = atts.getvalue("url"); if (mapurl == null) log.warn("no url attribute on 'xfml' element"); else { try { map_uri = new urilocator(mapurl); topicmapstoreif store = topicmap.getstore(); if (store instanceof abstracttopicmapstore && store.getbaseaddress() == null) ((abstracttopicmapstore) store).setbaseaddress(map_uri); doc_address = map_uri; processed_documents_accumulated.add(getbaseaddress()); } catch (malformedurlexception e) { log.warn("invalid xfml base url: " + mapurl); } } } else if (el_facet.equals(qname)) { string id = atts.getvalue("id"); current_topic = builder.maketopic(); registersourcelocator(current_topic, id); keep_content = true; } else if (el_topic.equals(qname)) { string id = atts.getvalue("id"); current_topic = builder.maketopic(); registersourcelocator(current_topic, id); string parentid = atts.getvalue("parenttopicid"); if (parentid == null) parentid = atts.getvalue("facetid"); topicif parent = resolvetopicref("#" + parentid); parentbuilder.makeassociation(parent, current_topic); } else if (el_page.equals(qname)) { string url = atts.getvalue("url"); current_topic = builder.maketopic(); current_topic.addsubjectlocator(createlocator(url)); } else if (el_occurrence.equals(qname)) { string topicid = atts.getvalue("topicid"); topicif subject = resolvetopicref("#" + topicid); occursbuilder.makeassociation(subject, current_topic); } else if (el_name.equals(qname) || el_psi.equals(qname) || el_description.equals(qname) || el_title.equals(qname) || el_connect.equals(qname)) keep_content = true; } catch (runtimeexception e) { e.printstacktrace(); throw e; } }