Help

8

xpath - how to replace attributes only and not the full field?

Avatar
Michael Karrer

Is it possible to only replace the attributes of an xml field in an xml view but not the full field?

Example:

<page string="Contacts" attrs="{'invisible': [('is_company','=',False), ('child_ids', '=', [])]}" autofocus="autofocus">
...
</page>

All i want to change is the

attrs="{'invisible': [('is_company','=',False), ('child_ids', '=', [])]}"

to

attrs=""

without replacing the full page field and all of its content!

So the problem is that i only know how to replace the full <page> filed with all of its content - so i would have to copy and paste all of the content of the page field to my new inherited view also - not a good way for me!

So is there a way to only change the attributes of a field (xml node) through an inherited view?

Avatar
Discard
1 Answer
31
Best Answer

Hello Michael,

There is a attributes value in position which allows you to change/replace the value of the attribute.

Try this:

<xpath expr="//page[@string='Contacts']" position="attributes">
    <attribute name="attrs">{}</attribute>
</xpath>

Thanks,

Serpent Consulting Services

2 Comments
Avatar
Discard

Just a sidenote: Since V9 @string has been depracated and you should now use @name.

Avatar
Tushar Donga
-

@Yenthe

<xpath expr="//page[@name='validity_date']" position="attributes">

<attribute name="attrs">{'required':[('demo_name','!=',False)]}</attribute>

can you tell me what wrong in this beacuse this is not working