Example #1
0
  /** This method is called when the SAX parser encounts the beginning of the XML document. */
  @Override
  public void startDocument() throws org.xml.sax.SAXException {
    // init of variables in the parent
    super.startDocument();

    /**
     * We will attempt to add namespace feature info to each namespaced element only if three
     * parameters are set in the global or local config file: ADD_NAMESPACE_FEATURES: boolean flag
     * ELEMENT_NAMESPACE_URI: feature name to use to hold namespace uri ELEMENT_NAMESPACE_PREFIX:
     * feature name to use to hold namespace prefix
     */
    OptionsMap configData = Gate.getUserConfig();

    boolean addNSFeature =
        Boolean.parseBoolean((String) configData.get(GateConstants.ADD_NAMESPACE_FEATURES));
    namespaceURIFeature = (String) configData.get(GateConstants.ELEMENT_NAMESPACE_URI);
    namespacePrefixFeature = (String) configData.get(GateConstants.ELEMENT_NAMESPACE_PREFIX);

    deserializeNamespaceInfo =
        (addNSFeature
            && namespacePrefixFeature != null
            && !namespacePrefixFeature.isEmpty()
            && namespaceURIFeature != null
            && !namespaceURIFeature.isEmpty());
  }