Coding

A RELAX NG compact schema for RSD

Published · 1min

I was feeling a bit bored last night and decided to write a schema for RSD in RELAX NG compact syntax. RSD is about five years old at this point, and nobody ever seems to have got around to writing one, so this might help somebody who wanted to make sure they’re producing valid RSD files:

default namespace = "http://archipelago.phrasewise.com/rsd"

# To make it explicit that these element do *not* contain any encoded HTML
# markup.
plainText = text

start = element rsd {
  attribute version { "1.0" },
  element service {
    element engineName { plainText },
    element engineLink { xsd:anyURI },
    element homePageLink { xsd:anyURI },
    element apis {
      element api {
        attribute name { text },
        attribute preferred { "true" | "false" },
        attribute apiLink { xsd:anyURI },
        attribute blogID { text },
        element settings {
          element docs { xsd:anyURI }?,
          element notes { plainText }?,
          element setting {
            attribute name { text },
            text
          }*
        }?
      }+
    }
  }
}

I’m not using xsd:boolean for the preferred attribute because it accepts 0 or false for false and 1 or true for true, whereas the spec states that it should only accept false and true.

Where this differs from the RSD spec, the spec is canonical, not this schema. However, this schema adds some rigour that the spec lacks, so where the spec is ambiguous, you can assume the schema above is correct.