Skip to content

Instantly share code, notes, and snippets.

@kamalgill
Last active September 20, 2018 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kamalgill/14dc00c43c3a75cde2f1222394b48c85 to your computer and use it in GitHub Desktop.
Save kamalgill/14dc00c43c3a75cde2f1222394b48c85 to your computer and use it in GitHub Desktop.
AWS S3 CORS XML RelaxNG schema
<element name="CORSConfiguration" xmlns="http://relaxng.org/ns/structure/1.0">
<oneOrMore>
<element name="CORSRule">
<interleave>
<oneOrMore>
<element name="AllowedOrigin"><text /></element>
</oneOrMore>
<oneOrMore>
<element name="AllowedMethod">
<choice>
<value>GET</value>
<value>PUT</value>
<value>POST</value>
<value>DELETE</value>
<value>HEAD</value>
</choice>
</element>
</oneOrMore>
<zeroOrMore>
<element name="AllowedHeader"><text /></element>
</zeroOrMore>
<zeroOrMore>
<element name="ExposeHeader"><text /></element>
</zeroOrMore>
<optional>
<element name="MaxAgeSeconds">
<data type="nonNegativeInteger" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
</element>
</optional>
<optional>
<element name="ID"><text /></element>
</optional>
</interleave>
</element>
</oneOrMore>
</element>
@lincolnthomas
Copy link

Looks good to me!
You can also add the optional "ID" element, which is an arbitrary string up to 255 chars that identifies a rule.

The closest thing I can find to a schema is the table in http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTcors.html, which is not in any sort of schema form.

@kamalgill
Copy link
Author

Thanks for the feedback Lincoln! I've updated the schema to add the optional ID element, and I modified the MaxAgeSeconds datatype from integer to nonNegativeInteger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment