changing attribute name, not value, with form controls in Author View

Oxygen general issues.
ttasovac
Posts: 82
Joined: Fri Dec 19, 2003 6:02 pm

changing attribute name, not value, with form controls in Author View

Post by ttasovac »

Hi.

I have a date picker form control like this:

Code: Select all

correspAction date:before {
    font-family: "Platforma Sans", sans-serif;
    content:
        oxy_label(text, "Датум: ", width, 30%)       
        oxy_datePicker(edit, '@when', width, 23%, format, 'yyyy-MM-dd', fontInherit, true, color, inherit);      
}
It works as expected and it enters the date into the `@when` attribute. So far so good.

In TEI, however, we need to use a different attribute for inexact dates, either `@notBefore` or `@notAfter`. So, next to the date picker, I'd like to add an oxy_comobox with the default value `@when`, and two additional values `@notBefore` and `@notAfter`, and then an oxy_action onChange that would replace `@when` with the selected attribute name (`@notBefore` or `@notAfter`) and keep the date picker working with the new attribute.

Is this something that can be done? If not, what's the most elegant way of giving the user this kind of choice without overcrowding the form?

Many thanks in advance.

All best,
Toma
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: changing attribute name, not value, with form controls in Author View

Post by alex_jitianu »

Hello,
In theory it sounds feasible. The onChange can execute an XQueryUpdateOperation, for example, to refactor the document. Afterwards, to make the date picker edit a different attribute you can rely on a number of extra selectors:

Code: Select all

correspAction date[notBefore]:before {
    font-family: "Platforma Sans", sans-serif;
    content:
        oxy_label(text, "Датум: ", width, 30%)       
        oxy_datePicker(edit, '@notBefore', width, 23%, format, 'yyyy-MM-dd', fontInherit, true, color, inherit);      
}
correspAction date[notAfter]:before {
    font-family: "Platforma Sans", sans-serif;
    content:
        oxy_label(text, "Датум: ", width, 30%)       
        oxy_datePicker(edit, '@notAfter', width, 23%, format, 'yyyy-MM-dd', fontInherit, true, color, inherit);      
}
Best regards,
Alex
ttasovac
Posts: 82
Joined: Fri Dec 19, 2003 6:02 pm

Re: changing attribute name, not value, with form controls in Author View

Post by ttasovac »

That's very cool, Alex. I see I can also do it with XSLT, which is easier for me.

The one bit that I'm still missing is how to pass the selected value from the combobox to my XSLT script:

Code: Select all

oxy_combobox(        
        edit, "@ana",
        editable, false,
        values, "when, notAfter, notBefore",
        labels, "тачно, пре, после",
        onChange, oxy_action(
          name, 'Refactor Date', 
          description, 'Change the attribute depending on selected value', 
          operation, 'ro.sync.ecss.extensions.commons.operations.XSLTOperation', 
          arg-script, '${pd}/xslt/refactorDate.xsl'
          arg-sourceLocation, '.',
          arg-targetLocation, '.',
          arg-externalParams, 'dateKind=???')
)
What do I need to put there instead of ??? to refer to the selected value?

Many thanks in advance.

All best,
Toma
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: changing attribute name, not value, with form controls in Author View

Post by alex_jitianu »

Hi Toma,
I think that you can use xpath_eval, like this:

Code: Select all

'dateKind= ${xpath_eval(@ana)}'
. Another option is to use XQueryUpdateOperation which is invoked in the content of the element:

Code: Select all

            onChange, oxy_action(
                name, 'Insert',
                operation, 'XQueryUpdateOperation',
                arg-script, 'insert node <product>{xs:string(@attribute)}</product>
                          as last into .')
ttasovac
Posts: 82
Joined: Fri Dec 19, 2003 6:02 pm

Re: changing attribute name, not value, with form controls in Author View

Post by ttasovac »

Thanks, Alex!
Post Reply