Page 1 of 1

How to make some form controls editable while other content

Posted: Mon Jun 23, 2014 10:33 pm
by branislav.mikulas
Hi,

I have the following XML (a short sample extracted from a more complex one):

Code: Select all


<weather>
<section name="All">
<station name="KhasabPort">
<param name="T_MIN" value="34"/>
<param name="T_MAX" value="40"/>
</station>
<station name="Matrah">
<param name="T_MIN" value="30"/>
<param name="T_MAX" value="35"> </param>
</station>
</section>
</weather>
and an associated CSS stylesheet:

Code: Select all


* {
display: block;
margin-left: 5px;
}

station:before {
content:
oxy_xpath("@name")
}

param:before {
content:
oxy_xpath("@name")
": "
oxy_editor( type, text,
edit, "@value");
}
(I used the oxy_xpath function to show the names, because I did not figure out if it is possible to get the @name values using the oxy_label function)

However I would like to have the number and the name of stations to be fixed and also the number and the names of the params to be fixed. I want only the param's "value" attributes to be editable in the Author mode.

Then I tried adding the following to the CSS:

Code: Select all


station {
-oxy-editable:false;
}

param {
-oxy-editable:true;
}
The -oxy-editable:false applied to the "station" as expected but the -oxy-editable:true did not apply to the "param" (so the "param" was not editable at all). Anyway I guess if the -oxy-editable:true worked for the "param", it would make all the "param" element editable (not only the @value) so I think it still would not be exactly what I wanted to achieve.

Could you please give some advice? Thank you.

Re: How to make some form controls editable while other cont

Posted: Tue Jun 24, 2014 11:13 am
by Radu
Hi,

Once you set -oxy-editable:false; to an element, the property will be propagated down to all its descendents, so you cannot specify that an ancestor is not editable but a certain descendant XML element is editable.

What you want can right now only be done by using our Author SDK Java API:

http://www.oxygenxml.com/oxygen_sdk.htm ... horing_SDK

We have a Java API called ro.sync.ecss.extensions.api.AuthorDocumentFilter which can be set and would allow you to intercept insertion and deletion events and reject them if they are done in certain places from the XML. If you want to try this approach, I could try to give you more details about this.

As a side observation, please try to use oxy_xpath as little as possible in the CSS as it might induce performance problems in very large documents, for example instead of constructs like this:

Code: Select all

 oxy_xpath("@name")
you can use directly:

Code: Select all

attr("name")
which is the regular way to get the value of an attribute in CSS.

Regards,
Radu

Re: How to make some form controls editable while other cont

Posted: Wed Jun 25, 2014 8:59 am
by Radu
One more thing,

We are discussing internally about implementing a special "-oxy-editable" extension value called something like:

Code: Select all

-oxy-editable:form-controls-only;
This would allow users to edit in those places only by using form control functionality, without allowing users to insert/remove content in any other way.
So if we implement this in a future version, it will also probably be a good fix for your issue. I'll update this forum thread if we do.

Regards,
Radu