NOTE-xml-media-types-20050504 33.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org" />
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8" />
<title>Describing Media Content of Binary Data in XML</title>

<style type="text/css">
/*<![CDATA[*/
code           { font-family: monospace; }

div.constraint,
div.issue,
div.note,
div.notice     { margin-left: 2em; }

ol.enumar      { list-style-type: decimal; }
ol.enumla      { list-style-type: lower-alpha; }
ol.enumlr      { list-style-type: lower-roman; }
ol.enumua      { list-style-type: upper-alpha; }
ol.enumur      { list-style-type: upper-roman; }


div.exampleInner pre { margin-left: 1em;
                       margin-top: 0em; margin-bottom: 0em}
div.exampleOuter {border: 4px double gray;
                  margin: 0em; padding: 0em}
div.exampleInner { background-color: #d5dee3;
                   border-top-width: 4px;
                   border-top-style: double;
                   border-top-color: #d3d3d3;
                   border-bottom-width: 4px;
                   border-bottom-style: double;
                   border-bottom-color: #d3d3d3;
                   padding: 4px; margin: 0em }
div.exampleWrapper { margin: 4px }
div.exampleHeader { font-weight: bold;
                    margin: 4px}
/*]]>*/
</style>
<link rel="stylesheet" type="text/css" href=
"http://www.w3.org/StyleSheets/TR/W3C-WG-NOTE.css" />
</head>
<body>
<div class="head">
<p><a href="http://www.w3.org/"><img src=
"http://www.w3.org/Icons/w3c_home" alt="W3C" height="48" width=
"72" /></a></p>
<h1><a name="title" id="title"></a>Describing Media Content of
Binary Data in XML</h1>
<h2><a name="w3c-doctype" id="w3c-doctype"></a>W3C Working Group
Note 4 May 2005</h2>
<dl>
<dt>This version:</dt>
<dd><a href=
"http://www.w3.org/TR/2005/NOTE-xml-media-types-20050504">http://www.w3.org/TR/2005/NOTE-xml-media-types-20050504</a></dd>
<dt>Latest version:</dt>
<dd><a href=
"http://www.w3.org/TR/xml-media-types">http://www.w3.org/TR/xml-media-types</a></dd>
<dt>Previous version:</dt>
<dd><a href=
"http://www.w3.org/TR/2005/NOTE-xml-media-types-20050502">http://www.w3.org/TR/2005/NOTE-xml-media-types-20050502</a></dd>
<dt>Editors:</dt>
<dd>Anish Karmarkar, Oracle</dd>
<dd>Ümit Yalçınalp, SAP</dd>
</dl>
<p class="copyright"><a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>&nbsp;©&nbsp;2005&nbsp;<a href="http://www.w3.org/"><acronym title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup>
(<a href="http://www.csail.mit.edu/"><acronym title=
"Massachusetts Institute of Technology">MIT</acronym></a>, <a href=
"http://www.ercim.org/"><acronym title=
"European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
W3C <a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a href=
"http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
</div>
<hr />
<div>
<h2><a name="abstract" id="abstract"></a>Abstract</h2>
<p>This document addresses the need to indicate the content-type
associated with binary element content in an XML document and the
need to specify, in XML Schema, the expected content-type(s)
associated with binary element content. It is expected that the
additional information about the content-type will be used for
optimizing the handling of binary data that is part of a Web
services message.</p>
</div>
<div>
<h2><a name="status" id="status"></a>Status of this Document</h2>
<p><em>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 <a href=
"http://www.w3.org/TR/">W3C technical reports index</a> at
http://www.w3.org/TR/.</em></p>
<p>This document is a <a href=
"http://www.w3.org/2004/02/Process-20040205/tr.html#q74">W3C
Working Group Note</a>. This document includes the resolution of
the comments received on the <a href=
"http://www.w3.org/TR/2004/WD-xml-media-types-20041102/">Last Call
Working Draft</a> previously published. The comments on this
document and their resolution can be found in the <a href=
"http://dev.w3.org/cvsweb/%7Echeckout%7E/2002/ws/desc/issues/wsd-issues.html">
Web Services Description Working Group's issues list</a>.</p>
<p>There is no technical difference between this document and the 2
May 2005 version; the acknowledgement section has been updated to
thank external contributors. A <a href="diff.html">diff-marked
version against the previous version of this document</a> is
available.</p>
<p>It has been produced jointly by the <a href=
"http://www.w3.org/2000/xp/Group/">XML Protocol Working Group</a>,
and the <a href="http://www.w3.org/2002/ws/desc/">Web Services
Description Working Group</a>, which are part of the <a href=
"http://www.w3.org/2002/ws/Activity">Web Services Activity</a>.</p>
<p>No further work on this topic is planned at this point. Errors
in this document can be reported to the public <a href=
"mailto:public-ws-media-types@w3.org">public-ws-media-types@w3.org</a>
mailing list (<a href=
"http://lists.w3.org/Archives/Public/public-ws-media-types/">public
archive</a>).</p>
<p>Publication as a Working Group Note 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.</p>
</div>
<div class="toc">
<h2><a name="contents" id="contents"></a>Table of Contents</h2>
<p class="toc">1 <a href="#introduction">Introduction</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;1.1 <a href="#notational">Notational
Conventions</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;1.2 <a href=
"#requirements">Requirements</a><br />
2 <a href="#declaration">Attributes for Declaring
Content-Type</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;2.1 <a href=
"#contentType">xmime:contentType Attribute</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;2.2 <a href=
"#expectedContentTypes">xmime:expectedContentTypes
Attribute</a><br />
3 <a href="#usage">Declaring Content-Type for Binary Data</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;3.1 <a href="#role">Role of
xmime:expectedContentTypes Schema Annotation Attribute</a><br />
4 <a href="#more-ex">Examples</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;4.1 <a href="#static">Binary Data with
Known Media Type</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;4.2 <a href="#example-with-q-param">Binary
Data with Preferred Media Type</a><br />
5 <a href="#normative-references">Normative References</a><br />
6 <a href="#informative-references">Informative
References</a><br /></p>
<h3><a name="appendices" id="appendices"></a>Appendices</h3>
<p class="toc">A <a href="#ack">Acknowledgements</a><br />
B <a href="#schema">Schema</a><br /></p>
</div>
<hr />
<div class="body">
<div class="div1">
<h2><a name="introduction" id="introduction"></a>1
Introduction</h2>
<p>Data sent and received over the Web typically uses the MIME
media type defined by <a href="#rfc2046">[IETF RFC 2046]</a>, as
the type system. For example, "image/jpeg", "application/pdf".
There is a need to indicate the content-type of the XML element
content, for example, in messages sent and received by Web
services. There is also a need to express the content-type
information using <a href="#XMLSchemaP2">[XML Schema:
Datatypes]</a> and <a href="#XMLSchemaP2">[XML Schema:
Datatypes]</a>, which is the type system used by <a href=
"#wsdl20part1">[WSDL 2.0 Part 1]</a>. This would allow XML-based
applications, such as Web services, to utilize the widely deployed
and supported MIME media type infrastructure.</p>
<p><a href="#XOP">[XOP]</a> and <a href="#MTOM">[MTOM]</a> enables
one to serialize binary content (element content that is in a
canonical lexical representation of the <em>xs:base64Binary</em>
type) in an optimized way using MIME packaging. There is a desire
to specify the content-type information of such binary element
content in a standard way in the <a href="#XMLInfoSet">[XML
Information Set]</a> and not just in the optimized serialization of
that Infoset.</p>
<p>This document specifies:</p>
<ul>
<li>
<p>An attribute (<em>xmime:contentType</em>) to indicate the
content-type of an XML element content whose type is
<em>xs:base64Binary</em> or <em>xs:hexBinary</em>. The value of the
attribute is a valid content-type string (e.g., "text/xml;
charset=utf-16"). This attribute specifies the content-type of the
element content on which it occurs.</p>
</li>
<li>
<p>A XML Schema annotation attribute
(<em>xmime:expectedContentTypes</em>) to indicate, in XML Schema,
the expected content-type(s) for an element content whose type is
<em>xs:base64Binary</em> or <em>xs:hexBinary</em>.</p>
</li>
</ul>
<p>The XML Schema annotation, <em>xmime:expectedContentTypes</em>,
specifies the expected range of values for the
<em>xmime:contentType</em> attribute and the expected range of
content-type for the binary element content.</p>
<p>Note that the use of this mechanism, in particular the
<em>xmime:contentType</em> attribute, does not require the
implementation, in whole or in part, of XML Schema. In the absence
of XML Schema the type information (xs:base64Binary or
xs:hexBinary) may have to be provided via other mechanisms; for
example, using <em>xsi:type</em>.</p>
<div class="div2">
<h3><a name="notational" id="notational"></a>1.1 Notational
Conventions</h3>
<p>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 <a href=
"#rfc2119">[IETF RFC 2119]</a>.</p>
<p>This specification uses properties from the XML Information Set
(see <a href="#XMLInfoSet">[XML Information Set]</a>). Such
properties are denoted by square brackets, e.g. [namespace
name].</p>
<p>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 <a href="#XMLInfoSet">[XML
Information Set]</a>).</p>
<a name="tabnsprefixes" id="tabnsprefixes"></a>
<table border="1" summary=
"Mapping of prefixes used in this document to their associated namespace name">
<caption>Table 1. Prefixes and Namespaces used in this
specification</caption>
<tbody>
<tr>
<th>Prefix</th>
<th>Namespace</th>
<th>Definition</th>
</tr>
<tr>
<td>xmime</td>
<td>http://www.w3.org/2005/05/xmlmime</td>
<td>Defined by this specification</td>
</tr>
<tr>
<td>xs</td>
<td>"http://www.w3.org/2001/XMLSchema"</td>
<td>Defined in the W3C XML Schema specifications <a href=
"#XMLSchemaP1">[XML Schema: Structures]</a>, <a href=
"#XMLSchemaP2">[XML Schema: Datatypes]</a>.</td>
</tr>
<tr>
<td>xsi</td>
<td>"http://www.w3.org/2001/XMLSchema-instance"</td>
<td>Defined in the W3C XML Schema specification <a href=
"#XMLSchemaP1">[XML Schema: Structures]</a>.</td>
</tr>
</tbody>
</table>
<p>Namespace names of the general form "http://example.org/..." and
"http://example.com/..." represent application or context-dependent
URIs (see <a href="#rfc3986">[IETF RFC 3986]</a>).</p>
<p>All parts of this specification are normative, with the
exception of examples and sections explicitly marked as
"Non-Normative".</p>
</div>
<div class="div2">
<h3><a name="requirements" id="requirements"></a>1.2
Requirements</h3>
<p>This section describes the set of requirements that this
document addresses.</p>
<ol class="enumar">
<li>
<p>Define how to indicate the content-type of an XML element
content whose type is <em>xs:base64Binary</em> or
<em>xs:hexBinary</em>. This is meta-data that may be, but not
required to, used by tools to infer the specific content-type of
binary data.</p>
</li>
<li>
<p>Define how to indicate the expected content-type(s) of XML
element content whose type is <em>xs:base64Binary</em> or
<em>xs:hexBinary</em> in XML Schema. This information is needed to
define the set of content-type that a binary data may have. For
example, a Web services application may be willing to indicate that
the binary data represents an image, but leaves it to a document
instance to further specify whether it is "jpeg", or "gif". This
meta-data is not required to be present.</p>
</li>
<li>
<p>Define the acceptable format of content-type values.</p>
</li>
<li>
<p>Define the relationship between the expected and the actual
value of the content-type declared for binary data in XML
documents.</p>
</li>
</ol>
</div>
</div>
<div class="div1">
<h2><a name="declaration" id="declaration"></a>2 Attributes for
Declaring Content-Type</h2>
<p>This section defines two global <em>attribute information
item</em>s for declaring the content-type of binary data and
expected content-type(s) of binary data in XML Schema to address
requirements (1) and (2) above. Their usage is addressed in Section
<a href="#usage"><b>3 Declaring Content-Type for Binary
Data</b></a>.</p>
<div class="div2">
<h3><a name="contentType" id="contentType"></a>2.1
xmime:contentType Attribute</h3>
<p>The <code>xmime:contentType</code> <em>attribute information
item</em> has the following Infoset properties:</p>
<ul>
<li>
<p>A [local name] of <code>contentType</code>.</p>
</li>
<li>
<p>A [namespace name] of "http://www.w3.org/2005/05/xmlmime".</p>
</li>
</ul>
<p>The type of the <code>xmime:contentType</code> <em>attribute
information item</em> is <em>xs:string</em> with a minimum length
of three and all leading and trailing white space characters are
ignored.</p>
<p>The [normalized value] of the <code>xmime:contentType</code>
<em>attribute information item</em> MUST be a valid Content-Type
string, e.g., "image/png", "text/xml; charset=utf-16" as defined by
<a href="#rfc2045">[IETF RFC 2045]</a> and indicates the
content-type of the [owner element]. Note that [normalized value]
consists of normalized attribute value as defined by <a href=
"#XMLInfoSet">[XML Information Set]</a> and does not mean that two
equivalent values of <code>xmime:contentType</code> will
necessarily be equal.</p>
<p>The <code>xmime:contentType</code> <em>attribute information
item</em> allows Web services applications to optimize the handling
of the binary data defined by a <em>binary element information
item</em> and should be considered as meta-data. The presence of
the <code>xmime:contentType</code> attribute does not changes the
value of the element content.</p>
</div>
<div class="div2">
<h3><a name="expectedContentTypes" id=
"expectedContentTypes"></a>2.2 xmime:expectedContentTypes
Attribute</h3>
<p>The <code>xmime:expectedContentTypes</code> <em>attribute
information item</em> has the following Infoset properties:</p>
<ul>
<li>
<p>A [local name] of <code>expectedContentTypes</code>.</p>
</li>
<li>
<p>A [namespace name] of
<code>http://www.w3.org/2005/05/xmlmime</code>.</p>
</li>
</ul>
<p>The type of the <code>xmime:expectedContentTypes</code>
<em>attribute information item</em> is <em>xs:string</em>.</p>
<p>The value and the meaning of the
<code>xmime:expectedContentTypes</code> attribute is similar to the
value allowed for the <code>'Accept'</code> HTTP header defined by
HTTP 1.1 specification, Section 14.1 (see <a href="#rfc2616">[IETF
RFC 2616]</a>) and MUST follow the production rules defined in that
section except for the following:</p>
<ol class="enumar">
<li>
<p>The prefix <em>"Accept:"</em> MUST NOT be used.</p>
</li>
<li>
<p>The rule <em>qdtext</em> is changed from: <code>qdtext = &lt;any
TEXT except&lt;"&gt;&gt;</code> to: <code>qdtext = &lt;any CHAR
except&lt;"&gt;&gt;</code> This change is made to disallow
non-US-ASCII OCTETs.</p>
</li>
</ol>
<p>The <code>xmime:expectedContentTypes</code> <em>attribute
information item</em> is intended to be used as part of XML Schema
annotation for a <em>binary element information item</em>
declaration (see <a href="#usage"><b>3 Declaring Content-Type for
Binary Data</b></a>). This <em>attribute information item</em> is
meant to allow XML Schema authors to indicate the range of media
types and/or associated parameters that are acceptable for the
binary data. It serves as a static constrain on the
<code>xmime:contentType</code>. Users of this <em>attribute
information item</em> are urged to avoid using wild cards (for
example, "image/*") as it may lead to interoperability problems. If
the set of expected media types is not known, the use of
<code>xmime:expectedContentTypes</code> is NOT RECOMMENDED.</p>
</div>
</div>
<div class="div1">
<h2><a name="usage" id="usage"></a>3 Declaring Content-Type for
Binary Data</h2>
<p>Documents that want to specify additional content-type
information for binary data SHOULD denote this by using a
<em>binary element information item</em>. A <em>binary element
information item</em> is an <em>element information item</em>
defined with the following additional constraints.</p>
<ul>
<li>
<p>An OPTIONAL <code>xmime:contentType</code> <em>attribute
information item</em> as described above in <a href=
"#contentType"><b>2.1 xmime:contentType Attribute</b></a> .</p>
</li>
<li>
<p>The <em>character information items</em> comprising the
[children] of the <em>element information item</em> MUST conform to
the lexical constraints of <em>xs:base64Binary</em> or
<em>xs:hexBinary</em>.</p>
</li>
</ul>
<p>If the media type identified by the value of an
<code>xmime:contentType</code> attribute information item is a text
based media type then the value of the
<code>xmime:contentType</code> attribute information item SHOULD
include a <code>charset</code> parameter.</p>
<p>For authoring convenience, two types
<code>xmime:base64Binary</code> and <code>xmime:hexBinary</code>
are defined in <a href="#schema"><b>B Schema</b></a></p>
<div class="exampleOuter">
<div class="exampleHeader"><a name="eg-ct-required" id=
"eg-ct-required"></a>Example 1: Element with binary content and
xmime:contentType attribute</div>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0" ?&gt;
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://example.com/ct-required"
           xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
           targetNamespace="http://example.com/ct-required"&gt;

    &lt;xs:import namespace="http://www.w3.org/2005/05/xmlmime"
                schemaLocation="http://www.w3.org/2005/05/xmlmime"/&gt;

    &lt;!-- This element has binary content and requires the xmime:contentType
         attribute that indicates the content-type of the binary element --&gt;
    &lt;xs:element name="MyBinaryData"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:simpleContent&gt;
          &lt;xs:extension base="xs:base64Binary" &gt;
            &lt;xs:attribute ref="xmime:contentType" use="required"/&gt;
          &lt;/xs:extension&gt;
        &lt;/xs:simpleContent&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;

&lt;/xs:schema&gt;
        
</pre></div>
</div>
<div class="div2">
<h3><a name="role" id="role"></a>3.1 Role of
xmime:expectedContentTypes Schema Annotation Attribute</h3>
<p>The <code>xmime:expectedContentTypes</code> attribute is used
for annotating XML Schema to indicate the expected range of
content-type of the binary element content and the expected range
of values for <code>xmime:contentType</code> attribute.</p>
<p>The value of the <code>xmime:contentType</code> attribute, if
present, SHOULD be within the range specified by the
<code>xmime:expectedContentTypes</code> annotation attribute, if
specified in the schema. See Section 14.1 of <a href=
"#rfc2616">[IETF RFC 2616]</a> on how to interpret content-type
ranges that may be defined with respect to actual content. When the
<code>xmime:expectedContentTypes</code> annotation attribute
contains a wild card ("*") or a list of acceptable content-type
separated by commas (","), the schema SHOULD require the
<code>xmime:contentType</code> attribute to be present.</p>
<p>Applications that need to specify expected content-type SHOULD
use the schema annotation to declare the range of expected values.
<code>xmime:expectedContentTypes</code> annotation attribute MAY be
used in conjunction with the declaration of <em>binary element
information item</em>s or with complex type definitions that are
derived from <em>xs:base64Binary</em> or <em>xs:hexBinary</em> in
XML Schema. If the <code>xmime:expectedContentTypes</code>
annotation attribute is used in both the <em>binary element
information item</em> declaration as well as definition of the
complex type which the <em>binary element information item</em>
belongs to, then the expected range of values defined for the
<em>binary element information item</em> MUST be a subset of the
expected range of values defined for the complex type.</p>
<p>The <code>xmime:expectedContentTypes</code> annotation can be
used in conjunction with either type or element declarations.
Certain data-binding frameworks which use static type mappings can
be more specific if the <code>xmime:expectedContentTypes</code>
annotation is applied to the complexType declarations instead of
the element declarations using those types. For this reason, the
use of expectedContentTypes on element declarations using named
complex types is not recommended. An example is provided in Example
6.</p>
<p>The example below consists of a type definition,
<code>PictureType</code>, and an element declaration,
<code>Picture</code>. The <code>xmime:contentType</code> attribute
is required to be present and specifies the content-type of the
binary content. The schema annotation attribute
<code>xmime:expectedContentTypes</code> specifies that the media
type of the binary content is 'image', and the subtype name is
either 'jpeg' or 'png'.</p>
<div class="exampleOuter">
<div class="exampleHeader"><a name="eg-wildcard" id=
"eg-wildcard"></a>Example 2: Schema declaring an element with
binary content and expected media type of "image/jpeg" or
"image/png"</div>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0" ?&gt;
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://example.com/wildcard"
           xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
           targetNamespace="http://example.com/wildcard"&gt;

    &lt;xs:import namespace="http://www.w3.org/2005/05/xmlmime"
                schemaLocation="http://www.w3.org/2005/05/xmlmime"/&gt;


    &lt;xs:complexType name="PictureType"&gt;
       &lt;xs:simpleContent&gt;
           &lt;xs:restriction base="xmime:base64Binary" &gt;
               &lt;xs:attribute ref="xmime:contentType" use="required" /&gt;
           &lt;/xs:restriction&gt;
       &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;

    &lt;!-- This element designates the range of values 
         that the element definition will accept    --&gt;
    &lt;xs:element name="Picture" type="tns:PictureType" 
                xmime:expectedContentTypes="image/jpeg, image/png"/&gt;

&lt;/xs:schema&gt;
        
</pre></div>
</div>
<p>The example document instance below conforms to the element
declaration of <code>Picture</code> and specifies that the binary
content is of type "image/png".</p>
<div class="exampleOuter">
<div class="exampleHeader"><a name="eg-wildcard-instance" id=
"eg-wildcard-instance"></a>Example 3: Document instance containing
element with binary content-type "image/png"</div>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0" ?&gt;
&lt;Picture xmlns="http://example.com/wildcard"
           xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
           xmime:contentType="image/png"&gt;/aWKKapGGyQ=&lt;/Picture&gt;
        
</pre></div>
</div>
</div>
</div>
<div class="div1">
<h2><a name="more-ex" id="more-ex"></a>4 Examples</h2>
<div class="div2">
<h3><a name="static" id="static"></a>4.1 Binary Data with Known
Media Type</h3>
<p>The examples in this section consists of a binary elements whose
media type is known in advance to be "image/jpeg".</p>
<p>In <a href="#eg-static">Example</a> 4, a fixed media type is
specified by declaring it with an annotation in conjunction with
the complex type definition. The attribute
<code>xmime:contentType</code> is not used as the media type of the
binary data is know in advance.</p>
<div class="exampleOuter">
<div class="exampleHeader"><a name="eg-static" id=
"eg-static"></a>Example 4: Element with binary content, known media
type and no xmime:contentType attribute</div>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0" ?&gt;
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://example.com/know-type"
           xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
           targetNamespace="http://example.com/know-type"&gt;

    &lt;xs:import namespace="http://www.w3.org/2005/05/xmlmime"
            schemaLocation="http://www.w3.org/2005/05/xmlmime"/&gt;

    &lt;xs:simpleType name="JPEGPictureType" 
            xmime:expectedContentTypes="image/jpeg"&gt; 
        &lt;xs:restriction base="xs:base64Binary"/&gt;
    &lt;/xs:simpleType&gt;

    &lt;xs:element name="JPEGPicture" type="tns:JPEGPictureType"/&gt;

&lt;/xs:schema&gt;
        
</pre></div>
</div>
<p>In <a href="#eg-static-with-ct">Example</a> 5, a fixed media
type is specified by declaring it with an annotation in conjunction
with the element declaration. The attribute
<code>xmime:contentType</code> is optionally used in document
instances to indicate the media type of the binary data.</p>
<div class="exampleOuter">
<div class="exampleHeader"><a name="eg-static-with-ct" id=
"eg-static-with-ct"></a>Example 5: Element with binary content,
known media type and optional xmime:contentType attribute</div>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0" ?&gt;
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://example.com/know-type"
           xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
           targetNamespace="http://example.com/know-type"&gt;

    &lt;xs:import namespace="http://www.w3.org/2005/05/xmlmime"
            schemaLocation="http://www.w3.org/2005/05/xmlmime"/&gt;

    &lt;xs:element name="JPEGPicture" type="xmime:base64Binary"
            xmime:expectedContentTypes="image/jpeg" /&gt;

&lt;/xs:schema&gt;
        
</pre></div>
</div>
</div>
<div class="div2">
<h3><a name="example-with-q-param" id=
"example-with-q-param"></a>4.2 Binary Data with Preferred Media
Type</h3>
<p>This example illustrates that binary data with media type
'image/jpeg' is preferred but binary data with media type of
'image/tiff' is also allowed (with a lower preference).</p>
<div class="exampleOuter">
<div class="exampleHeader"><a name="eg-preferred" id=
"eg-preferred"></a>Example 6: Element with binary content and
preferred media type</div>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0" ?&gt;
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://example.com/preferred-type"
           xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
           targetNamespace="http://example.com/preferred-type"&gt;

    &lt;xs:import namespace="http://www.w3.org/2005/05/xmlmime"
            schemaLocation="http://www.w3.org/2005/05/xmlmime"/&gt;


    &lt;xs:complexType name="JPEGPreferredPictureType"
            xmime:expectedContentTypes="image/jpeg;q=1.0, image/tiff;q=0.8"&gt; 
        &lt;xs:simpleContent&gt;
            &lt;xs:restriction base="xmime:base64Binary" &gt;
                &lt;xs:attribute ref="xmime:contentType" use="required" /&gt;
            &lt;/xs:restriction&gt;
        &lt;/xs:simpleContent&gt;
    &lt;/xs:complexType&gt;

    &lt;xs:element name="JPEGPeferredPicture" 
            type="tns:JPEGPreferredPictureType"/&gt; 

&lt;/xs:schema&gt;
        
</pre></div>
</div>
</div>
</div>
<div class="div1">
<h2><a name="normative-references" id="normative-references"></a>5
Normative References</h2>
<dl>
<dt class="label"><a name="XMLSchemaP1" id="XMLSchemaP1"></a>XML
Schema: Structures</dt>
<dd><a href=
"http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/"><cite>XML
Schema Part 1: Structures Second Edition</cite></a>, H. Thompson,
D. Beech, M. Maloney, and N. Mendelsohn, Editors. World Wide Web
Consortium Recommendation, 28 October 2004. (See
http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/.)</dd>
<dt class="label"><a name="XMLSchemaP2" id="XMLSchemaP2"></a>XML
Schema: Datatypes</dt>
<dd><a href=
"http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/"><cite>XML
Schema Part 2: Datatypes Second Edition</cite></a>, P. Byron and A.
Malhotra, Editors. World Wide Web Consortium Recommendation, 28
October 2004. (See
http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/.)</dd>
<dt class="label"><a name="rfc3986" id="rfc3986"></a>IETF RFC
3986</dt>
<dd><a href="http://www.ietf.org/rfc/rfc3986.txt"><cite>Uniform
Resource Identifiers (URI): Generic Syntax</cite></a>, T.
Berners-Lee, R. Fielding, L. Masinter, January 2005. (See
http://www.ietf.org/rfc/rfc3986.txt.)</dd>
<dt class="label"><a name="rfc2045" id="rfc2045"></a>IETF RFC
2045</dt>
<dd><a href="http://www.ietf.org/rfc/rfc2045.txt"><cite>RFC 2045 -
Multipurpose Internet Mail Extensions (MIME) Part One: Format of
Internet Message Bodies</cite></a>, N. Freed, N. Borenstein,
November 1996. (See http://www.ietf.org/rfc/rfc2045.txt.)</dd>
<dt class="label"><a name="rfc2046" id="rfc2046"></a>IETF RFC
2046</dt>
<dd><a href="http://www.ietf.org/rfc/rfc2046.txt"><cite>RFC 2046 -
Multipurpose Internet Mail Extensions (MIME) Part Two: Media
Types</cite></a>, N. Freed, N. Borenstein, November 1996. (See
http://www.ietf.org/rfc/rfc2046.txt.)</dd>
<dt class="label"><a name="rfc2616" id="rfc2616"></a>IETF RFC
2616</dt>
<dd><a href=
"http://www.w3.org/Protocols/rfc2616/rfc2616.html"><cite>Hypertext
Transfer Protocol--HTTP 1.1</cite></a>, R. Fielding, J. Gettys, J.
Mogul, H. Frystyk, L. Masinter, P. Leach, T. Berners-Lee, June
1999. (See http://www.w3.org/Protocols/rfc2616/rfc2616.html.)</dd>
<dt class="label"><a name="rfc2119" id="rfc2119"></a>IETF RFC
2119</dt>
<dd><a href="http://www.ietf.org/rfc/rfc2119.txt"><cite>Key words
for use in RFCs to Indicate Requirement Levels</cite></a>, S.
Bradner, Author. Internet Engineering Task Force, June 1999. (See
http://www.ietf.org/rfc/rfc2119.txt.)</dd>
<dt class="label"><a name="XMLInfoSet" id="XMLInfoSet"></a>XML
Information Set</dt>
<dd><a href=
"http://www.w3.org/TR/2001/REC-xml-infoset-20011024/"><cite>XML
Information Set (Second Edition)</cite></a>, J. Cowan and R. Tobin,
World Wide Web Consortium Recommendation, 4 February 2004. (See
http://www.w3.org/TR/2001/REC-xml-infoset-20011024/.)</dd>
</dl>
</div>
<div class="div1">
<h2><a name="informative-references" id=
"informative-references"></a>6 Informative References</h2>
<dl>
<dt class="label"><a name="wsdl20part1" id="wsdl20part1"></a>WSDL
2.0 Part 1</dt>
<dd><a href=
"http://www.w3.org/TR/2004/WD-wsdl20-20040803/"><cite>Web Services
Description Language (WSDL) Version 2.0 Part 1: Core
Language</cite></a>, Roberto Chinnici, Martin Gudgin, Jean-Jacques
Moreau, Jeffrey Schlimmer, Sanjiva Weerawarana, World Wide Web
Consortium Working Draft 3 August 2004 (See
http://www.w3.org/TR/2004/WD-wsdl20-20040803/.)</dd>
<dt class="label"><a name="XOP" id="XOP"></a>XOP</dt>
<dd><a href=
"http://www.w3.org/TR/2005/REC-xop10-20050125/"><cite>XML-binary
Optimized Packaging</cite></a>, Martin Gudgin, Noah Mendelsohn,
Mark Nottingham, Herve Ruellan, W3C Recommendation, 25 January 2005
(See http://www.w3.org/TR/2005/REC-xop10-20050125/.)</dd>
<dt class="label"><a name="MTOM" id="MTOM"></a>MTOM</dt>
<dd><a href=
"http://www.w3.org/TR/2005/REC-soap12-mtom-20050125/"><cite>SOAP
Message Transmission Optimization Mechanism</cite></a>, Martin
Gudgin, Noah Mendelsohn, Mark Nottingham, Herve Ruellan, W3C
Recommendation, 25 January 2005 (See
http://www.w3.org/TR/2005/REC-soap12-mtom-20050125/.)</dd>
</dl>
</div>
</div>
<div class="back">
<div class="div1">
<h2><a name="ack" id="ack"></a>A Acknowledgements</h2>
<p>This document is developed by the participants of the joint
media types task force formed by <a href=
"http://www.w3.org/2002/ws/desc/">Web Services Description</a> and
<a href="http://www.w3.org/2000/xp/Group/">XML Protocol</a> Working
Groups. Participants of the taskforce, specifically Martin Gudgin,
and Mark Nottingham are gratefully acknowledged.</p>
<p>The authors would also like to thank the commentors, in
particular Joe Fialli, Larry Massinter, and Henry Thompson.</p>
</div>
<div class="div1">
<h2><a name="schema" id="schema"></a>B Schema</h2>
<div class="exampleInner">
<pre>
&lt;?xml version="1.0" ?&gt;
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
           targetNamespace="http://www.w3.org/2005/05/xmlmime" &gt;

  &lt;xs:attribute name="contentType"&gt;
    &lt;xs:simpleType&gt;
      &lt;xs:restriction base="xs:string" &gt;
      &lt;xs:minLength value="3" /&gt;
      &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
  &lt;/xs:attribute&gt;

  &lt;xs:attribute name="expectedContentTypes" type="xs:string" /&gt;

  &lt;xs:complexType name="base64Binary" &gt;
    &lt;xs:simpleContent&gt;
        &lt;xs:extension base="xs:base64Binary" &gt;
            &lt;xs:attribute ref="xmime:contentType" /&gt;
        &lt;/xs:extension&gt;
    &lt;/xs:simpleContent&gt;
  &lt;/xs:complexType&gt;

  &lt;xs:complexType name="hexBinary" &gt;
    &lt;xs:simpleContent&gt;
        &lt;xs:extension base="xs:hexBinary" &gt;
            &lt;xs:attribute ref="xmime:contentType" /&gt;
        &lt;/xs:extension&gt;
    &lt;/xs:simpleContent&gt;
  &lt;/xs:complexType&gt;

&lt;/xs:schema&gt;
</pre></div>
</div>
</div>
</body>
</html>