Different results of ciAttribute.getPossibleValues() on schema or DTD

Post here questions and problems related to editing and publishing DITA content.
SNO
Posts: 51
Joined: Mon Oct 01, 2012 3:05 pm

Different results of ciAttribute.getPossibleValues() on schema or DTD

Post by SNO »

Hallo,
I have a stange behaviour of the methode ciAttribute.getPossibleValues().

The methode returns different results depending if I use XML Schema or DTD.
Using DTD it returs null if there are no values defined in the DTD.
On Schema it returns an empty List.

Is this behaviour because of a mistake on my Schema? I use the DITA schema from Open Dita in version 1.3.

Best Regards
Stefan
Stefan Nöbauer
Senior Solution Architect
KGU-Consulting GmbH
SNO
Posts: 51
Joined: Mon Oct 01, 2012 3:05 pm

Re: Different results of ciAttribute.getPossibleValues() on schema or DTD

Post by SNO »

Hello,
I have another question about the editableState of the CIAttribute Class.
Can I use this state to distinguish between a text field and a combo? Or is it also possible to get TRUE as the editable state and also a list of values in the possible Values?

Best Regards
Stefan
Stefan Nöbauer
Senior Solution Architect
KGU-Consulting GmbH
Radu
Posts: 9046
Joined: Fri Jul 09, 2004 5:18 pm

Re: Different results of ciAttribute.getPossibleValues() on schema or DTD

Post by Radu »

Hi Stefan,

About this:
Using DTD it returs null if there are no values defined in the DTD.
On Schema it returns an empty List.
I confirm that's how things seem to be implemented on our side. Indeed it's a bit inconsistent, does that interfere with your work? I mean you can check if the list is not null and not empty to decide if there are possible values.

About the "editableState" we use a method like this on our side:

Code: Select all

  /**
   * Check if the attribute can have only allowed items.
   * @param attribute The attribute
   * @return <code>true</code> if the attribute can have only allowed items.
   */
  public static boolean canHaveOnlyAllowedValues(CIAttribute attribute){
    if(attribute != null){
      if(attribute.getEditableState() == EditableState.ONLY_ALLOWED_ITEMS){
        return true;
      } else if(attribute.getEditableState() == EditableState.SCHEMA_ONLY_ALLOWED_ITEMS){
          return true;
      }
    }
    return false;
  }
}{/code}

to decide if the combo box in which the value is edited should be directly editable or not (in which case the end user can choose only by using the drop down button).
We choose to show a text field or a combo box depending on the size of the list of possible values, if the list is null or empty we show a text field.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
SNO
Posts: 51
Joined: Mon Oct 01, 2012 3:05 pm

Re: Different results of ciAttribute.getPossibleValues() on schema or DTD

Post by SNO »

Hi Radu,
thanks for your answer.
I mean you can check if the list is not null and not empty to decide if there are possible values.
This is how we fixd this issue!

about the EditableState it is still not clear if ist is possible to have the state TRUE and possible values?
Or the state can only be *ONLY_ALLOWED_ITEMS if there are possible values.

In case the editableState is set to TRUE and I get possible values I would have to use an editable combobox. Is this a valid case?

Code: Select all

EDITABLESTATE        VALUES                          NO VALUES
false              text field (read only)     textfield (read only) 
true               editable combo             text field
onlyAllowed..      combo                            x
Best Regards,
Stefan
Stefan Nöbauer
Senior Solution Architect
KGU-Consulting GmbH
Radu
Posts: 9046
Joined: Fri Jul 09, 2004 5:18 pm

Re: Different results of ciAttribute.getPossibleValues() on schema or DTD

Post by Radu »

Hi Stefan,
In case the editableState is set to TRUE and I get possible values I would have to use an editable combobox. Is this a valid case?
Yes, it is. For example for the DITA codeblock element we proposed a number of @outputclass attribute values. But you can set your own value if you want. These proposed values do not come from the DTD but from a cc_config.xml content completion configuration file. But nonetheless this case exists.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
josephw
Posts: 11
Joined: Mon Dec 06, 2021 12:25 pm

Re: Different results of ciAttribute.getPossibleValues() on schema or DTD

Post by josephw »

Hi Radu,
how can we get the values from the content completion configuration? It feels like the values are not attached to the getPossibleValues function of CIAttribute.

Best Regards
Joseph
Joseph Weichert
Senior Solution Architect
KGU TechPub Services GmbH
Post Reply