XML Schema - Element with string, attribute and a sequence?



I have an element in my XML data that has an attribute AND string, as well as a child sequence. Is there anyway to correctly write a .XSD schema to validate this?



<ygg:Attr name="JournalTitleFull">Nature</ygg:Attr>
<ygg:Attr name="JournalIssue">7534</ygg:Attr>
<ygg:Attr name="DOI">10.1038/nature14094</ygg:Attr>
<ygg:Attr name="Year">2015</ygg:Attr>
<ygg:Attr name="JournalTitle">Nature</ygg:Attr>
<ygg:Attr name="Month">Jan</ygg:Attr>
<ygg:Attr name="Day">15</ygg:Attr>
<ygg:Attr name="JournalVolume">517</ygg:Attr>
<ygg:Attr name="Authors">
<ygg:Value>Neppl, S</ygg:Value><ygg:Value>Ernstorfer, R</ygg:Value>


An excerpt from my schema is below but misses the strings of the element (i.e. Nature, 7534, 10.1038/nature14094 etc from above). Any attempt to add the strings to the element renders me unable to add either the attribute and/or child sequence.



<xs:element name="Attr">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="ygg:Value"/>
</xs:sequence>
<xs:attribute name="name" use="required" type="xs:NCName"/>
</xs:complexType>
</xs:element>
<xs:element name="Value" type="xs:string"/>


Note - "ygg:Attr" is defined as a sequence earlier in the schema


Any help would be much appreciated. Please note this is a re-formulated question from earlier, as my prior question caused confusion. Thanks very much!


No comments:

Post a Comment