WD-xmlschema-guide2versioning-20070720 70.7 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 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="EN" xml:lang="EN"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Guide to Versioning XML Languages using new XML Schema 1.1 features</title><style type="text/css">
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}

p { clear: both }

.prefix { float:left; width: 15%; background: yellow; color: black;
border: solid black thin; padding: .1em; margin-left: 2%;
margin-right: 2%;}

.principle, .constraint, .property, .practice { color: black; border:
solid black thin; padding: .1em; margin-left: 5%; margin-right: 5%; clear: none}

.principle  { background: #f7ebd7 }
.constraint { background: #becece }
.property   { background: #f7ebd7 }
.practice   { background: #dfffff }

pre em      { font-style: italic;
              font-weight: bold;
            }
</style><link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-WD.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>Guide to Versioning XML Languages using new XML Schema 1.1 features</h1>

<h2><a name="subtitle" id="subtitle"></a></h2>

<h2><a name="w3c-doctype" id="w3c-doctype"></a>W3C Working Draft 20 July 2007</h2>
<dl><dt>This version:</dt><dd>
			<a href="http://www.w3.org/TR/2007/WD-xmlschema-guide2versioning-20070720">http://www.w3.org/TR/2007/WD-xmlschema-guide2versioning-20070720</a>
		</dd><dt>Latest version:</dt><dd>
			<a href="http://www.w3.org/TR/xmlschema-guide2versioning">http://www.w3.org/TR/xmlschema-guide2versioning</a>
		</dd><dt>Previous version:</dt><dd>
   <a href="http://www.w3.org/TR/2006/WD-xmlschema-guide2versioning-20060928">http://www.w3.org/TR/2006/WD-xmlschema-guide2versioning-20060928</a>
</dd><dt>Editor:</dt><dd>David Orchard, BEA Systems, Inc. <a href="mailto:David.Orchard@BEA.com">&lt;David.Orchard@BEA.com&gt;</a></dd></dl><p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2007 <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 is a guide to versioning XML
languages using new XML Schema 1.1 mechanisms.  It shows many of the new Schema 1.1
mechanisms, provides context above the schema 1.1 WD, and solicits
reader input.</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 public working draft, published
20 July 2007, of a document which when complete is expected to become a W3C
Working Group Note.  It has been developed by the <a href="http://www.w3.org/XML/Schema">W3C XML Schema Working
Group</a>, as part of the W3C <a href="http://www.w3.org/XML/Activity">XML Activity</a>, to
illustrate the use of XML Schema 1.1 in defining XML languages.
XML Schema 1.1 introduces a number of new features intended to
make it easier to define XML languages which are flexible enough to
tolerate later revision in a forward-compatible way.
The current
draft is not complete, but it illustrates several techniques important
for the versioning of XML languages defined using XML Schema 1.1.
It will be updated to make it more complete and to reflect further
technical changes in the development of XML Schema 1.1.  
Note that some examples given here illustrate constructs
not included in previous public working drafts of 
XML Schema 1.1; the examples reflect the Working Group's
expectations about the content of the next working draft
of XML Schema 1.1.
The Working
Group has consensus that this draft should be published, but does not
necessarily have consensus on every aspect of the exposition.</p>
<p>Please send comments on this document to
the archived versioning mailing list <a href="mailto:public-xml-versioning@w3.org">public-xml-versioning@w3.org</a> 
(<a href="http://lists.w3.org/Archives/Public/public-xml-versioning/">archive</a>).</p>
<p>The English version of this specification is the only officially
maintained
version. Information about translations of this document is available
at <a href="http://www.w3.org/2003/03/Translations/byTechnology?technology=xmlschema">http://www.w3.org/2003/03/Translations/byTechnology?technology=xmlschema</a>.</p>
<p>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.</p>
<p>This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</a>. The group does not expect this document
to become a W3C Recommendation. 
W3C
maintains a <a href="http://www.w3.org/2004/01/pp-impl/19482/status">public list of
any patent disclosures</a> made in connection with the deliverables
of the group; that page also includes instructions for disclosing a
patent. An individual who has actual knowledge of a patent which the
individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the W3C Patent Policy</a>. </p>
</div>
<div class="toc">
<h2><a name="contents" id="contents"></a>Table of Contents</h2>
<div class="toc">1 <a href="#introduction">Introduction</a><br />
2 <a href="#wildcard">Wildcards</a><br />
3 <a href="#allgroup">Updated All Group</a><br />
4 <a href="#negativewildcard">Negative Wildcards</a><br />
5 <a href="#id90153">Multiple Namespaces</a><br />
6 <a href="#openContent">Default Open Content</a><br />
    6.1 <a href="#id90223">Schema wide Open Content</a><br />
    6.2 <a href="#id90258">ComplexType level open content</a><br />
7 <a href="#id90288">Not in Schema wildcard</a><br />
8 <a href="#id90340">Type extension and restriction with wildcards</a><br />
    8.1 <a href="#id90351">Extension</a><br />
    8.2 <a href="#id90441">Restriction</a><br />
    8.3 <a href="#id90510">Allowing Extension or Restriction with wildcards</a><br />
    8.4 <a href="#id90521">Producer side considerations for NIS</a><br />
9 <a href="#id90605">Fallback to Declared Type</a><br />
10 <a href="#id90662">Appendix: Some mechanisms not in Schema 1.0 or 1.1</a><br />
    10.1 <a href="#id90679">Extension replacing wildcard</a><br />
    10.2 <a href="#id90736">Fallback</a><br />
    10.3 <a href="#id90773">FallbackElement in instance</a><br />
        10.3.1 <a href="#id90836">Multiple Versions with Fallback Type</a><br />
    10.4 <a href="#id90878">Version numbers</a><br />
    10.5 <a href="#id90891">MustUnderstand</a><br />
11 <a href="#id90899">References</a><br />
12 <a href="#ack">Acknowledgements</a><br />
</div>
</div>
<hr /><div class="body">
<div class="div1">

<h2><a name="introduction" id="introduction"></a>1 Introduction</h2>
<p>This document, Guide to Versioning XML Languages using new XML Schema 1.1 Features, is intended to provide an easily approachable description of the new versioning features in the XML Schema definition language, and should be used alongside the formal descriptions of the language contained in Parts 1 and 2 of the XML Schema Recommendation. The intended audience of this document includes application developers whose programs read and write schema documents, and schema authors who need to know about the features of the language, especially features that provide functionality above and beyond what is provided by DTDs. The text assumes that you have a basic understanding of XML, Namespaces in XML, and XML Schema.  </p>
<p>The guide is a non-normative document, which means that it does not provide a definitive (from the W3C's point of view) specification of the XML Schema language. The examples and other explanatory material in this document are provided to help you understand XML Schema, but they may not always provide definitive answers. In such cases, you will need to refer to the XML Schema specification.  To help you do this, we provide many links pointing to the relevant parts of the specification. </p>
<p>The W3C Technical Architecture Group is working on a <a href="#TAGXMLVersioningPart1">[TAG Finding Versioning Part 1]</a> finding that provides a language-independent rationale and description of languages, extensibility, versioning, and compatibility, and an XML specific finding <a href="#TAGXMLVersioningXML">[TAG Finding Versioning XML]</a>.  They are suggested reading for these topics.  </p>
<p>Creating and using multiple versions of a language is common and useful.  As described in the Draft TAG finding, extensibility is a key contributor to versioning.  It can enable forwards and backwards compatible versioning.  The majority of this guide focuses on <a href="#XMLSchema11Part1">[XML Schema 1.1 Part 1]</a> extensibility techniques that enable forwards-compatible versioning.  In schema terms, this is when a schema processor with an older schema can process and validate an instance that is valid against a newer schema.  This does not include any material that describes versioning in schema 1.0.  Every example shown is in Schema 1.1 and is illegal in Schema 1.0 unless otherwise stated.</p>
<p>This guide focuses on describing the different ways extra content can be added to create new versions of a schema.  These different ways reflects different conditions faced by schema authors. These conditions may manifest themselves as technical constraints (e.g. location of extension points where content can be added) or non-technical constraints (e.g. ownership over a schema).   </p>
<p>XML Schema 1.1 contains a number of new extensibility mechanisms.   The ones described in the March 2007 draft are:</p>
<ol class="enumar"><li><p>Weak wildcards - permits wildcards adjacent to optional elements</p>
</li><li><p>Updated All Group - wildcards within All Group</p>
</li><li><p>Negative wildcard - exclude specific namespaces and names</p>
</li><li><p>Fallback To Declared Type - use declared type if  xsi:type is unknown</p>
</li><li><p>Auto-insertion of wildcards</p>
</li><li><p>Not in Schema wildcard - a wildcard that allows anything not defined in the current schema</p>
</li></ol><p>This document does not discuss the Post Schema Validation Infoset properties as that would result in a significantly less readable document.</p>
<p>This document does not discuss versioning of the schema language itself, such as how a Schema 1.0 processor should treat any of the Schema 1.1 constructs.  This document only focuses on the increased versioning capabilities for users of Schema 1.1.</p>
</div>
<div class="div1">

<h2><a name="wildcard" id="wildcard"></a>2 Wildcards</h2>
<p>Let us start by considering a name instance.  It describes a namens:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id89869" id="id89869"></a>Example 1: Simple name instance</div><div class="exampleInner">
<pre>&lt;personName xmlns="http://www.example.org/ns/personName/1"&gt;
  &lt;given&gt;Dave&lt;/given&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
&lt;/personName&gt;</pre></div>
</div>
<p>As described in the Draft TAG finding, extensibility in the type is desired for versioning.  Schema wildcards are a significant mechanism for allowing extensibility.  Using XML Schema 1.1, the name owner might like to write a schema such as:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id89897" id="id89897"></a>Example 2: Simple name with wildcard</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1"
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
       &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
      &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
  &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>The previous Schema is legal in XML Schema 1.1 but illegal in XML Schema 1.0 because of the Unique Particle Attribution Rule.  The UPA constraint in schemas specifes that as a schema processor must always know which piece of the type delcaration (what the Recommendation calls a particle) is going to be used to validate each piece.   In Schema 1.1, that rule is loosened, to always give priority to matching on explicit references to an element, in preference to matching a wildcard (&lt;any/&gt;).</p>
<p>One possible extension is adding a middle.  It describes a namens:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id89916" id="id89916"></a>Example 3: Simple name instance with middle</div><div class="exampleInner">
<pre>&lt;personName xmlns="http://www.example.org/ns/personName/1"&gt;
  &lt;given&gt;Dave&lt;/given&gt;
  &lt;middle&gt;Bryce&lt;/middle&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
&lt;/personName&gt;</pre></div>
</div>
<p>The next version of the schema with middle name added might look like:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id89937" id="id89937"></a>Example 4: New name with illegal wildcard complete replacement of schema</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified"
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;xs:element name="middle" type="xs:string" minOccurs="0"/&gt;
      &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
      &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
   
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>This schema is illegal in Schema 1.0 and remains illegal in Schema 1.1 because there is a UPA (Unique Particle Attribution) rule violation with the additional optional middle and wildcard.  In this case, an extension that was not a &lt;middle&gt; could match against the wildcard after given or before family.  </p>
<p>However, Schema 1.1 has partially reduced the UPA constraints such that the following is now legal, and it will valid the previous 2 instances: </p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id89967" id="id89967"></a>Example 5: New name with legal wildcard replacing old name</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified"
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;xs:sequence minOccurs="0"&gt;
          &lt;xs:element name="middle" type="xs:string" /&gt;
          &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
      &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
    
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>Alternatively, each of the elements could be wrapped in a sequence followed by a wildcard:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id89985" id="id89985"></a>Example 6: New name with every element wrapped in a sequence and a wildcard</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified"
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;xs:sequence&gt; 
         &lt;xs:element name="given" type="xs:string"/&gt;
         &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:sequence minOccurs="0"&gt;
          &lt;xs:element name="middle" type="xs:string" /&gt;
          &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:sequence&gt;
         &lt;xs:element name="family" type="xs:string"/&gt;
         &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
    
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>Another alternative is each of the elements could be a reference to a model group that is the sequence of the element followed by a wildcard:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90004" id="id90004"></a>Example 7: New name with every element a reference</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
  &lt;xs:group name="given"&gt;
       &lt;xs:sequence&gt; 
         &lt;xs:element name="given" type="xs:string"/&gt;
         &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;/xs:sequence&gt;
   &lt;/xs:group&gt;
   &lt;xs:group name="middle"&gt;
      &lt;xs:sequence&gt;
          &lt;xs:element name="middle" type="xs:string" /&gt;
          &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;/xs:sequence&gt;
   &lt;/xs:group&gt;
   &lt;xs:group name="family"&gt;
       &lt;xs:sequence&gt;
         &lt;xs:element name="family" type="xs:string"/&gt;
         &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;/xs:sequence&gt;
   &lt;/xs:group&gt;
   
   &lt;xs:complexType name="nameType"&gt; 
     &lt;xs:sequence&gt; 
       &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt; 
       &lt;xs:group ref="namens:given"/&gt; 
       &lt;xs:group ref="namens:middle" minOccurs="0"/&gt; 
       &lt;xs:group ref="namens:family"/&gt; 
     &lt;/xs:sequence&gt; 
     &lt;xs:anyAttribute/&gt; 
   &lt;/xs:complexType&gt;
  
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>The wildcard construct enables authors to create schemas that are both forwards and backwards-compatible.  The new schema is backwards compatible because it will validate old and new instances.  The exception is instances that have content that is legal in the wildcard but not in the new content.  An example might be a middle name that has element children  or digits as content.   However, that scenario means that an author created a middle name instance in the name namespace according to one schema AND an author defined a new name in the same namespace according to a different schema.  Arguably there is an authority over the namespace that will prevent such clashes and so in practice this exception won't happen.  Alternatively, we can make a slightly different compatibility guarantee, which is the new schema is backwards compatible with validate old and new instance where new instances do not have any extensions in the defined namespaces.  The old schema is forwards compatible because it will validate old and new instances - of course it sees these as current and future instances.</p>
<p>The new schema is created by the replacement of a repeating wildcard in the original, with an optional-wildcard, optional-element, optional-wildcard sequence, in the later schema. The new schema explicitly states the entire new content model, including everything from the original schema as well as the new explicit declaration for middle, and for that reason we call it a "Complete Respecification" of the type. </p>
<p>The new type declared above using wildcards could be declared as an explicit &lt;xs:restriction/&gt; of the original type, because every document accepted by the new type is also accepted by the old.   XML Schema's type &lt;xs:restriction/&gt; allows alteration of wildcards anywhere in the content model, like Complete Respecification, but allows the original type to be preserved.  Alternatively, XML Schema's type extension mechanism &lt;xs:extension/&gt; [provide ref to Recommendation] provides a different way of specifiying a modified type, in which the original content is not restated, but only the new elements are explicitly referenced.  The differences are:  (1) xs:extension of sequences allows new content only at the end of the model and (2) using wildcards as shown above, the original type will accept not only documents in the original language, but also documents containing the middle name, something that's not true in typical uses of xs:extension.  Thus the schema author of new version of a type has 3 options outlined above: 1) Complete Respecification without explicit use of xs:restriction; 2) Complete Respecification with explicit use of xs:restriction; 3) xs:extension. </p>
</div>
<div class="div1">

<h2><a name="allgroup" id="allgroup"></a>3 Updated All Group</h2>
<p>All-groups can use the updated wildcard:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90045" id="id90045"></a>Example 8: Name using All-group</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified"
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:all&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:element name="middle" type="xs:string" minOccurs="0"/&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
      &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:all&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
    
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>This highlights two change to all-groups: the addition of wildcards and maxOccurs &gt; 1 allows personNames such as:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90066" id="id90066"></a>Example 9: Name instances with unordered content</div><div class="exampleInner">
<pre>&lt;personName xmlns="http://www.example.org/ns/personName/1"&gt;
  &lt;given&gt;Dave&lt;/given&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
&lt;/personName&gt;

&lt;personName xmlns="http://www.example.org/ns/personName/1"&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
  &lt;given&gt;Dave&lt;/given&gt;
&lt;/personName&gt;

&lt;personName xmlns="http://www.example.org/ns/personName/1"&gt;
  &lt;middle&gt;Bryce&lt;/middle&gt;
  &lt;given&gt;Dave&lt;/given&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
&lt;/personName&gt;

&lt;personName xmlns="http://www.example.org/ns/personName/1"&gt;
  &lt;addr:Address xmlns:addr="http://www.example.org/ns/address/1"&gt;Vancouver&lt;/addr:Address&gt;
  &lt;given&gt;Dave&lt;/given&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
&lt;/personName&gt;</pre></div>
</div>
</div>
<div class="div1">

<h2><a name="negativewildcard" id="negativewildcard"></a>4 Negative Wildcards</h2>
<p>The previous schemas allowed extra content that was already declared elsewhere in the schema, because the wildcard the wildcard could match anything.  The NIS wildcard matches global elements from the schema, and the schema is generated by the schema processor as a result of processing all the schema documents including those imported and included. In the following example, the wildcards used in the schemas above would match the &lt;given&gt; that follows &lt;family&gt;:
</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90089" id="id90089"></a>Example 10: Name instance with extra given at the end</div><div class="exampleInner">
<pre>&lt;personName xmlns="http://www.example.org/ns/personName/1"&gt;
  &lt;given&gt;Dave&lt;/given&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
  &lt;given&gt;Dave&lt;/given&gt;
&lt;/personName&gt;</pre></div>
</div>
<p>We can preclude the "extra" occurances by using the negative wildcard to disallow certain elements, ie:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90114" id="id90114"></a>Example 11: name with various negative wildcard</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
       &lt;xs:any namespace="##any" 
                    notQName="namens:personName namens:given namens:family" 
                    processContents="lax" 
                    minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:any namespace="http://www.example.org/ns/personName/1" 
                   notQName="namens:personName namens:given namens:family" 
                   processContents="lax" 
                   minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
      &lt;xs:any notNamespace="http://www.example.org/ns/personName/1" 
                   processContents="lax" 
                   minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>The first wildcard allows anything other than namens:personName, namens:given, namens:family.  The 2nd wildcard allows any element in the http://www.example.org/ns/personName/1 namespace expect for name, given, family.  The last wild card allows for any namespace other than the http://www.example.org/ns/personName/1 namespace. </p>
<p>It is possible to re-use the wildcard with the excluded QNames by employing a model group with a wildcard referencing the QNames.</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90140" id="id90140"></a>Example 12: name with various negative wildcards in Group</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1"
      elementFormDefault="qualified"
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
      
  &lt;xs:group name="definedQNames"&gt;
     &lt;xs:sequence&gt;
         &lt;xs:any namespace="##any" notQname="namens:personName namens:given namens:family"/&gt;
     &lt;/xs:sequence&gt;
  &lt;/xs:group&gt; 
  
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:group ref="namens:definedQNames"/&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:group ref="namens:definedQNames"/&gt;
       &lt;xs:element name="family" type="xs:string"/&gt;
      &lt;xs:group ref="namens:definedQNames"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
</div>
<div class="div1">

<h2><a name="id90153" id="id90153"></a>5 Multiple Namespaces</h2>
<p>Many XML Languages use multiple namespaces.  Imagine the name where the given and family are from different namespaces than the name with wildcards at the end.  What wildcard should be there?  Saying "##any" means already existing terms could be inserted.  ##other only prevents items from the target namespace (name) from appearing.  If we want to allow only elements that are not in the givenns, familyns, or name namespaces, we can use negative wildcards with the notNamespace option:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90162" id="id90162"></a>Example 13: Multiple namespaces with negative wildcards</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"
      xmlns:givenns="http://www.example.org/ns/personName/given/1"
      xmlns:familyns="http://www.example.org/ns/personName/family/1"&gt; 
      
  &lt;xs:import namespace="http://www.example.org/ns/personName/given/1"/&gt; 
  &lt;xs:import namespace="http://www.example.org/ns/personName/family/1"/&gt; 

  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
       &lt;xs:element ref="givenns:given"/&gt;
       &lt;xs:element ref="familyns:family"/&gt;
       &lt;xs:any notNamespace="http://www.example.org/ns/personName/1 http://www.example.org/ns/personName/given/1 
                    http://www.example.org/ns/personName/family/1" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>The wildcard above will validate any element except those with namespaces "http://www.example.org/ns/personName/1 http://www.example.org/ns/personName/given/1 and  http://www.example.org/ns/personName/family/1".  A common versioning scenario is to extend an existing namespace with new names, as mentioned in TAG finding (<a href="http://www.w3.org/2001/tag/doc/namespaceState.html">http://www.w3.org/2001/tag/doc/namespaceState.html</a>).  If we want to exclude existing terms from a namespace, we can also list them, as shown earlier but reprised in multi-ns:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90200" id="id90200"></a>Example 14: Multiple namespaces with negative wildcards</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
      
  &lt;xs:import namespace="http://www.example.org/ns/personName/given/1"/&gt; 
  &lt;xs:import namespace="http://www.example.org/ns/personName/family/1"/&gt; 

  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
       &lt;xs:element ref="givenns:given"/&gt;
       &lt;xs:element ref="familyns:family"/&gt;
       &lt;xs:any namespace="##any" notQName="namens:personName givenns:given familyns:family" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
</div>
<div class="div1">

<h2><a name="openContent" id="openContent"></a>6 Default Open Content</h2>
<p>The previous schemas can be hard to read because of the wildcards sprinkled through the types.  Also, the language designer has to remember to put the wildcards in everywhere.  To partially address this problem, Schema 1.1 introduces the openContent element.  It's functionality can be thought of as a default wildcard.  There are two places that open content can occur, at the schema level or at the complextype level.  The open content facility can provide for extensibility of the content model in two styles: extensibility only at the end is specified by a mode="suffix" in the openContent; extensibility before the first element, between every element and after the last is specified by a mode="interleave" in the openContent.  For simplicity, the type of wildcard that is defaulted is specified by a wildcard as a child of openContent.  </p>
<div class="div2">

<h3><a name="id90223" id="id90223"></a>6.1 Schema wide Open Content</h3>
<p>At the schema wide level, a sample is:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90233" id="id90233"></a>Example 15: Schema level open content</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
      
     &lt;xs:openContent mode="interleave"&gt;
           &lt;xs:any namespace="##any" processContents="lax" 
                        minOccurs="0" maxOccurs="unbounded"/&gt;
     &lt;/xs:openContent&gt;
  
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
     &lt;/xs:sequence&gt;
     &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>This content allows and validates any extensions before, between or after family.  If another type was added to the schema, then it would also have the openContent.  For a schema that only has type nameType, it is very similar to Example #2.</p>
</div>
<div class="div2">

<h3><a name="id90258" id="id90258"></a>6.2 ComplexType level open content</h3>
<p>A ComplexType level open content is:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90267" id="id90267"></a>Example 16: ComplexType level open content</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
      
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:openContent mode="suffix"&gt;
           &lt;xs:any namespace="##any" processContents="lax" 
                  minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:openContent&gt;
    
    &lt;xs:sequence&gt;
	  &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>This content allows and validates any extensions before, between or after family.  For the nameType type definition, it is very similar to Example #2.</p>
</div>
</div>
<div class="div1">

<h2><a name="id90288" id="id90288"></a>7 Not in Schema wildcard</h2>
<p>The Negative wildcard requires that every wildcard specify or list the excluded QNames.  We see that this can become difficult to manage as the number of wildcards and definitions grows.  If there were 1000 element definitions and another one was added, then potentially 1000 wildcards would need to be updated to preclude the new element.  Best case is there is an open content at the schema level and only one change is needed.  However, even in this scenario, it is very possible to forget to add the new excluded qname.  To help with this manageability issue, the Not In Schema wildcard specifies that any declared element is not allowed in the wildcard and is equivalent to the negative wildcard if all the declared elements were listed as excluded QNames.   For ease of authoring, the examples are based upon the open content mentioned above.</p>
<p>The schema looks like:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90299" id="id90299"></a>Example 17: name with NIS wildcard</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
  
  &lt;!-- Defines addr:Address, addr:City, addr:PostalCode, addr:Country, addr:State --&gt;
  &lt;xs:import namespace="http://www.example.org/ns/Address/1"/&gt; 
  
  &lt;!-- ##defined here disallows: namens:personName, namens:given, namens:family,
       addr:Address, addr:City, addr:PostalCode, addr:Country, addr:State --&gt;
  &lt;xs:openContent mode="interleave"&gt;
     &lt;xs:any namespace="##any" notQName="##defined" processContents="lax"/&gt;
  &lt;/xs:openContent&gt;
  
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>This example shows 2 different namespaces, namens and addr, that collectively define namens:personName, namens:given, namens:family, addr:Address, addr:City, addr:PostalCode, addr:Country, addr:State.  Actually, here and in other QName comparisons discussed in this primer, it's the namespace name URI, that's compared, not the 'namens or addr' prefix.  This text ensures that the namespace URI for namens is http://www.example.org/ns/personName/1 and the local name is personName for namens:personName.  For convenience in this primer we follow XML conventions and refer just to the prefixed QName.  These Qnames are disallowed in the personName element.  Imagine that a producer invents an extension, say "middle" names.  The producer puts the middle after the family, shown below</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90314" id="id90314"></a>Example 18: Name instances validating against ##defined</div><div class="exampleInner">
<pre>&lt;personName xmlns="http://www.example.org/ns/personName/1"&gt;
  &lt;given&gt;Dave&lt;/given&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
  &lt;midns:middle xmlns:midns="http://www.example.org/ns/middleName/1"&gt;Bryce&lt;/midns:middle&gt;
&lt;/personName&gt;</pre></div>
</div>
<p>The consumer won't know about the middle names and validation will pass.  Again, note that elements that are considered defined are all the elements that are available as a result of processing every schema document including those referenced by include and import.  </p>
</div>
<div class="div1">

<h2><a name="id90340" id="id90340"></a>8 Type extension and restriction with wildcards</h2>
<p>Extension and Restriction are two modularity mechanisms that can be combined with the new wildcard capabilities of XML Schema 1.1.</p>
<div class="div2">

<h3><a name="id90351" id="id90351"></a>8.1 Extension</h3>
<p>We can use open contents and type extension to add content to the content model in the simplest way, that is adding the new element, because the following is legal in Schema:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90363" id="id90363"></a>Example 19: Type extension with defaults</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt;
     &lt;xs:openContent mode="interleave"&gt;
             &lt;xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;/xs:openContent&gt;
      
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
  
  &lt;xs:complexType name="personNameWithMiddleType"&gt;
      &lt;xs:complexContent&gt;
         &lt;xs:extension base="namens:nameType"&gt;
            &lt;xs:sequence&gt;
               &lt;xs:element name="middle" type="xs:string"/&gt;
           &lt;/xs:sequence&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:complexContent&gt;
      &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personNameWithMiddle" type="namens:personNameWithMiddleType"/&gt;

&lt;/xs:schema&gt;</pre></div>
</div>
<p>This results in a type which is legal in schema 1.1 because it creates a type with content model below:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90380" id="id90380"></a>Example 20: type extension result</div><div class="exampleInner">
<pre>&lt;xs:sequence&gt;
    &lt;xs:element name="given" type="xs:string"/&gt;
    &lt;xs:element name="family" type="xs:string"/&gt;
    &lt;xs:element name="middle" type="xs:string"/&gt;
&lt;/xs:sequence&gt;</pre></div>
</div>
<p>Its validation semantics are changed to behave as if occurs before, in between and after, each particle, like this:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90401" id="id90401"></a>Example 21: type extension result</div><div class="exampleInner">
<pre>&lt;xs:sequence&gt;
    &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;xs:element name="given" type="xs:string"/&gt;
    &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;xs:element name="family" type="xs:string"/&gt;
    &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;xs:element name="middle" type="xs:string"/&gt;
    &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt;
&lt;/xs:sequence&gt;</pre></div>
</div>
<p>Note that extension adds to the content model.  In the previous case, the wildcard was implicit and not part of the types content model.  Extension of types with explicit wildcards at the end is not possible when the wildcard has a minOccurs that does not equal the maxOccurs.  The reason is that extension of types extends the content model, and adding an explicit element after a wildcard with optional content is actually a restriction.  For example, the following is illegal.</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90416" id="id90416"></a>Example 22: Illegal type extension</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt;
      
   &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
          &lt;xs:any namespace="##any" processContents="lax" 
          minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt; 
      
   &lt;xs:complexType name="personNameWithMiddleType"&gt;
      &lt;xs:complexContent&gt;
         &lt;xs:extension base="namens:nameType"&gt;
           &lt;xs:sequence minOccurs="0" &gt;
               &lt;xs:element name="middle" type="xs:string"/&gt; 
                   &lt;xs:any namespace="##any" processContents="lax" 
                   minOccurs="0" maxOccurs="unbounded"/&gt;
           &lt;/xs:sequence&gt;
        &lt;/xs:extension&gt;
      &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
      
&lt;/xs:schema&gt;</pre></div>
</div>
<p>It is worth noting that if the wildcard has a minOccurs = maxOccurs then the previous extension is valid because the number of elements validated by the wildcard is predictable and so the UPA constraint is not violated.  However, this doesn't appear to be a common usage pattern.</p>
</div>
<div class="div2">

<h3><a name="id90441" id="id90441"></a>8.2 Restriction</h3>
<p>Now let us examine type restriction with wildcards.</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90455" id="id90455"></a>Example 23: type restriction replacing last any</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 

  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
          &lt;xs:any namespace="##any" processContents="lax" 
          minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
    
  &lt;xs:complexType name="personNameWithMiddleType"&gt;
      &lt;xs:complexContent&gt;
         &lt;xs:restriction base="namens:nameType" &gt;
           &lt;xs:sequence&gt;
            &lt;xs:element name="given" type="xs:string"/&gt;
            &lt;xs:element name="family" type="xs:string"/&gt;
            &lt;xs:element name="middle" type="xs:string" minOccurs="0"/&gt;
                &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt;
           &lt;/xs:sequence&gt;
        &lt;xs:anyAttribute/&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personNameWithMiddle" type="namens:personNameWithMiddleType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>Note that the restriction forces us to replicate the content model of the restricted type.   This does allow us to perform significant updates to the content model including adding content between existing elements, for example</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90471" id="id90471"></a>Example 24: type restriction changing many wildcards</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
   
  &lt;xs:complexType name="nameType"&gt;
     &lt;xs:sequence&gt;
       &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;   
       &lt;xs:element name="given" type="xs:string"/&gt;
       &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;   
       &lt;xs:element name="family" type="xs:string"/&gt;
       &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;   
     &lt;/xs:sequence&gt;
     &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
 &lt;xs:complexType name="MuchBetterNameType"&gt;
      &lt;xs:complexContent&gt;
         &lt;xs:restriction base="namens:nameType" &gt;
           &lt;xs:sequence&gt;
             &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt; 
             &lt;xs:element name="prefix" type="xs:string" minOccurs="0"/&gt;
             &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt; 
             &lt;xs:element name="given" type="xs:string"/&gt;  &lt;!-- ie David --&gt;
             &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt; 
             &lt;xs:element name="familiarname" type="xs:string" minOccurs="0"/&gt;  &lt;!-- ie Dave --&gt;
             &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt; 
             &lt;xs:element name="middle" type="xs:string" minOccurs="0"/&gt;
             &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt; 
             &lt;xs:element name="family" type="xs:string"/&gt;
             &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt; 
             &lt;xs:element name="suffix" type="xs:string" minOccurs="0"/&gt;
             &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt; 
             &lt;xs:element name="fullyWrittenName" type="xs:string" minOccurs="0"/&gt;  &lt;!-- ie Henry S Truman --&gt;
             &lt;xs:any namespace="##any" processContents="lax" 
                minOccurs="0" maxOccurs="unbounded"/&gt; 
            &lt;/xs:sequence&gt;
           &lt;xs:anyAttribute/&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
      
  &lt;xs:element name="MuchBetterName" type="namens:MuchBetterNameType"/&gt;

&lt;/xs:schema&gt;</pre></div>
</div>
<p>We can also change the location of the wildcards.   The newer version of the schema must not allow more things than before - because any instances of the new type must be valid against the old type - the wildcards can change from interleave to suffix to none.  Because we are restricting the type, we use the xsd:restriction construct.  An example of this is: </p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90491" id="id90491"></a>Example 25: type extension</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt;
       
  &lt;xs:complexType name="nameType"&gt;
      &lt;xs:openContent mode="interleave"&gt;
         &lt;xs:any namespace="##any" processContents="lax"
                       minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;/xs:openContent&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element name="given" type="xs:string"/&gt;
        &lt;xs:element name="family" type="xs:string"/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
  
  &lt;xs:complexType name="personNameWithMiddleType"&gt;
      &lt;xs:complexContent&gt;
         &lt;xs:restriction base="namens:nameType"&gt;
           &lt;xs:openContent mode="suffix"&gt;
              &lt;xs:any namespace="##any" processContents="lax"
                           minOccurs="0" maxOccurs="unbounded"/&gt;
           &lt;/xs:openContent&gt;
           &lt;xs:sequence&gt;
               &lt;xs:element name="given" type="xs:string"/&gt;
               &lt;xs:element name="family" type="xs:string"/&gt;
               &lt;xs:element name="middle" type="xs:string" minOccurs="0"/&gt; 
           &lt;/xs:sequence&gt;
        &lt;/xs:restriction&gt;
        &lt;xs:anyAttribute/&gt;
      &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personName" type="namens:personNameWithMiddleType"/&gt;

&lt;/xs:schema&gt;</pre></div>
</div>
</div>
<div class="div2">

<h3><a name="id90510" id="id90510"></a>8.3 Allowing Extension or Restriction with wildcards</h3>
<p>The first version of a type will determine whether xsd:extension or xsd:restriction can be used for modularity.  In general, explicit repeating wildcards in the first version of a type mean that a derived type can use xsd:restriction and cannot use xsd:extension.  The converse is true, which is that no wildcards or implicit wildcards in the first version of a type mean that a derived type can use xsd:extension and cannot use xsd:restriction unless other content allowed by the base type is optional or variable.  If a type author wants to enable re-use of a type without respecification, specifically xsd:extension, then they typically must not use explicit wildcards.</p>
</div>
<div class="div2">

<h3><a name="id90521" id="id90521"></a>8.4 Producer side considerations for NIS</h3>
<p>There is an issue for a producer of a document with extensions that wishes to write a schema that includes the extension.  In the scenario where a middle is added to a name, the producer does know about the extension.  It might create a schema for the extension such as </p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90534" id="id90534"></a>Example 26: New middle</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/middleName/1" 
      elementFormDefault="qualified" 
      xmlns:midns="http://www.example.org/ns/middleName/1"&gt; 
        
   &lt;xs:element name="middle" type="xs:string"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>When the producer attempts to validate the instance document against the two schemas, validation will fail.  This is because the ##defined will now fail because the middle is now known.  </p>
<p>One attempt to solve this problem is to rewrite the schema.  </p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90562" id="id90562"></a>Example 27: name with NIS wildcard respecified with middle</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"
      xmlns:midns="http://www.example.org/ns/middleName/1"&gt; 
  
  &lt;xs:import namespace="http://www.example.org/ns/middleName/1"/&gt;
  
  &lt;xs:openContent mode="interleave"&gt;
     &lt;xs:any namespace="##any" notQName="##defined" processContents="lax"
                   minOccurs="0" maxOccurs="unbounded"/&gt;     
  &lt;/xs:openContent&gt;
  
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
      &lt;xs:element ref="midns:middle" minOccurs="0"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
  &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>The producer is able to produce a schema that validates the instance.  But what if the producer is not able to change the nameType to add in the middle?  They might attempt to do something such as:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90578" id="id90578"></a>Example 28: name with NIS wildcard</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"
      xmlns:midns="http://www.example.org/ns/middleName/1"&gt; 
  
  &lt;xs:import namespace="http://www.example.org/ns/personMiddle/1"/&gt;

  
  &lt;xs:redefine schemaLocation="name.xsd"&gt;
    &lt;xs:complexType name="nameType"&gt;
      &lt;xs:complexContent&gt;
        &lt;xs:restriction base="namens:nameType"&gt;
          &lt;xs:sequence&gt;
            &lt;xs:element name="given" type="xs:string"/&gt;
            &lt;xs:element name="family" type="xs:string"/&gt;
            &lt;xs:element ref="midns:middle" minOccurs="0"/&gt;
          &lt;/xs:sequence&gt;
          &lt;xs:anyAttribute/&gt;
        &lt;/xs:restriction&gt;    
      &lt;/xs:complexContent&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:redefine&gt;
  
  &lt;xs:openContent mode="interleave"&gt;
    &lt;xs:any namespace="##any" notQName="##defined" 
                 processContents="lax"
                 minOccurs="0" maxOccurs="unbounded"/&gt; 
  &lt;/xs:openContent&gt;
      
  &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>The problem is that, by the time the definition of the redefined type is checked, the midns:middle is known, and it defines midns:middle  In such a context, the above schema represents an illegal redefinition of nameType.  The Working Group acknowledges this may limit use of NIS wildcards in some circumstances and solicits feedback.</p>
</div>
</div>
<div class="div1">

<h2><a name="id90605" id="id90605"></a>9 Fallback to Declared Type</h2>
<p>XML Schema 1.0 has a feature that an instance document may contain an xsi:type attribute that specifies the type of the element.  When a consumer receives the existing element name with an xsi:type specifying the new type, it may not know about the new type.  A fallback from the xsi:type to the declared type allows a consuming schema processor to "cast" the type it does know about into the declared type.  </p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90621" id="id90621"></a>Example 29: name with xsi:type</div><div class="exampleInner">
<pre>&lt;personName xmlns="http://www.example.org/ns/personName/1" 
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:type="namens:personNameWithMiddle"&gt;
  &lt;given&gt;Dave&lt;/given&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
  &lt;middle&gt;Bryce&lt;/middle&gt;
&lt;/personName&gt;</pre></div>
</div>
<p>If the consumer of this element didn't understand the xsi:type definition (namens:personNameWithMiddle), they could "cast" it to the declared type (namens:personName), resulting in roughly:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90644" id="id90644"></a>Example 30: name after fallback to declared type</div><div class="exampleInner">
<pre>&lt;personName xmlns="http://www.example.org/ns/personName/1" &gt;
  &lt;given&gt;Dave&lt;/given&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
  &lt;middle&gt;Bryce&lt;/middle&gt;
&lt;/personName&gt;</pre></div>
</div>
</div>
<div class="div1">

<h2><a name="id90662" id="id90662"></a>10 Appendix: Some mechanisms not in Schema 1.0 or 1.1</h2>
<p>This section lists a few mechanisms that have some interest and demand but for a variety of reasons are not in Schema 1.0 or Schema 1.1.  These are included here because there are still discussion within the Schema WG about versioning mechanisms and may be useful for the Schema WG members.  Note, the syntax used here-in is probably incorrect as it isn't maintained as closely as the in-scope mechanisms. </p>
<div class="div2">

<h3><a name="id90679" id="id90679"></a>10.1 Extension replacing wildcard</h3>
<p>As noted in the section on extension and restriction, an explicit wildcard at the end of a content model means that xsd:extension cannot be used and thus restatement of the original content must be done.  One potential solution to allow re-use without restatement is to revise XML Schema's extension mechanism to specify that a trailing wildcard in a base type is replaced by the extension.  ie:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90695" id="id90695"></a>Example 31: type extension replacing last any</div><div class="exampleInner">
<pre>&lt;xs:complexType name="nameType"&gt;
     &lt;xs:sequence&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
      &lt;xs:any namespace="##any" processContents="lax"
                         minOccurs="0" maxOccurs="unbounded"/&gt; 
     &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:complexType name="personNameWithMiddleType"&gt;
      &lt;xs:complexContent&gt;
         &lt;xs:extensionRemovingTrailingWildcard base="namens:nameType" &gt;
           &lt;xs:sequence&gt;
              &lt;xs:element name="middle" type="xs:string" minOccurs="0"/&gt;
              &lt;xs:any namespace="##any" processContents="lax"
                                 minOccurs="0" maxOccurs="unbounded"/&gt; 
            &lt;/xs:sequence&gt;
        &lt;/xs:extensionRemovingTrailingWildcard&gt;
      &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;</pre></div>
</div>
<p>This proposed new extension would result in a content model of</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90711" id="id90711"></a>Example 32: type extension result</div><div class="exampleInner">
<pre>&lt;xs:sequence&gt;
       &lt;xs:element name="given" type="xs:string"/&gt;
       &lt;xs:element name="family" type="xs:string"/&gt;
       &lt;xs:element name="middle" type="xs:string" minOccurs="0"/&gt;
       &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;/xs:sequence&gt;
</pre></div>
</div>
<p>This feature does not seem very useful however.  This can be approximated by a base type with an open content with mode=suffix and then the extension type have the same open content.</p>
</div>
<div class="div2">

<h3><a name="id90736" id="id90736"></a>10.2 Fallback</h3>
<p>Fallback allows replacement content to be inserted if an element type isn't defined.  All the previous examples generally retain the extra content in the PSVI.  One use of fallback is to "prune" the extra content from the PSVI, such as:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90749" id="id90749"></a>Example 33: name with fallback in schema instance</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 
  &lt;xs:complexType name="nameType"&gt;
    &lt;xs:sequence&gt;
       &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"&gt;
              &lt;xs:fallback/&gt;
       &lt;/xs:any&gt;
      &lt;xs:element name="given" type="xs:string"/&gt;
       &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"&gt;
              &lt;xs:fallback/&gt;
       &lt;/xs:any&gt;
      &lt;xs:element name="family" type="xs:string"/&gt;
       &lt;xs:any namespace="##any" processContents="lax" 
              minOccurs="0" maxOccurs="unbounded"&gt;
              &lt;xs:fallback/&gt;
       &lt;/xs:any&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute/&gt;
  &lt;/xs:complexType&gt;
      
   &lt;xs:element name="personName" type="namens:nameType"/&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>In this example, any extensions will be pruned and will not be in the PSVI after fallback processing is applied.</p>
<p>Also see the following section for instance document based fallback.</p>
</div>
<div class="div2">

<h3><a name="id90773" id="id90773"></a>10.3 FallbackElement in instance</h3>
<p>The previous example creates a new type and preserved the existing name.  Another possibility is that new element names will be created.  When a consumer receives a new element name, it may not know about the new element name or type.  An xsi:fallbackElement can be specified in the instance, and a consumer can "cast" the element it does know about into the xsi:fallbackElement.  </p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90788" id="id90788"></a>Example 34: personNameWithMiddle with xsi:fallbackElement</div><div class="exampleInner">
<pre>&lt;personNameWithMiddle xmlns="http://www.example.org/ns/personName/1" 
		xmlns:namens="http://www.example.org/ns/personName/1" 
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:type="namens:personNameWithMiddleType" 
		xsi:fallbackElement="namens:personName"&gt;
  &lt;given&gt;Dave&lt;/given&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
  &lt;middle&gt;Bryce&lt;/middle&gt;
&lt;/personNameWithMiddle&gt;</pre></div>
</div>
<p>If the consumer of this element didn't understand the element definition, they could "cast" it to the fallbackElement, resulting in:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90813" id="id90813"></a>Example 35: name after fallbackElement processing</div><div class="exampleInner">
<pre>&lt;personName xmlns="http://www.example.org/ns/personName/1" 
		xmlns:namens="http://www.example.org/ns/personName/1" 
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:type="namens:personNameWithMiddleType" &gt;
  &lt;given&gt;Dave&lt;/given&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
  &lt;middle&gt;Bryce&lt;/middle&gt;
&lt;/personName&gt;</pre></div>
</div>
<p>This would then combine with the fallback to Declared type as mentioned previously.</p>
<div class="div3">

<h4><a name="id90836" id="id90836"></a>10.3.1 Multiple Versions with Fallback Type</h4>
<p>Let us explore multiple versions.  Imagine a 3rd version of name is created with a suffix:</p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90847" id="id90847"></a>Example 36: Multiple versions with fallback type</div><div class="exampleInner">
<pre>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/ns/personName/1" 
      elementFormDefault="qualified" 
      xmlns:namens="http://www.example.org/ns/personName/1"&gt; 

&lt;xs:element name="personNameWithMiddleAndSuffix" type="namens:personNameWithMiddleAndSuffixType"/&gt;
  &lt;xs:complexType name="personNameWithMiddleAndSuffixType"&gt;
      &lt;xs:complexContent&gt;
         &lt;xs:restriction base="namens:personNameWithMiddle" &gt;
           &lt;xs:openContent mode="suffix"&gt;
             &lt;xs:any namespace="##any" processContents="lax"
                                minOccurs="0" maxOccurs="unbounded"/&gt; 
           &lt;/xs:openContent&gt;
           &lt;xs:sequence&gt;
             &lt;xs:element name="given" type="xs:string"/&gt;
             &lt;xs:element name="family" type="xs:string"/&gt;
            &lt;xs:element name="middle" type="xs:string" minOccurs="0"/&gt;
            &lt;xs:element name="suffix" type="xs:string" minOccurs="0"/&gt;
           &lt;/xs:sequence&gt;
        &lt;/xs:restriction&gt;
      &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:schema&gt;</pre></div>
</div>
<p>There is a problem of chaining the fallback elements together.  TBD.  </p>
<div class="exampleOuter">

<div class="exampleHeader"><a name="id90864" id="id90864"></a>Example 37: personNameWithMiddleAndSuffix with fallbackElement</div><div class="exampleInner">
<pre>&lt;personNameWithMiddleAndSuffix xmlns="http://www.example.org/ns/personName/1" 
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:type="namens:personNameWithMiddleAndSuffix" xsi:fallbackElement="namens:personNameWithMiddle namens:personName"&gt;
  &lt;given&gt;Dave&lt;/given&gt;
  &lt;family&gt;Orchard&lt;/family&gt;
  &lt;middle&gt;Bryce&lt;/middle&gt;
&lt;/personNameWithMiddleAndSuffix&gt;</pre></div>
</div>
</div>
</div>
<div class="div2">

<h3><a name="id90878" id="id90878"></a>10.4 Version numbers</h3>
</div>
<div class="div2">

<h3><a name="id90891" id="id90891"></a>10.5 MustUnderstand</h3>
</div>
</div>
<div class="div1">

<h2><a name="id90899" id="id90899"></a>11 References</h2>
<dl><dt class="label"><a name="XMLSchemaPart1" id="XMLSchemaPart1"></a>XML Schema Part 1</dt><dd>
					<a href="http://www.w3.org/TR/xmlschema-1"><cite>W3C Recommendation, XML Schema, Part 1</cite></a>  (See http://www.w3.org/TR/xmlschema-1.)</dd><dt class="label"><a name="XMLSchema11Part1" id="XMLSchema11Part1"></a>XML Schema 1.1 Part 1</dt><dd>
					<a href="http://www.w3.org/XML/Group/2004/06/xmlschema-1/structures.html"><cite>W3C Working Draft, XML Schema 1.1, Part 1</cite></a>  (See http://www.w3.org/XML/Group/2004/06/xmlschema-1/structures.html.)</dd><dt class="label"><a name="TAGXMLVersioningPart1" id="TAGXMLVersioningPart1"></a>TAG Finding Versioning Part 1</dt><dd>
					<a href="http://www.w3.org/2001/tag/doc/versioning"><cite>TAG Finding on Versioning Part 1</cite></a>  (See http://www.w3.org/2001/tag/doc/versioning.)</dd><dt class="label"><a name="TAGXMLVersioningXML" id="TAGXMLVersioningXML"></a>TAG Finding Versioning XML</dt><dd>
					<a href="http://www.w3.org/2001/tag/doc/versioning-xml"><cite>TAG Finding on Versioning XML</cite></a>  (See http://www.w3.org/2001/tag/doc/versioning-xml.)</dd></dl></div>
<div class="div1">

<h2><a name="ack" id="ack"></a>12 Acknowledgements</h2>
<p>Gilbert Pilz, BEA Systems.  W3C Schema Working Group Members.  Paul Downey, BT.</p>
</div>
</div>
</body>
</html>