im using eclipse mars with XMLEspresso Plugin. The question is can i referenz an attribute or do i have to put it in the element. The validation of eclipse says there cant be an id in flughafen same for all other attributes.
XML- Example:
<?xml version="1.0" encoding="UTF-8"?>
<flugplan xmlns="http://example.org/Flugplan"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.org/Flugplan Flugplan-flat.xsd ">
<flughafen id="DUS" name="Düsseldorf" land="D" />
<flughafen id="HAM" name="Hamburg" land="D" />
<flughafen id="LHR" name="London/Heathrow" land="GB" />
<flughafen id="MUC" name="München" land="D" />
<flughafen id="WAW" name="Warschau" land="PL" />
<type id="A319" reichweite="6801" />
<type id="A321" reichweite="5600" />
<type id="CRJ9" reichweite="2100" />
<type id="DH8D" reichweite="1520" />
<maschine code="D-AIDW" type="A321" />
<maschine code="D-ACNN" type="CRJ9" />
<maschine code="SP-EQB" type="DH8D" />
<maschine code="D-AIDX" type="A321" />
<maschine code="D-AGWM" type="A319" />
<flug code="EW4462" start="HAM" ziel="LHR" abflug="07:30" entfernung="746" />
<flug code="LH2085" start="HAM" ziel="MUC" abflug="07:30" entfernung="601" />
<flug code="L0402" start="HAM" ziel="WAW" abflug="07:35" entfernung="754" />
<flug code="LH2087" start="HAM" ziel="MUC" abflug="08:00" entfernung="601" />
<flug code="4U9031" start="HAM" ziel="DUS" abflug="08:20" entfernung="340" />
<einsatz flug="EW4462" maschine="D-ACNN" />
<einsatz flug="LH2085" maschine="D-AIDW" />
<einsatz flug="L0402" maschine="SP-EQB" />
<einsatz flug="LH2087" maschine="D-AIDX" />
<einsatz flug="4U9031" maschine="D-AGWM" />
</flugplan>
Xml Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.org/Flugplan"
xmlns="http://example.org/Flugplan"
elementFormDefault="qualified">
<xsd:attribute name="id" type="xsd:ID" />
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="land" type="xsd:string" />
<xsd:attribute name="reichweite" type="xsd:string" />
<xsd:attribute name="code" type="xsd:string" />
<xsd:attribute name="typ" type="xsd:string" />
<xsd:attribute name="start" type="xsd:string" />
<xsd:attribute name="ziel" type="xsd:string" />
<xsd:attribute name="abflug" type="xsd:string" />
<xsd:attribute name="entfernung" type="xsd:integer" />
<xsd:attribute name="flug" type="xsd:string" />
<xsd:attribute name="maschine" type="xsd:string" />
<xsd:element name="flughafen">
<xsd:complexType>
<xsd:attribute ref="id" />
<xsd:attribute ref="name" />
<xsd:attribute ref="land" />
</xsd:complexType>
</xsd:element>
<xsd:element name="type">
<xsd:complexType>
<xsd:attribute ref="id" />
<xsd:attribute ref="reichweite" />
</xsd:complexType>
</xsd:element>
<xsd:element name="maschine">
<xsd:complexType>
<xsd:attribute ref="code" />
<xsd:attribute ref="typ" />
</xsd:complexType>
</xsd:element>
<xsd:element name="flug">
<xsd:complexType>
<xsd:attribute ref="code" />
<xsd:attribute ref="start" />
<xsd:attribute ref="ziel" />
<xsd:attribute ref="abflug" />
<xsd:attribute ref="entfernung" />
</xsd:complexType>
</xsd:element>
<xsd:element name="einsatz">
<xsd:complexType>
<xsd:attribute ref="flug" />
<xsd:attribute ref="maschine" />
</xsd:complexType>
</xsd:element>
<xsd:element name="flugplan">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="flughafen" minOccurs="1" maxOccurs="unbounded" />
<xsd:element ref="type" minOccurs="1" maxOccurs="unbounded" />
<xsd:element ref="maschine" minOccurs="1" maxOccurs="unbounded" />
<xsd:element ref="flug" minOccurs="1" maxOccurs="unbounded" />
<xsd:element ref="einsatz" minOccurs="1" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
It is correct that your XML is invalid against your XSD as currently written. Assuming that you wish to change your XSD to have your XML be valid against it, here are some options:
xsd:attributeGroups
.