W3C

Assigning Media Types to Binary Data in XML

W3C Working Draft 8 June 2004

This version:
http://www.w3.org/TR/2004/WD-xml-media-types-20040608
Latest version:
http://www.w3.org/TR/xml-media-types
Editors:
Anish Karmarkar, Oracle Corporation
Ümit Yalçınalp, Oracle Corporation

Abstract

This document addresses the need to indicate the media type associated with binary element content in an XML document and the need to specify, in XML Schema, the expected media types associated with binary element content. It is expected that the additional information about the media type will be used for optimizing the handling of binary data that is part of a Web services message.

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

This is the First Public Working Draft of the Assigning Media Types to Binary Data in XML document. It has been produced jointly by the XML Protocol Working Group, and the Web Services Description Working Group, which are part of the Web Services Activity.

The current intention of the Working Groups is to issue the final version of this specification as a Working Group Note.

This document has been produced under the 24 January 2002 Current Patent Practice as amended by the W3C Patent Policy Transition Procedure. Patent disclosures relevant to this specification may be found on the Web Services Description Working Group's patent disclosure page and the XML Protocol Working Group's patent disclosure page. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) with respect to this specification should disclose the information in accordance with section 6 of the W3C Patent Policy.

Discussion of this document takes place on the public public-ws-media-types@w3.org mailing list (public archive) of the joint media-types task force of the XML Protocol Working Group, and the Web Services Description Working Group. A list of open issues against this document is available.

Comments on this document are invited and are to be sent to the public public-ws-media-types@w3.org mailing list (public archive).

Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

Table of Contents

1 Introduction
    1.1 Notational Conventions
    1.2 Requirements
2 Attributes for Declaring Media Types
    2.1 contentType attribute
    2.2 expectedMediaType element
3 Declaring media types for binary data
    3.1 Role of expectedMediaType Schema annotation element
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 [IETF RFC 2046], 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 element 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 (element content that is in a canonical lexical representation of the xs:base64Binary type) in an optimized way using MIME packaging. There is a desire to specify the media type information of such binary element content 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 [IETF RFC 2119].

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
xmlmime http://www.w3.org/2004/06/xmlmime Defined by this specification
wsdl http://www.w3.org/2004/03/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/2004/03/wsdl namespace can be found at http://www.w3.org/2004/03/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].

1.2 Requirements

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

  • Define how to indicate the media type of an XML element content whose type is xs:base64Binary. This is meta-data that may be, but not required to, used by tools to infer the specific media type of binary data.

  • Define how to indicate the expected media type(s) of XML element content whose type is xs:baseB4Binary in XML Schema. This information is needed to define the set of media types that a binary data may have. For example, a Web services 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 meta-data is used to indicate the set of media types the binary data may have and is not required to be present.

  • Define the acceptable format of media type values.

  • Define the relationship between the expected and the actual value of the media types declared for binary data in XML documents.

2 Attributes for Declaring Media Types

This section defines a global attribute information item and an element information item 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 contentType attribute

The contentType attribute information item has the following Infoset properties:

  • A [local name] of contentType.

  • A [namespace name] of "http://www.w3.org/2004/06/xmlmime".

The type of the contentType attribute information item is xs:string.

The [normalized value] of the contentType attribute information item MUST be the name of a IANA media type token, e.g., "image/png", "text/xml; charset=utf-16".

2.2 expectedMediaType element

expectedMediaType element information item has the following Infoset properties:

  • A [local name] of expectedMediaType.

  • A [namespace name] of http://www.w3.org/2004/06/xmlmime.

The type of the expectedMediaType element information item is xs:string.

The value of the expectedMediaType element is similar to the value allowed for the 'Accept' header defined by HTTP 1.1 specification, Section 14.1 [IETF RFC 2616].

The value of the contentType attribute SHOULD be allowed by the expectedMediaType, if specified in the schema, as specified by 3 Declaring media types for binary data.

The expectedMediaType element is intended to be used as part of a Schema annotation for a binary element information item declaration (see 3 Declaring media types for binary data).

3 Declaring media types for binary data

Documents that want to specify additional media type information for binary data 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 contentType attribute information item allows Web services applications to optimize the handling of the binary data defined by a binary element information item and should be considered as meta-data. The presence of the contentType attribute does not changes the value of the element content.

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/2004/06/xmlmime"
    schemaLocation="http://www.w3.org/2004/06/xmlmime"/>


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

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

</xs:schema>

3.1 Role of expectedMediaType Schema annotation element

The expectedMediaType element is used for annotating the schema to indicate the expected range of values for contentType attribute only. The expectedMediaType element addresses Requirement (2).

Applications that need to specify expected media types SHOULD use the schema annotation element to declare the range of expected values. The annotation should be considered only as a hint. expectedMediaType is used in conjunction with the declaration of binary element information items in the schema. If expectedMediaType 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"
           xmlns:xmlmime="http://www.w3.org/2004/06/xmlmime"
           targetNamespace="http://example.com/thisexample">

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


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

<xs:element name="companyPicture" type="tns:Picture" 
    <xs:annotation>
        <xs:documentation>This element designates the range of values 
        that the declared binary type will accept 
        </xs:documentation>
        <xs:appInfo>
           <xmlmime:expectedMediaType>image/*</xmlmime:expectedMediaType>
        </xs:appInfo>
    </xs:annotation>
</xs:element>

</xs:schema>

Editorial note: ASK  
This document addresses the requirements in Issue 443 of the XML Protocol WG issues list. If this document is changed in the future in such a way that the requirements in issue 443 are not addressed, then issue 443 may be reopened by the XML Protocol WG.

4 References

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. (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. (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. (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. (See http://www.faqs.org/rfcs/rfc2046.html.)
IETF RFC 2616
Hypertext Transfer Protocol--HTTP 1.1, R. Fieldingm, J. Gettys, J. Mogul, H. Frystyk, L. Masinter, P. Leach, T. Berners-Lee, Authors, W3C/MIT, June 1999. (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. (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. (See http://www.w3.org/TR/2001/REC-xml-infoset-20011024.)
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. (See http://www.gotdotnet.com/team/jeffsch/paswa/paswa61.html.)

A Acknowledgements

This document is developed by the participants of the joint media types task force formed by Web Services Description and XML Protocol Working Groups. Participants of the taskforce, specifically Martin Gudgin, and Mark Nottingham are gratefully acknowledged.

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/2004/06/xmlmime"
           targetNamespace="http://www.w3.org/2004/06/xmlmime" >

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

<xs:element name="expectedMediaType" >
    <xs:simpleType>
      <xs:list itemType="tns:expectedMediaTypeItem" />
    </xs:simpleType>
</xs:element>

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

</xs:schema>