Difference between revisions of "XML Attribute"

112 bytes added ,  13:16, 3 May 2011
Rebranding XML "traits" as "attributes"
imported>Low Post
(Added a warning about child() not being restricted to direct children.)
imported>JRoush
(Rebranding XML "traits" as "attributes")
Line 1: Line 1:
Normal XML uses named attributes for specifying additional info for an element. The XML syntax doesn't specify what attributes are possible, only that they be given as ''AttributeName="Value"'' in the opening tag of an element.  Oblivion XML recognizes only three true XML attributes: '''name''', '''src''', and '''trait'''.   
Normal XML uses named attributes (also called '''traits''', but that word has a different meaning in Oblivion's XML) to specify additional info for an element. The XML syntax doesn't specify what attributes are possible, only that they be given as ''AttributeName="Value"'' in the opening tag of an element.  Oblivion XML recognizes only three true XML attributes: '''name''', '''src''', and '''trait'''.   


The '''name''' attribute provides a way to identify elements in a menu file.  This attribute is used only for [[Object Element]]s - property or operator elements are never named.  The name of an element need not be unique within the entire menu, but every element should at least have a different name from it's siblings (as discussed below).
The '''name''' attribute provides a way to identify elements in a menu file.  This attribute is used only for [[Object Element]]s - property or operator elements are never named.  The name of an element need not be unique within the entire menu, but every element should at least have a different name from it's siblings (as discussed below).
Line 8: Line 8:
The '''src''' and '''trait''' attributes are always provided together (except for the special case of the [[Include Element]]).  They are used only in empty Operator elements, to specify the value used by the operator:
The '''src''' and '''trait''' attributes are always provided together (except for the special case of the [[Include Element]]).  They are used only in empty Operator elements, to specify the value used by the operator:


  <!-- Good -->
The '''src''' attribute can refer to any [[Object Element]] by it's name, or can use one of the "relative" sources:
*'''Me()''' - the object whose property the operator is modifying.
*'''Parent()''' - the parent of Me(), that is the element of which Me() is a child.
*'''Sibling(''SiblingName'')''' - a the siblings of Me(), that is the elements that are also children of Parent(). The name of the sibling can be provided as an argument - this is why no two siblings should have the same name. When omitted it will use the sibling that came before it - the one that was defined above it in the XML (doesn't work for the very first element).
*'''Child(''ChildName'')''' - a child object of Me().  Again, the name must be specified.  The search for ''ChildName'' isn't restricted to direct children - it also includes children of children, and their children, and so on. If multiple children with the same name exist the last one specified in the xml is used.
 
The '''trait''' attribute can refer to any [[Property Element]] (or "trait") of the source.  The current value of the property is used as value of the operator.
 
  <image>
  <image>
     <x>
     <x>
       &lt;!-- Add the value of SomeElement's width property --&gt;
       &lt;!-- The Add Operator gets its value from the Width Property/Trait of SomeElement.--&gt;
       &lt;!-- to the current x value of this image --&gt;
       &lt;!-- The result is to add SomeElement's width to the current x value of this image --&gt;
       <add src="SomeElement" trait="width" />  
       <add src="SomeElement" trait="width" />  
     </x>
     </x>
  </image>
  </image>
   
   
The '''src''' attribute can refer to any [[Object Element]] by it's name, or can use one of the "relative" sources:
*'''Me()''' - the object whose property the operator is modifying.
*'''Parent()''' - the parent of Me(), that is the element of which Me() is a child.
*'''Sibling(''SiblingName'')''' - a the siblings of Me(), that is the elements that are also children of Parent().  The name of the sibling can be provided as an argument - this is why no two siblings should have the same name. When omitted it will use the sibling that came before it - the one that was defined above it in the XML. Although this does not work for the very first element.
*'''Child(''ChildName'')''' - a child object of Me().  Again, the name must be specified.
**The search for ''ChildName'' isn't restricted to direct children of Me(). Also a children of a child of (a child of ...) Me() are valid values. If multiple children with the same name exist the last one specified in the xml is used.
The '''trait''' attribute can refer to any ''property'' of the source object.  The current value of this property is used as value (operand) of the operator.
[[Category:Oblivion XML]]
[[Category:Oblivion XML]]
Anonymous user