Als een XML-bestand elementen met een complex type bevat, kunt u met xsi:type in de XML-editor tussen het complexe type en alle afgeleide complexe typen kiezen.
Met de XML-schemaspecificatie kunt u typen afleiden per extensie.
Een voorbeeld hiervan vindt u in de onderstaande stappen:
- Create an XML schema and create a complex type for it called Address.
- Add some basic elements to Address, such
as streetName and city.
- Derive (by extension) two new complex types from Address: USAddress and UKAddress.
- Add a new element to USAddress called state,
and also a new element to UKAddress called postcode.
- Create two more elements: billTo and shipTo,
as Address types.
- When you create an XML instance document for an element such as
billTo or Address, an
xsi:type attribute will automatically be added to it. Een voorbeeld:
<billTo xsi:type="ipo:Address">
Het kenmerk xsi:type wordt gebruikt om afgeleide complexe typen te identificeren (en complexe typen die hiervan zijn afgeleid).
- In the Design view of the XML editor, a list will be available,
letting you select the appropriate type definition (Address, USAddress,
or UKAddress). De typedefinitie die u selecteert, geeft aan welke bewerkingen voor het contentmodel kunnen worden gebruikt.
For example, if you
select USAddress , your billTo element
can contain a state element, but it cannot contain a postcode element.
In het XML-voorbeeld "XML-bestanden bewerken en valideren" wordt de xsi:type-ondersteuning gedemonstreerd.
Voor meer informatie over xsi:type, raadpleegt u de sectie Using Derived Types in Instance Documents in XML Schema Part 0: Primer.
Voor meer informatie over validatiesemantiek als xsi:type wordt gebruikt, raadpleegt u de sectie Schema-Related
Markup in Documents Being Validated in XML Schema Part 1: Structures