3

The docs mention :XML, :JSON, and :HTML, but I have a URL that returns plain text. I'd like to write

global {
  datasource tests_executed:TEXT <- "http://saucelabs.com/rest/v1/info/counter"
}
rule how_many_tests {
  pre {
    count = datasource:tests_executed("");
    msg = "Executed #{count} tests.";
  }
  notify("Saucelabs",msg) with sticky=true;
}

Are :XML, :JSON, and :HTML the only valid formats for a datasource?

Randall Bohn
  • 2,597
  • 2
  • 16
  • 20

1 Answers1

1

XML, JSON, and HTML are the only current valid formats but if the Kynetx engine isn't able to parse the datasource as that format, it treats it as a string.

Mike Grace
  • 16,636
  • 8
  • 59
  • 79
  • Could it equivalently be said that everything is treated as ":TEXT", as it were, unless the datasource can be parsed as XML, JSON, or HTML at the programmer's indication? – Steve Nay Apr 28 '11 at 14:40
  • Yes. That is probably a better way of putting it. : ) – Mike Grace Apr 28 '11 at 14:41
  • 1
    I think the Kynetx engine will convert the data to JSON if it can, otherwise it presents it as a string. When you specify a format it helps the engine bypass some of the 'format detection' stuff. :XML tells it to try XML to JSON conversion first. :JSON tells it that no conversion should be required. :HTML tells it not to bother with any detection or conversion, just present the raw result as a string. Perhaps :RAW would be a good synonym for :HTML. – Randall Bohn Apr 29 '11 at 05:05
  • @Randall Exactly. Must have tacos. – Alex Apr 30 '11 at 01:36