Uploaded image for project: 'Axiom'
  1. Axiom
  2. AXIOM-375

Simplify the OMElement#declareNamespace(String, String) API

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 1.3.0
    • API
    • None

    Description

      OMElement#declareNamespace(String, String) auto-generates a prefix if the prefix is either null or the empty string. There are several issues with this:

      1. It is inconsistent with other APIs (in particular OMElement#declareNamespace(OMNamespace) which make a distinction between null (indicating that a prefix should be generated) and the empty string (meaning the default namespace).

      2. It is not possible to use OMElement#declareNamespace(String, String) to declare a default namespace. This is especially annoying when the prefix is provided as a variable, in which case one has to write something like this:

      if (prefix.length() == 0)

      { nextElem.declareDefaultNamespace(uri); }

      else

      { nextElem.declareNamespace(uri, prefix); }

      3. It is obviously not necessary to support two different ways to indicate that a prefix should be generated. One (prefix == null) should be enough.

      This should be changed in the next major release (1.3). To make the transition easier, the Javadoc in 1.2.x should be updated to indicate that using an empty string is deprecated and the code should generate a warning if the method is invoked in this way.

      Attachments

        Activity

          People

            veithen Andreas Veithen
            veithen Andreas Veithen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: