Article

Adding a Default Attribute to a Document

Author Info

28 February 2007 - 4:31am
Submitted by: anonymous (not verified)

article
Reads:

1064

Score:
0
0
 
Comments:

0

Problem

A Forum reader recently asked:

"After doing a source query, you get an "Instance" document back. How can I add a default attribute to this document? I think I need to use do-append-xml-text or element, but I have not found any examples of this."

And here's the response from Father Ramon ...

Solution

Try this:

<rule>
  <description>add default attribute to instance</description>
  <conditions>
   <and>
    <if-operation mode="case" op="equal">instance</if-operation>
    <if-class-name mode="nocase" op="equal">User</if-class-name>
   </and>
  </conditions>
  <actions>
   <do-append-xml-element expression="." name="attr"/>
   <do-set-xml-attr expression="attr[last()]" name="attr-name">
    <arg-string>
     <token-text>MyAttrName</token-text>
    </arg-string>
   </do-set-xml-attr>
   <do-append-xml-element expression="attr[last()]" name="value"/>
   <do-append-xml-text expression="attr[last()]/value[last()]">
    <arg-string>
     <token-text>the value of the attribute</token-text>
    </arg-string>
   </do-append-xml-text>
  </actions>
</rule>

Author Info

28 February 2007 - 4:31am
Submitted by: anonymous (not verified)




User Comments

© 2009 Novell, Inc. All Rights Reserved.