#16 Misleading display of invalid attributes in some cases



I think a bug in Jaxe 3.5 allows to display invalid attributes as valid attributes.

Let's assume we use this "exemple_config.xsd" schema file (to use with an "exemple_config.xml" interface file automatically generated thanks to the appropriated Jaxe function):

========== BOF: exemple_config.xsd ==========
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:complexType mixed="true" name="typeDates">
<xs:element name="creation">
<xs:complexType mixed="true">
<xs:attribute name="date" type="xs:date" use="required">


<xs:element name="dates" type="typeDates">

========== EOF: exemple_config.xsd ==========

If you create a new XML file using the "exemple_config.xml" file you can generate this output file for instance:

========== BOF: MyBuggedFile.xml ==========
<?xml version="1.0" encoding="ISO-8859-1"?>
<creation date="OmgWhatAnInvalidValueWeShouldHaveADateHere">

========== EOF: MyBuggedFile.xml ==========

And Jaxe 3.5 will show you that everything is valid and won't even complain about an invalid value when you click "OK" in the attribute dialog box. The best you will get is a red cross on the right edge of the attribute dialog box showing that the value is invalid but nothing will block you from inputing an invalid value. In the editing area all the validation marks will be green. Assuming to what I've seen on other validation boxes something should prevent this kind of invalid data to be input.

If you run the validation function in Jaxe the report will clearly display that data is invalid (sorry it's in French):

========== BOF: validation report ==========
Error : cvc-datatype-valid.1.2.1 : 'wdf' n'est pas une valeur valide pour 'date'.

Error : cvc-attribute.3 : La valeur 'wdf' de l'attribut 'date' de l'élément 'creation' n'est pas valide par rapport à son type, 'date'.
========== EOF : validation report ==========

I wish I could write a patch to solve this issue but I don't have any skills about Java - sorry guys...

Best regards,



  • Cluxter

    Just to clarify: the report shows "wdf" because I used this value first to test the bug then replaced it by "OmgWhatAnInvalidValueWeShouldHaveADateHere" to make things clearer in my exemple.

  • I see how this behavior can be a problem, but it was actually chosen: there are cases where one would want to be able to close the attribute dialog even though an attribute is invalid. For instance, if you want to look at an invalid document without changing it.

    Currently, the attribute is marked as invalid with the red cross, so I think your bug title is inexact. The element color is not changed in the XML window because this is only taking the children nodes into account. We could change that and validate the attributes too, but I am afraid it could confuse some users who would wonder if a child element is missing without thinking about the attributes. It would also slow down the display for large documents, which is already an issue.

    Note that there are other cases where an invalid document is created with Jaxe. For instance, when a document is being created and some of the required children have not been created yet. The only way to be sure a document is valid is to use the validation menu.

    This is basically a UI problem, and I have not found a good solution yet...

  • Cluxter

    • summary: Invalid attributes displayed as valid attributes --> Misleading display of invalid attributes in some cases
  • Cluxter

    We could add a third color and a third mark to those already existing. Let's say - arbitrarily - grey for the color and a "~" or a "#" or a "¤" for the mark (or whatever you want).
    This feature could be an option disabled by default.

    This way we would ensure that:

    - a green color or a "V" means "this part is valid";
    - a grey color (or whatever you want which is not to close to green or to red) or an new symbol means "invalid but on attributes only";
    - a red color or an "X" means "invalid on a child/on children - and maybe on attributes too since red would have the priority on grey;
    - the compatibility with the way the software was used so far is not broken; someone who would use this new version wouldn't see any difference on an invalid document as long as he/she doesn't enable the option;
    - the display wouldn't be slowed down by default (or not a lot at all I guess) - only if the user decides to do it on purpose.

    I changed the title accordingly.

    • status: open --> closed-fixed
  • Adding more colors is not a good solution, because there are already different sets of colors used for different namespaces. It is already getting confusing.

    I have decided to change the meaning of the changed color and checked icon on elements from "children elements are invalid" to "the element (children or attributes) is invalid". It is easy to understand, and hopefully users will think of checking the attributes when they see an invalid element. This situation is better than the older one anyway, because it was too easy to miss invalid attributes.

    I checked the performance with WXS schemas, and although it requires to validate all attributes when loading a document, it does not seem to impact loading time significantly. What slows things down is the JDK implementation for JTextPane, which is horrible.

    I have also fixed the text color for an invalid attribute value when an attribute dialog is opened. It should be red.

    It's in the mercurial repository, and will be in the next release of Jaxe.