[jdom-interest] CDATA inconsistency

Elliotte Rusty Harold elharo at metalab.unc.edu
Tue May 14 13:40:31 PDT 2002


The public CDATA constructor is as follows:

    public CDATA(String str) {
        super(str);
    }

However, the setText() method makes checks this constrcutor doesn't make:

    public Text setText(String str) {
        // Overrides Text.setText() because this needs to check CDATA
        // rules are enforced.  We could have a separate Verifier check
        // for CDATA beyond Text and call that alone before super.setText().

        String reason;

        if (str == null) {
            value = EMPTY_STRING;
            return this;
        }

        if ((reason = Verifier.checkCDATASection(str)) != null) {
            throw new IllegalDataException(str, "CDATA section", reason);
        }
        value = str;
        return this;
    }

I think the constructor should call setText() instead of super; i.e.

    public CDATA(String str) {
        this.setText(str);
    }

-- 
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+ 
|           The XML Bible, 2nd Edition (IDG Books, 2001)             |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:   http://www.cafeaulait.org/     | 
|  Read Cafe con Leche for XML News:  http://www.cafeconleche.org/   |
+----------------------------------+---------------------------------+






More information about the jdom-interest mailing list