If you have to define a simple XML element of a certain predefined type like string or long but you want to include properties in the resulting element, the following schema definition might come handy.
XML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema"
targetNamespace = "http://www.consulting-bolte.de/ImgRule/"
xmlns:tns = "http://www.consulting-bolte.de/ImgRule/"
elementFormDefault = "qualified" >
<xs:complexType name = "PropertyType" >
<xs:simpleContent >
<xs:extension base = "xs:string" >
<xs:attribute name = "name" type = "xs:string" />
<xs:attribute name = "type" type = "xs:string" />
</xs:extension >
</xs:simpleContent >
</xs:complexType >
</xs:schema >
The above schema extends the simple type string from the W3C xml namespace.
Written by Alexander Bolte
Last Updated: 16 July 2015
Hits: 9257