Skip to main content
13-Aquamarine
April 5, 2020
Solved

How to force the adding of an undeclared attribute

  • April 5, 2020
  • 1 reply
  • 2210 views

Hello,

With an ACL function, is it possible to force the adding an attribute (and its value) to an element although the attribute is not declared in the reference schema ?
My XML document will be not valid against the XSD Schema, but I would like to do it.

 

Kind regards

David

Best answer by ClayHelberg

You can do this by "cheating" using the AOM and Javascript:

javascript("Application.activeDocument.insertionPoint.startContainer.setAttribute("bogus","invalid")");

In this example, it will add bogus="invalid" to the current tag (where the caret is). If you have a specific OID instead of the node where the caret is, you can use something like this:

javascript("Acl.DOMOID('" . $myoid . "').setAttribute('bogus','invalid')");

Of course, you could also do it the conventional way, by turning off context rules before adding the undeclared attribute.

1 reply

18-Opal
May 26, 2020

You can do this by "cheating" using the AOM and Javascript:

javascript("Application.activeDocument.insertionPoint.startContainer.setAttribute("bogus","invalid")");

In this example, it will add bogus="invalid" to the current tag (where the caret is). If you have a specific OID instead of the node where the caret is, you can use something like this:

javascript("Acl.DOMOID('" . $myoid . "').setAttribute('bogus','invalid')");

Of course, you could also do it the conventional way, by turning off context rules before adding the undeclared attribute.

dgopois13-AquamarineAuthor
13-Aquamarine
May 27, 2020

Hi Clay,

 

Thank you again for your help.

Best regards

David