Forum Discussion

pixshatterer's avatar
9 years ago

Scene Graph node fields valid values

Hi, I have been having a rough time trying to assign a valid value to a stringArray field from XML, so far trying something like:


<MyComp
 id="comp"
 messages="[hi, hello, world, none]"
/>



... but so far I always have this in the debugger:
Warnings occurred while creating XML component CarouselItem

-- Type mismatch occurred when setting the "messages" field of a "MyComp" node

... is there a way to set those values right?

It would be awesome if documentation had samples about valid values per field type!

10 Replies

  • You know what would be awesome-er? If the error message was showing what the expected type was!
    I.e. is `messages` declared in <interface/>as "string" or what? (Apparently not string or it wouldn't object)

    Welcome to XML world, where we always feed strings to the properties but make-believe they are something else! </sarcasm>
  • TheEndless's avatar
    TheEndless
    Channel Surfer
    This this instead...
    <MyComp
      id="comp"
      messages="['hi', 'hello', 'world', 'none']"
    />
  • TheEndless's avatar
    TheEndless
    Channel Surfer
    "EnTerr" wrote:
    Pray tell - what field type would that be?  πŸ˜Ž

    The OP said he was trying to set the value of a "stringarray" field.
  • "TheEndless" wrote:
    This this instead...
    <MyComp
      id="comp"
      messages="['hi', 'hello', 'world', 'none']"
    />


    I already tried, but it didn't work πŸ˜• so I went looking around if escaping quotes would work and it did, so this was the solution:

     
    <MyComp
    id="comp"
    messages="[&quot;hi&quot;,&quot;hello&quot;,&quot;world&quot;,&quot;none&quot;]"
    />


    ... which looks awful, but so far looks like the only way :v 
  • "TheEndless" wrote:
    "EnTerr" wrote:
    Pray tell - what field type would that be?  πŸ˜Ž

    The OP said he was trying to set the value of a "stringarray" field.

    ... and btw, I ran into another issue now: I wanted to pass uri in this format as it can be used in XML components  "pkg:/locale/whatever/$$RES$$/image.png" but now it doesn't resolve those.. is there an - maybe - obvious way to accomplish that?
  • "EnTerr" wrote:
    You know what would be awesome-er? If the error message was showing what the expected type was!
    I.e. is `messages` declared in <interface/>as "string" or what? (Apparently not string or it wouldn't object)

    Welcome to XML world, where we always feed strings to the properties but make-believe they are something else! </sarcasm>

    ...well, I think it was self explanatory when I wrote it:


    Hi, I have been having a rough time trying to assign a valid value to a stringArray field...

    ... but I can be wrong πŸ™‚
  • TheEndless's avatar
    TheEndless
    Channel Surfer
    "pixshatterer" wrote:

    I already tried, but it didn't work πŸ˜• so I went looking around if escaping quotes would work and it did, so this was the solution:
    <MyComp
    id="comp"
    messages="[&quot;hi&quot;,&quot;hello&quot;,&quot;world&quot;,&quot;none&quot;]"
    />

    ... which looks awful, but so far looks like the only way :v 

    Eep!  Try flipping the quotes...
    <MyComp
     id="comp"
     messages='["hi", "hello", "world", "none"]'
    />

    XML supports single and double quotes interchangeably when wrapping attribute values.  Apparently the Roku SceneGraph parser doesn't...
  • "TheEndless" wrote:
    "pixshatterer" wrote:

    I already tried, but it didn't work πŸ˜• so I went looking around if escaping quotes would work and it did, so this was the solution:
    <MyComp
    id="comp"
    messages="[&quot;hi&quot;,&quot;hello&quot;,&quot;world&quot;,&quot;none&quot;]"
    />

    ... which looks awful, but so far looks like the only way :v 

    Eep!  Try flipping the quotes...
    <MyComp
     id="comp"
     messages='["hi", "hello", "world", "none"]'
    />

    XML supports single and double quotes interchangeably when wrapping attribute values.  Apparently the Roku SceneGraph parser doesn't...

    Awesome! that worked! I'm familiar with the XML interchangeability of single/double quotes there, but after it failed when I tried the other way around  - as you suggested too - I gave up on that.

    Thanks!