I have two child elements with the same name but different attributes. Is there a way to write a valid XSD for it.
Error I get now is: Multiple element with name link and of different type appear in the model group
I have an XML like this:
<entry>
<id> 123 </id>
<link rel="alternate" type="text/html" href="ABC.html" />
<link rel="amphtml" href="https:ABCD.html" >
<inline:inline type="text/html">
<![CDATA[
<!doctype html>
<html amp>
</html>
]]>
</inline:inline>
</link>
</entry>
I am defining the XSD like this:
<xs:element name="entry" type="atom:entryType"/>
<xs:complexType name="entryType">
<xs:annotation>
<xs:documentation>
The Atom entry construct is defined in accordance with the XML defined in Just-in doc.
</xs:documentation>
</xs:annotation>
<xs:choice maxOccurs="unbounded">
<xs:element name="id" type="atom:idType"/>
<xs:element name="link" type="atom:linkType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="link" type="atom:secondLinkType" minOccurs="1" maxOccurs="unbounded"/>
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
<xs:attributeGroup ref="atom:commonAttributes"/>
</xs:complexType>
<xs:simpleType name="KnownRelCodeType">
<xs:restriction base="xs:string">
<xs:enumeration value="alternate">
<xs:annotation>
<xs:documentation>
The value "alternate" signifies that the IRI in the value of the href attribute identifies an alternate version of the resource described by the containing element.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="SecondKnownRelCodeType">
<xs:restriction base="xs:string">
<xs:enumeration value="amphtml">
<xs:annotation>
<xs:documentation>
The value "amphtml" signifies that....
</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="RelCodeType">
<xs:union memberTypes="atom:KnownRelCodeType xs:string"/>
</xs:simpleType>
<xs:simpleType name="SecondRelCodeType">
<xs:union memberTypes="atom:SecondKnownRelCodeType xs:string"/>
</xs:simpleType>
<xs:complexType name="linkType" mixed="true">
<xs:annotation>
<xs:documentation>
The Atom link construct is defined in section 3.4 of the format spec.
</xs:documentation>
</xs:annotation>
<xs:attribute name="href" type="xs:anyURI" use="required"/>
<xs:attribute name="rel" type="atom:RelCodeType" use="required"/>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attributeGroup ref="atom:commonAttributes"/>
</xs:complexType>
<xs:complexType name="secondLinkType" mixed="true">
<xs:annotation>
<xs:documentation>
complex type for link rel="amphtml"
</xs:documentation>
</xs:annotation>
<xs:attribute name="rel" type="atom:SecondRelCodeType" use="required"/>
<xs:attribute name="href" type="xs:anyURI" use="required"/>
<xs:attributeGroup ref="atom:commonAttributes"/>
<xs:element name="inline:inline" type="inline:inlineType"/>
<xs:attributeGroup ref="atom:commonAttributes"/>
</xs:complexType>