Changes between Initial Version and Version 1 of FAQ_XmlPathNames


Ignore:
Timestamp:
Mar 8, 2006 8:39:14 PM (18 years ago)
Author:
dkearney
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FAQ_XmlPathNames

    v1 v1  
     1= How do I read XML Paths with Rappture1.x? =
     2
     3Rappture uses a very simple, clear method for refering to elements
     4of an xml tree. Take this node for example:
     5
     6{{{
     7<run>
     8    <input>
     9        <number id="temperature">
     10            <default>10</default>
     11            <current>15</current>
     12        </number>
     13    </input>
     14</run>
     15}}}
     16
     17In the above example, there are 4 accessible xml nodes.
     18  1. input
     19  2. number
     20  3. default
     21  4. current
     22
     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.
     27
     28In general all accessible nodes are named using the following scheme:
     29{{{
     30nodeType(nodeId)
     31}}}
     32
     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:
     38
     39{{{
     40input
     41}}}
     42
     43In the first example the number node can be referred to using three
     44different names
     45
     46{{{
     47input.number
     48input.number(temperature)
     49input.(temperature)
     50}}}
     51
     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.
     60
     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:
     64{{{
     65<run>
     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>
     75
     76    </input>
     77</run>
     78}}}
     79
     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:
     83
     84{{{
     85input.number(temperature)
     86input.number(Ef)
     87}}}
     88
     89Similarly the default and current tags can be referred to using the following names:
     90{{{
     91input.number(temperature).default
     92input.number(temperature).current
     93}}}
     94
     95[wiki:FAQ Back to Frequently Asked Questions]