Changes between Initial Version and Version 1 of FAQ_XmlPathNames

03/08/06 23:39:14 (11 years ago)



  • FAQ_XmlPathNames

    v1 v1  
     1= How do I read XML Paths with Rappture1.x? = 
     3Rappture uses a very simple, clear method for refering to elements 
     4of an xml tree. Take this node for example: 
     8    <input> 
     9        <number id="temperature"> 
     10            <default>10</default> 
     11            <current>15</current> 
     12        </number> 
     13    </input> 
     17In the above example, there are 4 accessible xml nodes. 
     18  1. input 
     19  2. number 
     20  3. default 
     21  4. current 
     23<run> is not considered an accessible node for Rappture. 
     24Instead it is named the root node. All xml information 
     25relevant to Rappture can be found inside of the root node's  
     26<run>...</run> tags. 
     28In general all accessible nodes are named using the following scheme: 
     33nodeType refers to the type of node, or the text found between '<' and '>'. 
     34nodeId refers to the id attribute within the opening node tag. 
     35In the first example, the different nodeTypes are input, number, default,  
     36and current. Only one node has a nodeId, that is the number node. Since the 
     37input tag has no nodeId, its xml path (relative to the root node) is: 
     43In the first example the number node can be referred to using three  
     44different names 
     52The first way of referring to the number node simply joins two node names  
     53together. The second way reflects a stricter naming convention which 
     54encompasses full names for all nodes. The full name for the input nodes is 
     55'input' and the full name for the number node is 'number(temperature)'. 
     56The third name is a bit trickier to decompose. 'input' is the nodeType of the 
     57parent node, but the nodeType of the child node is not provided. This is 
     58acceptable. As a short cut, if the nodeId is provided within parenthesis, 
     59it can still be searched for. 
     61Note that the best way to refer to a node is to use its full name. There 
     62would be no guarantee the correct node will be found if without using  
     63the full name if the xml looked like this: 
     66    <input> 
     67        <number id="temperature"> 
     68            <default>10</default> 
     69            <current>15</current> 
     70        </number> 
     71        <number id="Ef"> 
     72            <default>3</default> 
     73            <current>2</current> 
     74        </number> 
     76    </input> 
     80In this case, just saying 'input.number' would return the first instance  
     81of the node of type 'number' under the parent node 'input'. A more appropriate 
     82way of referring to each of these nodes would be: 
     89Similarly the default and current tags can be referred to using the following names: 
     95[wiki:FAQ Back to Frequently Asked Questions]