XML-Schema include - Element
❮ Vollständige XML-Schema-Referenz
Definition und Verwendung
Das include-Element wird verwendet, um einem Dokument mehrere Schemas mit demselben Zielnamensraum hinzuzufügen.
Elementinformationen
- Übergeordnete Elemente: Schema
Syntax
<include
id=ID
schemaLocation=anyURI
any attributes
>
(annotation?)
</include>
(Das ?-Zeichen gibt an, dass das Element null oder einmal innerhalb des Include-Elements vorkommen kann.)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
schemaLocation | Required. Specifies the URI to the schema to include in the target namespace of the containing schema |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
Beispiel 1
Bei eingebundenen Schemas müssen die eingebundenen Dateien alle auf denselben Ziel-Namespace verweisen. Wenn der Namespace des Schemaziels nicht übereinstimmt, funktioniert das Include nicht:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.w3schools.com/schema">
<xs:include schemaLocation="https://www.w3schools.com/xml/customer.xsd"/>
<xs:include schemaLocation="https://www.w3schools.com/xml/company.xsd"/>
..
..
..
</xs:schema>
❮ Vollständige XML-Schema-Referenz