DJOodle
DJOodle

Reputation: 323

XML-RPC Schema .xsd

Does anyone have, or know how to edit, an XSD for XML-RPC method calls?

I found this one: MSDN Xml Rpc Schema

However it doesnt allow a valid XML-RPC case. The bit which seems off is:

<xsd:complexType name="ValueType" mixed="true">
    <xsd:choice>
        <xsd:element name="i4"            type="xsd:int" />
        <xsd:element name="int"           type="xsd:int" />
        <xsd:element name="string"        type="ASCIIString" />
        <xsd:element name="double"        type="xsd:decimal" />
        <xsd:element name="Base64"        type="xsd:base64Binary" />
        <xsd:element name="boolean"       type="NumericBoolean" />
        <xsd:element name="dateTime.iso8601" type="xsd:dateTime" />
        <xsd:element name="array"         type="ArrayType" />
        <xsd:element name="struct"        type="StructType" />
    </xsd:choice>
</xsd:complexType>

According to the XML-RPC spec, the following is valid:

...
<value>example text</value>
....

Because if no type element is provided, the text inside the <value> elements are defaulted to strings. However the above xsd would not validate it.

I tried changing it to:

<xsd:complexType mixed="true" name="ValueType">
    <xsd:choice minOccurs="0" maxOccurs="1">
        <xsd:element name="i4"            type="xsd:int" />
        <xsd:element name="int"           type="xsd:int" />
        <xsd:element name="string"        type="ASCIIString" />
        <xsd:element name="double"        type="xsd:decimal" />
        <xsd:element name="Base64"        type="xsd:base64Binary" />
        <xsd:element name="boolean"       type="NumericBoolean" />
        <xsd:element name="dateTime.iso8601" type="xsd:dateTime" />
        <xsd:element name="array"         type="ArrayType" />
        <xsd:element name="struct"        type="StructType" />
    </xsd:choice>
</xsd:complexType>

But that allows: <value>testtext<string>with more text</string></value> which shouldn't be valid according to the spec.

I'm having trouble trying to make it so the Value element can contain either data OR elements, but not a mixture of the two.

Anywho, if anyone knows how to fix the above or has a working xsd they can provide, would be really grateful.

Upvotes: 2

Views: 1959

Answers (2)

gggeek
gggeek

Reputation: 331

Some information about why it is not possible to have a normative DTD or XSD describing XML-RPC endpoints can be found at http://www.cafeconleche.org/books/xmljava/chapters/ch02s05.html.

In short: some XML-RPC constraints are impossible to describe using an XSD.

As you seem to have found out already, it is possible to use RELAX-NG to perfectly describe XML-RPC endpoints. An example such schema can be found at https://github.com/gggeek/xmlrpc-schemas

Upvotes: 0

Petru Gardea
Petru Gardea

Reputation: 21638

What you want is not describable using XSD 1.0; conceptually, what you want is a "union" of content models: text only and element only.

If you can employ other means, such as adding Schematron or moving to XSD 1.1 (poorly supported), then please update your question with additional info.

Upvotes: 1

Related Questions