Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    XPath question regarding attributes and stepping

    Hello,
    I am running into a bit of a problem trying to represent data from a datasource (and render it in a grid) when I have an attribute on a node in XML...

    Expected: What I want to do is to set a record (via recordXPath) at the 'lowest' level of a nested complex structure, and then specify data values (via valueXPath) up and down the XML tree, if you will.

    Problem: The initial record item (lowest level node and attribute, e.g. @name) can be shown in a listGrid, however a complex valueXPath such as "../../element@name" does not return any values

    example:
    Code:
    <streetList>
        <street name="Decker" type="asphalt">
            <symbolList>
                <symbol name="stop" type="standing sign"/>
                <symbol name="yield" type="standing sign"/>
            </symbolList>
            <streetDates sunset="2020" sunrise="1958">
         </street>
    </streetList>
    in my datasource, I have the recordXPath set to the lowest nested node, for example:
    Code:
    isc.DataSource.create({
        ID:"streets",
        recordXPath: "/streetList/street/symbolList/symbol",
        ...,
        fields: [
                   {
                    name:"SymbolName",
                    valueXPath:"@name"
                    },
                   {
                    name:"StreetName",
                    valueXPath:"../../street@name"
                    }
                  ]
       ...

    #2
    Hi sonny,

    That's not actually a valid XPath, you want:

    Code:
                   
                {
                    name:"StreetName",
                    valueXPath:"../../@name"
                }
    Note the invalid XPath is reported as a warning in the Developer Console.

    Comment


      #3
      Thank you very much. Yes. I do now see that it was an invalid XPath!

      A problem remains, however, for me to see into the attributes of a sibling node (or, rather, a parent's sibling in this case).

      For example in my data above, if I wanted to return the value of the 'streetDates' node, 'sunset' attribute, I want to try something like:
      Code:
         ...fields: [
                     {
                      name:"SymbolName",
                      valueXPath:"@name"
                      },
                     {
                      name:"StreetSunset",
                      valueXPath:"../../streetDates@sunset"
                      }
                    ]...
      ...however it seems that this is not supported?

      Thank you in advance!
      Sonny

      Comment


        #4
        Hi sonny,

        That's another invalid XPath. Be sure to check the Developer Console as these are being reported as warnings. You want something like "../../streetDates/@sunset".

        Comment


          #5
          Yes indeed! Thank you again for the wonderful help!
          Works now, just as you have written.

          Comment

          Working...
          X