Page 1 of 1
Different results of ciAttribute.getPossibleValues() on schema or DTD
Posted: Wed Nov 11, 2020 1:06 pm
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
Re: Different results of ciAttribute.getPossibleValues() on schema or DTD
Posted: Wed Nov 11, 2020 1:25 pm
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
Re: Different results of ciAttribute.getPossibleValues() on schema or DTD
Posted: Wed Nov 11, 2020 4:42 pm
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
Re: Different results of ciAttribute.getPossibleValues() on schema or DTD
Posted: Wed Nov 11, 2020 5:47 pm
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
Re: Different results of ciAttribute.getPossibleValues() on schema or DTD
Posted: Thu Nov 12, 2020 11:58 am
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
Re: Different results of ciAttribute.getPossibleValues() on schema or DTD
Posted: Mon Feb 28, 2022 6:23 pm
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