How to make some form controls editable while other content

Questions about XML that are not covered by the other forums should go here.
branislav.mikulas
Posts: 1

How to make some form controls editable while other content

Mon Jun 23, 2014 10:33 pm

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.
Radu
Posts: 5376

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

Tue Jun 24, 2014 11:13 am

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.html#XML_Editor_Authoring_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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 5376

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

Wed Jun 25, 2014 8:59 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “General XML Questions”

Who is online

Users browsing this forum: No registered users and 0 guests