W3C

Assigning Media Types to Binary Data in XML

Working Draft 28 March 2004

This version:
XML-Media-Types.html
Latest version:
XML-Media-Types.html
Editors:
Anish Karmarkar, Oracle Corporation
Umit Yalcinalp, Oracle Corporation

Abstract

This document addresses the ability to declare the specific media type that is associated with binary data in an XML document. It is expected that the additional information on the media type will be used for optimizing the handling of binary data that is part of a message.

Status of this Document

This is a draft document prepared for review purposes only. This document is published by the joint media-types task force of [WSD WG] and [XMLP WG] in the [WS Activity].

Table of Contents

1 Introduction
    1.1 Notational Conventions
    1.2 Requirements
2 Attributes for Declaring Media Types
    2.1 mediaType attribute component
    2.2 acceptedMediaType attribute component
3 Declaring media types for binary data
    3.1 Role of xmlmime:acceptedMediaType attribute
4 References

Appendices

A Acknowledgements
B Appendix Attribute Schema


1 Introduction

Data sent and received over the Web typically uses the the MIME media type defined by [rfc2046], as the type system. For example, "image/jpeg", "application/pdf". As Web services get widely deployed, there is a need to indicate the media type of the XML content in the messages sent and received by Web services. There is also a need to express the media type information using [XML Schema: Datatypes], which is the type system used by [WSDL 2.0 Part 1] to describe Web services. This would allow Web services to utilize the widely deployed and supported MIME media type infrastructure.

[XOP] and [MTOM] enables one to serialize binary content (an element information item of type xs:base64Binary) in an optimized way using MIME packaging. There is a desire to specify the media type information of such binary data in a standard way in the [XML Information Set] and not just in the optimized serialization of that Infoset.

This document specifies:

1.1 Notational Conventions

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [rfc2119].

This specification uses properties from the XML Information Set, see [XML Information Set]. Such properties are denoted by square brackets, e.g. [namespace name].

This specification uses namespace prefixes that are listed in Table 1. Note that the choice of any namespace prefix is arbitrary and not semantically significant (see [XML Information Set]).

Table 1. Prefixes and Namespaces used in this specification
Prefix Namespace Definition
xmime "http://www.w3.org/@@@@/@@/xmlmime" Defined by this specification
wsdl "http://www.w3.org/@@@@/@@/wsdl" Defined by the WSDL 2.0 specification. A normative XML Schema [XML Schema: Structures], [XML Schema: Datatypes] document for the "http://www.w3.org/@@@@/@@/wsdl" namespace can be found at http://www.w3.org/@@@@/@@/wsdl.
xs "http://www.w3.org/2001/XMLSchema" Defined in the W3C XML Schema specification [XML Schema: Structures], [XML Schema: Datatypes].

Namespace names of the general form "http://example.org/..." and "http://example.com/..." represent application or context-dependent URIs [IETF RFC 2396].

Issue (wsdl-schema-ref):

Editorial Issue: Publishing WSDL 2.0 schema

Source: We need a WSDL 2.0 published schema to refer to to fix the table"

Resolution:

None recorded.

1.2 Requirements

This section describes the set of requirements that this document addresses.

  • Define how to indicate the media type of binary data in an XML document using XML schema, in particular using xs:base64Binary data type. This is meta-data that may, but not required to, be used by tools to infer the specific media type of binary data.
  • Define how to indicate the accepted media type of binary data that use the schema. This information is needed define the set of media types that a binary type may be. For example, an application may be willing to indicate that binary data represents an image, but leaves it to a document to further specify whether it is jpeg, gif, etc. This information is meta-data to indicate the set of media types that binary data may have and is not required to be present.
  • Define the acceptable format of media type values.
  • Define the relationship between the accepted and the actual value of the media types declared for binary data in XML documents.

2 Attributes for Declaring Media Types

This section defines two global attribute components for declaring the media type of binary data in XML Schema to address the requirements (1) and (2) above. Their usage is addressed in Section 3 Declaring media types for binary data.

2.1 mediaType attribute component

Attribute declaration for the mediaType attribute specifies the following Infoset properties.

Table 2. Properties of the mediaType attribute component
Property Value
{name} mediaType
{target namespace} http://www.w3.org/@@@@/@@/xmlmime;
{type definition} xs:string
{scope} global

The content model for the mediaType is an IANA media type token.

The value of the mediaType attribute component MUST be the name of a IANA media type token, e.g."image/jpeg".

Issue (mediaType-content-model):

Allowing other choices for mediaType values

Source: Should other choices be allowed to represent media-type values? Even if allowed, should this specification utilize them?

Resolution:

None recorded.

2.2 acceptedMediaType attribute component

Attribute declaration for the acceptedMediaType attribute specifies the following Infoset properties:

Table 3. Properties of the acceptedMediaType attribute component"
Property Value
{name} acceptedMediaType
{target namespace} http://www.w3.org/@@@@/@@/xmlmime
{type} xs:string
{scope} global

The value that the type attribute component must follow the production rules defined by HTTP 1.1 specification, Section 14.1 [IETF RFC 2616].

The value of the mediaType attribute SHOULD be allowed by the acceptedMediaType, if specified in the schema.

Issue (wild-cards-for-mediatype-values):

Should media-type values allow wild cards

Source: HTTP/MIME allow wildcards for declaring accepted media-types. Should this specification also allow wildcards for acceptedMediaTypes and/or mediaType attribute values, such as "image/*"?. There is already an issue recorded for this problem by XMLP as stated in XMLP Issue 443

Resolution:

None recorded.

Issue (production-rules):

Production Rules

Source: Depending on the resolution of the previous issue, the production rules in defining acceptable values as they include "Accept:" token as part of the value in [IETF RFC 2616]. The appendix schema therefore uses the current value defined by the [PASWA] document to reflect this in the schema.

Resolution:

None recorded.

3 Declaring media types for binary data

Documents that want to utilize additional media type information SHOULD denote this by using a binary element information item. A binary element information item is an element information item defined with the following additional Infoset properties.

The mediaType attribute information item allows applications that want to interpret or optimize the binary data defined by a binary element information item and should be considered meta-data. The presence of the xmlmime:mediaType attribute does not change the value of the element.

Example:


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://example.com/thisexample"
           targetNamespace="http://example.com/thisexample">

<xs:import namespace="http://www.w3.org/@@@@/@@/xmlmime"
    schemaLocation="http://www.w3.org/@@@@/@@/xmlmime"/>


<xs:complexType name="Picture">
   <xs:simpleContent>
       <xs:extension base="xs:base64Binary" >
           <xs:attribute ref="xmlmime:mediaType" use="optional" />
       </xs:extension>
   </xs:simpleContent>
</xs:complexType>

</xs:element name="companyPicture" type="tns:Picture"/>

</xs:schema>

3.1 Role of xmlmime:acceptedMediaType attribute

The acceptedMediaType attribute is for decorating the schema by using extensibility to indicate the accepted range of values for xmlmime:mediaType attribute only. The xmlmime:acceptedMediaType attribute addresses Requirement (2).

Note:

Alternative ways of indicating this meta-data has been covered and discussed at the WSD September Meeting in detail [WSDL September 2003 Face to Face Meeting]. The writeup captures the conclusions of this discussion by utilizing an attribute to designate the media type.

Applications that need to specify acceptable media types SHOULD use the attribute when declaring binary elements to declare the range of acceptable values. The decoration only applies as a hint for the binary element information items in the Infoset. Therefore, it is used in conjunction with the declaration of binary element information items in the schema. If xmlmime:acceptedMediaType attribute is not used, the value "*/*" SHOULD be assumed.

Example:


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://example.com/thisexample"
           targetNamespace="http://example.com/thisexample">

<xs:import namespace="http://www.w3.org/@@@@/@@/xmlmime"
    schemaLocation="http://www.w3.org/@@@@/@@/xmlmime"/>


<xs:complexType name="Picture">
   <xs:simpleContent>
       <xs:extension base="xs:base64Binary" >
           <xs:attribute ref="xmlmime:mediaType" use="optional" />
       </xs:extension>
   </xs:simpleContent>
</xs:complexType>

</xs:element name="companyPicture" type="tns:Picture" 
             xmlmime:acceptMediaType="image/*"/>

</xs:schema>

4 References

WS Activity
Web Services Activity. (See http://www.w3.org/2002/ws/Activity.html.)
WSD WG
Web Services Description Working Group (See http://www.w3.org/2002/ws/desc/.)
XMLP WG
XML Protocol Working Group (See http://www.w3.org/2000/xp/Group/.)
XMLP Archive
XML Protocol Discussion Archive (See http://lists.w3.org/Archives/Public/xml-dist-app/.)
XML Schema: Structures
XML Schema Part 1: Structures, H. Thompson, D. Beech, M. Maloney, and N. Mendelsohn, Editors. World Wide Web Consortium, 2 May 2001. This version of the XML Schema Part 1 Recommendation is http://www.w3.org/TR/2001/REC-xmlschema-1-20010502. The latest version of XML Schema Part 1 is available at http://www.w3.org/TR/xmlschema-1. (See http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/.)
XML Schema: Datatypes
XML Schema Part 2: Datatypes, P. Byron and A. Malhotra, Editors. World Wide Web Consortium, 2 May 2001. This version of the XML Schema Part 2 Recommendation is http://www.w3.org/TR/2001/REC-xmlschema-2-20010502. The latest version of XML Schema Part 2 is available at http://www.w3.org/TR/xmlschema-2. (See http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/.)
IETF RFC 2396
Uniform Resource Identifiers (URI): Generic Syntax, T. Berners-Lee, R. Fielding, L. Masinter, Authors. Internet Engineering Task Force, August 1998. Available at http://www.ietf.org/rfc/rfc2396.txt. (See http://www.ietf.org/rfc/rfc2396.txt.)
IETF RFC 2046
RFC 2046 - Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types, N. Freed, N. Borenstein, November 1996. Available at http://www.faqs.org/rfcs/rfc2046.html (See .)
IETF RFC 2616
Hypertext Transfer Protocol--HTTP 1.1R. Fieldingm, J. Gettys, J. Mogul, H. Frystyk, L. Masinter, P. Leach, T. Berners-Lee, Authors, W3C/MIT, June 1999. Available at http://www.w3.org/Protocols/rfc2616/rfc2616.html. (See http://www.w3.org/Protocols/rfc2616/rfc2616.html.)
IETF RFC 2119
Key words for use in RFCs to Indicate Requirement Levels, S. Bradner, Author. Internet Engineering Task Force, June 1999. Available at http://www.ietf.org/rfc/rfc2119.txt. (See http://www.ietf.org/rfc/rfc2119.txt.)
XML Information Set
XML Information Set, J. Cowan and R. Tobin, Editors. World Wide Web Consortium, 24 October 2001. This version of the XML Information Set Recommendation is http://www.w3.org/TR/2001/REC-xml-infoset-20011024. The latest version of XML Information Set is available at http://www.w3.org/TR/xml-infoset. (See http://www.w3.org/TR/2001/REC-xml-infoset-20011024.)
WSDL September 2003 Face to Face Meeting
WSDL WG September Face2Face Meeting Minutes, is available at http://lists.w3.org/Archives/Public/www-ws-desc/2003Sep/0218.html and contains other presentations. (See http://lists.w3.org/Archives/Public/www-ws-desc/2003Sep/0218.html.)
WSDL 2.0 Part 1
Web Services Description Language (WSDL) Version 2.0 Part 1: Core Language. Roberto Chinnici, Martin Gudgin, Jean-Jacques Moreau, Jeffrey Schlimmer, Sanjiva Weerawarana, World Wide Web Consortium, W3C Working Draft 26 March 2004 (See http://www.w3.org/TR/2004/WD-wsdl20-20040326/.)
XOP
XML-binary Optimized Packaging, Noah Mendelsohn, Mark Nottingham, Herve Ruellan, W3C Working Draft 09 February 2004 (See http://www.w3.org/TR/2004/WD-xop10-20040209/.)
MTOM
SOAP Message Transmission Optimization Mechanism Noah Mendelsohn, Mark Nottingham, Herve Ruellan, W3C Working Draft 09 February 2004 (See http://www.w3.org/TR/2004/WD-soap12-mtom-20040209/.)
PASWA
Proposed Infoset Addendum to SOAP Messages with Attachments Adam Bosworth, Don Box, Martin Gudgin, Mark Jones, Franz-Josef Fritz, Amy Lewis, Jean-Jacques Moreau, Mark Nottingham, David Orchard, Herve Ruellan, Jeffrey Schlimmer, Volker Wiechers, Version 0.61 draft is available at http://www.gotdotnet.com/team/jeffsch/paswa/paswa61.html (See http://www.gotdotnet.com/team/jeffsch/paswa/paswa61.html.)

A Acknowledgements

This note is developed by the participants of the joint media types task force formed by WSD and XMLP working groups. Participants are TBD.

B Appendix Attribute Schema

Note:

The following definitions are taken from [PASWA].


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://www.w3.org/@@@@/@@/xmlmime"
           targetNamespace="http://www.w3.org/@@@@/@@/xmlmime" >

<xs:attribute name="mediaType" >
    <xs:simpleType>
      <xs:restriction base="xs:string" >
      <xs:pattern value="(text|application|image|audio|video|model|multipart|message|x-[-.a-z0-9]+)/[a-z0-9]
              [-.+a-z0-9]+(;\s?.+=.+)*" />
      </xs:restriction>
    </xs:simpleType>
</xs:attribute>

<xs:attribute name="acceptMediaType" >
    <xs:simpleType>
      <xs:restriction base="xs:string" >
        <xs:pattern value="(text|application|image|audio|video|model|multipart|message|x-[-.a-z0-9]+)/
        [a-z0-9][-.+a-z0-9]+(;p=(1\.0|0\.\d+))?" />
      </xs:restriction>
    </xs:simpleType>
</xs:attribute>

</xs:schema>