XML / XML-Datenstrukturen / XML: Stark strukturierte Dokumente, komplett sequenzielle Dokument-Struktur
![]() |
![]() |
➪ Stellen Sie sich vor, die hierarchische Struktur würde komplett fehlen, und Sie hätten es mit einer rein sequenziellen XML-Struktur zu tun, deren inhaltliche Abhängigkeiten durch die Anschlussprogrammierung erst einmal abgebildet werden müssten, um sie auswerten zu können.
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="Orte">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="grpOrt" />
<xs:group ref="grpMensch"/>
<xs:group ref="grpKauf"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="id" type="xs:int"/>
<xs:element name="idOrt" type="xs:int"/>
<xs:element name="idMensch" type="xs:int"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="vorname" type="xs:string"/>
<xs:element name="beruf" type="xs:string"/>
<xs:element name="hobby" type="xs:string"/>
<xs:element name="Gehalt" type="xs:string"/>
<xs:element name="anzahl" type="xs:int"/>
<xs:element name="bez" type="xs:string"/>
<xs:element name="preis" type="xs:decimal"/>
<xs:element name="Gesamt" type="xs:decimal"/>
<xs:group name="grp_id_name">
<xs:sequence>
<xs:element ref="id"/>
<xs:element ref="name"/>
</xs:sequence>
</xs:group>
<xs:group name="grpKauf">
<xs:sequence>
<xs:element ref="idMensch"/>
<xs:element ref="anzahl"/>
<xs:element ref="bez"/>
<xs:element ref="preis"/>
<xs:element ref="Gesamt"/>
</xs:sequence>
</xs:group>
<xs:group name="grpMensch">
<xs:sequence>
<xs:group ref="grp_id_name"/>
<xs:element ref="vorname"/>
<xs:element ref="Gehalt"/>
<xs:element ref="idOrt"/>
</xs:sequence>
</xs:group>
<xs:group name="grpOrt">
<xs:choice>
<xs:group ref="grp_id_name"/>
</xs:choice>
</xs:group>
</xs:schema>
Inhaltlich ist das XML-Dokument identisch mit den vorgenannten Beispielen, lediglich mit einem komplett veränderten strukturellen Aufbau. (Streng genommen hätte man hier ohne Informationsverlust sogar noch auf die "Fremdschlüssel" idOrt und idMensch sowie auf das Gesamt-Feld verzichten können, da sie sich aus dem Kontext der Sequenz ergeben.) Auch so etwas kommt in der Praxis vor, und es stellt sich die Frage, wie in diesem Fall vorgegangen werden kann.
Auch für derlei scheinbares Chaos gibt es ein XML-Schema, hier kann es jedoch sein, dass unterschiedliche Validation-Engines gegebenenfalls Fehler melden. Während SAXON-EE bei mir mit der Deklaration einverstanden war, hatte Xerces ein Problem mit der identischen Abfolge von <id> und <name> bei <Ort> und <Mensch>.
<Orte>
<id>1</id>
<name>Neustadt</name>
<id>1</id>
<name>Holzflos</name>
<vorname>Hugo</vorname>
<Gehalt>234.56</Gehalt>
<idOrt>1</idOrt>
<idMensch>1</idMensch>
<anzahl>3</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>38.97</Gesamt>
<idMensch>1</idMensch>
<anzahl>9</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>116.91</Gesamt>
<idMensch>1</idMensch>
<anzahl>8</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>103.92</Gesamt>
<idMensch>1</idMensch>
<anzahl>9</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>233.91</Gesamt>
<idMensch>1</idMensch>
<anzahl>9</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>233.91</Gesamt>
<idMensch>1</idMensch>
<anzahl>8</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>207.92</Gesamt>
<idMensch>1</idMensch>
<anzahl>8</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>207.92</Gesamt>
<idMensch>1</idMensch>
<anzahl>8</anzahl>
<bez>Schuhe</bez>
<preis>151.23</preis>
<Gesamt>1209.84</Gesamt>
<idMensch>1</idMensch>
<anzahl>8</anzahl>
<bez>Schuhe</bez>
<preis>151.23</preis>
<Gesamt>1209.84</Gesamt>
<id>4</id>
<name>Nixlos</name>
<vorname>Nicole</vorname>
<Gehalt>1234.56</Gehalt>
<idOrt>1</idOrt>
<idMensch>4</idMensch>
<anzahl>8</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>207.92</Gesamt>
<idMensch>4</idMensch>
<anzahl>7</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>181.92999999999998</Gesamt>
<idMensch>4</idMensch>
<anzahl>6</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>155.94</Gesamt>
<idMensch>4</idMensch>
<anzahl>5</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>129.95</Gesamt>
<idMensch>4</idMensch>
<anzahl>4</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>103.96</Gesamt>
<idMensch>4</idMensch>
<anzahl>4</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>103.96</Gesamt>
<idMensch>4</idMensch>
<anzahl>3</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>77.97</Gesamt>
<id>9</id>
<name>Sprachlos</name>
<vorname>Stefan</vorname>
<Gehalt>5430</Gehalt>
<idOrt>1</idOrt>
<idMensch>9</idMensch>
<anzahl>11</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>142.89000000000002</Gesamt>
<idMensch>9</idMensch>
<anzahl>22</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>285.78000000000003</Gesamt>
<idMensch>9</idMensch>
<anzahl>33</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>428.67</Gesamt>
<idMensch>9</idMensch>
<anzahl>33</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>857.67</Gesamt>
<idMensch>9</idMensch>
<anzahl>44</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>1143.56</Gesamt>
<idMensch>9</idMensch>
<anzahl>55</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>1429.4499999999998</Gesamt>
<id>2</id>
<name>Sagblos</name>
<vorname>Stefan</vorname>
<Gehalt>321.45</Gehalt>
<idOrt>1</idOrt>
<idMensch>2</idMensch>
<anzahl>7</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>90.93</Gesamt>
<idMensch>2</idMensch>
<anzahl>7</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>181.92999999999998</Gesamt>
<idMensch>2</idMensch>
<anzahl>7</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>181.92999999999998</Gesamt>
<idMensch>2</idMensch>
<anzahl>7</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>181.92999999999998</Gesamt>
<idMensch>2</idMensch>
<anzahl>7</anzahl>
<bez>Schuhe</bez>
<preis>151.23</preis>
<Gesamt>1058.61</Gesamt>
<idMensch>2</idMensch>
<anzahl>7</anzahl>
<bez>Schuhe</bez>
<preis>151.23</preis>
<Gesamt>1058.61</Gesamt>
<id>3</id>
<name>Sorglos</name>
<vorname>Siggi</vorname>
<Gehalt>987.58</Gehalt>
<idOrt>1</idOrt>
<idMensch>3</idMensch>
<anzahl>2</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>25.98</Gesamt>
<idMensch>3</idMensch>
<anzahl>8</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>103.92</Gesamt>
<idMensch>3</idMensch>
<anzahl>4</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>51.96</Gesamt>
<idMensch>3</idMensch>
<anzahl>9</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>233.91</Gesamt>
<idMensch>3</idMensch>
<anzahl>3</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>77.97</Gesamt>
<idMensch>3</idMensch>
<anzahl>6</anzahl>
<bez>Schuhe</bez>
<preis>151.23</preis>
<Gesamt>907.37999999999988</Gesamt>
<idMensch>3</idMensch>
<anzahl>5</anzahl>
<bez>Schuhe</bez>
<preis>151.23</preis>
<Gesamt>756.15</Gesamt>
<idMensch>3</idMensch>
<anzahl>2</anzahl>
<bez>Schuhe</bez>
<preis>151.23</preis>
<Gesamt>302.46</Gesamt>
<idMensch>3</idMensch>
<anzahl>1</anzahl>
<bez>Schuhe</bez>
<preis>151.23</preis>
<Gesamt>151.23</Gesamt>
<id>7</id>
<name>Herzlos</name>
<vorname>Heini</vorname>
<Gehalt>654.21</Gehalt>
<idOrt>1</idOrt>
<idMensch>7</idMensch>
<anzahl>7</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>90.93</Gesamt>
<idMensch>7</idMensch>
<anzahl>9</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>116.91</Gesamt>
<idMensch>7</idMensch>
<anzahl>8</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>207.92</Gesamt>
<id>2</id>
<name>Darmstadt</name>
<id>8</id>
<name>Rhodos</name>
<vorname>Rudi</vorname>
<Gehalt>333.33</Gehalt>
<idOrt>2</idOrt>
<idMensch>8</idMensch>
<anzahl>3</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>38.97</Gesamt>
<idMensch>8</idMensch>
<anzahl>5</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>129.95</Gesamt>
<idMensch>8</idMensch>
<anzahl>22</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>571.78</Gesamt>
<id>15</id>
<name>Kolos</name>
<vorname>Karl</vorname>
<Gehalt>456</Gehalt>
<idOrt>2</idOrt>
<idMensch>15</idMensch>
<anzahl>2</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>25.98</Gesamt>
<idMensch>15</idMensch>
<anzahl>6</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>155.94</Gesamt>
<id>16</id>
<name>Sinnlos</name>
<vorname>Simone</vorname>
<Gehalt>876.54</Gehalt>
<idOrt>2</idOrt>
<idMensch>16</idMensch>
<anzahl>6</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>155.94</Gesamt>
<id>17</id>
<name>Zeitlos</name>
<vorname>Horst</vorname>
<Gehalt>546.77</Gehalt>
<idOrt>2</idOrt>
<idMensch>17</idMensch>
<anzahl>3</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>38.97</Gesamt>
<id>18</id>
<name>Wunschlos</name>
<vorname>Werner</vorname>
<Gehalt>777.77</Gehalt>
<idOrt>2</idOrt>
<idMensch>18</idMensch>
<anzahl>4</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>103.96</Gesamt>
<id>19</id>
<name>Lustlos</name>
<vorname>Ludwig</vorname>
<Gehalt>357</Gehalt>
<idOrt>2</idOrt>
<id>3</id>
<name>Kapstadt</name>
<id>5</id>
<name>Wasistlos</name>
<vorname>Willi</vorname>
<Gehalt>6789</Gehalt>
<idOrt>3</idOrt>
<idMensch>5</idMensch>
<anzahl>4</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>51.96</Gesamt>
<idMensch>5</idMensch>
<anzahl>44</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>571.56000000000006</Gesamt>
<idMensch>5</idMensch>
<anzahl>3</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>77.97</Gesamt>
<idMensch>5</idMensch>
<anzahl>5</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>129.95</Gesamt>
<id>10</id>
<name>Ruhelos</name>
<vorname>Rita</vorname>
<Gehalt>234</Gehalt>
<idOrt>3</idOrt>
<idMensch>10</idMensch>
<anzahl>4</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>51.96</Gesamt>
<idMensch>10</idMensch>
<anzahl>1</anzahl>
<bez>Schuhe</bez>
<preis>151.23</preis>
<Gesamt>151.23</Gesamt>
<id>11</id>
<name>Schlaflos</name>
<vorname>Susi</vorname>
<Gehalt>321</Gehalt>
<idOrt>3</idOrt>
<idMensch>11</idMensch>
<anzahl>2</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>51.98</Gesamt>
<idMensch>11</idMensch>
<anzahl>5</anzahl>
<bez>Schuhe</bez>
<preis>151.23</preis>
<Gesamt>756.15</Gesamt>
<id>12</id>
<name>Rielos</name>
<vorname>Lotte</vorname>
<Gehalt>456</Gehalt>
<idOrt>3</idOrt>
<idMensch>12</idMensch>
<anzahl>3</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>38.97</Gesamt>
<idMensch>12</idMensch>
<anzahl>6</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>155.94</Gesamt>
<idMensch>12</idMensch>
<anzahl>9</anzahl>
<bez>Schuhe</bez>
<preis>151.23</preis>
<Gesamt>1361.07</Gesamt>
<id>6</id>
<name>Bodenlos</name>
<vorname>Betty</vorname>
<Gehalt>3450</Gehalt>
<idOrt>3</idOrt>
<idMensch>6</idMensch>
<anzahl>6</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>77.94</Gesamt>
<idMensch>6</idMensch>
<anzahl>5</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>64.95</Gesamt>
<idMensch>6</idMensch>
<anzahl>7</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>181.92999999999998</Gesamt>
<id>13</id>
<name>Muehelos</name>
<vorname>Martin</vorname>
<Gehalt>222</Gehalt>
<idOrt>3</idOrt>
<idMensch>13</idMensch>
<anzahl>7</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>90.93</Gesamt>
<idMensch>13</idMensch>
<anzahl>4</anzahl>
<bez>Hemd</bez>
<preis>12.99</preis>
<Gesamt>51.96</Gesamt>
<id>14</id>
<name>Leinenlos</name>
<vorname>Liane</vorname>
<Gehalt>135</Gehalt>
<idOrt>3</idOrt>
<idMensch>14</idMensch>
<anzahl>8</anzahl>
<bez>Hose</bez>
<preis>25.99</preis>
<Gesamt>207.92</Gesamt>
<idMensch>14</idMensch>
<anzahl>5</anzahl>
<bez>Schuhe</bez>
<preis>151.23</preis>
<Gesamt>756.15</Gesamt>
</Orte>
wg / 3. April 2020
Fragen? Anmerkungen? Tipps?
Bitte nehmen Sie Kontakt zu mir auf.
V.i.S.d.P.: Wilfried Grupe * Klus 6 * 37643 Negenborn
☎ 0151. 750 360 61 * eMail: info10@wilfried-grupe.de