VS2005 doesn't like my XML Schema
-
I am using Visual Studio 2005 to create my first XML Schema. Generally it's going well. The intellisense in VS is very helpful. My only issue is that VS is flagging the element "Well" in my example, saying "The type attribute cannot be present with either simpleType or complexType." I'm not sure how to structure it if this way isn't acceptable. I've also included a XML snippet of what I am trying define in the schema. Any help appreciated.
<xsd:element name="Well\_Volumes"> <xsd:complexType> <xsd:sequence> <xsd:element name="Well" type="xsd:decimal"> <xsd:complexType> <xsd:attribute name="channel" type="xsd:string"/> <xsd:attribute name="dispense\_order" type="xsd:string"/> <xsd:attribute name="plate\_column" type="xsd:string"/> <xsd:attribute name="plate\_row" type="xsd:string"/> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <Well\_Volumes> <Well channel="A" dispense\_order="1" plate\_column="1" plate\_row="1">0.209</Well> <Well channel="A" dispense\_order="2" plate\_column="2" plate\_row="1">0.212</Well> <Well channel="A" dispense\_order="3" plate\_column="3" plate\_row="1">0.219</Well> <Well channel="B" dispense\_order="1" plate\_column="4" plate\_row="2">0.212</Well> <Well channel="B" dispense\_order="2" plate\_column="5" plate\_row="2">0.222</Well> <Well channel="B" dispense\_order="3" plate\_column="6" plate\_row="2">0.212</Well> </Well\_Volumes>
-
I am using Visual Studio 2005 to create my first XML Schema. Generally it's going well. The intellisense in VS is very helpful. My only issue is that VS is flagging the element "Well" in my example, saying "The type attribute cannot be present with either simpleType or complexType." I'm not sure how to structure it if this way isn't acceptable. I've also included a XML snippet of what I am trying define in the schema. Any help appreciated.
<xsd:element name="Well\_Volumes"> <xsd:complexType> <xsd:sequence> <xsd:element name="Well" type="xsd:decimal"> <xsd:complexType> <xsd:attribute name="channel" type="xsd:string"/> <xsd:attribute name="dispense\_order" type="xsd:string"/> <xsd:attribute name="plate\_column" type="xsd:string"/> <xsd:attribute name="plate\_row" type="xsd:string"/> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <Well\_Volumes> <Well channel="A" dispense\_order="1" plate\_column="1" plate\_row="1">0.209</Well> <Well channel="A" dispense\_order="2" plate\_column="2" plate\_row="1">0.212</Well> <Well channel="A" dispense\_order="3" plate\_column="3" plate\_row="1">0.219</Well> <Well channel="B" dispense\_order="1" plate\_column="4" plate\_row="2">0.212</Well> <Well channel="B" dispense\_order="2" plate\_column="5" plate\_row="2">0.222</Well> <Well channel="B" dispense\_order="3" plate\_column="6" plate\_row="2">0.212</Well> </Well\_Volumes>
Thanks everyone, but never mind. Although it makes perfect sense to me, apparently an element can not include both attributes and a value. Hmmm... Maybe in the next version. Below is how I am fixing the problem.
<xsd:element name="Well\_Volumes"> <xsd:complexType> <xsd:sequence> <xsd:element name="Well"> <xsd:complexType> <xsd:sequence> <xsd:element name="volume" type="xsd:decimal"/> </xsd:sequence> <xsd:attribute name="channel" type="xsd:string"/> <xsd:attribute name="dispense\_order" type="xsd:string"/> <xsd:attribute name="plate\_column" type="xsd:string"/> <xsd:attribute name="plate\_row" type="xsd:string"/> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element>
-
I am using Visual Studio 2005 to create my first XML Schema. Generally it's going well. The intellisense in VS is very helpful. My only issue is that VS is flagging the element "Well" in my example, saying "The type attribute cannot be present with either simpleType or complexType." I'm not sure how to structure it if this way isn't acceptable. I've also included a XML snippet of what I am trying define in the schema. Any help appreciated.
<xsd:element name="Well\_Volumes"> <xsd:complexType> <xsd:sequence> <xsd:element name="Well" type="xsd:decimal"> <xsd:complexType> <xsd:attribute name="channel" type="xsd:string"/> <xsd:attribute name="dispense\_order" type="xsd:string"/> <xsd:attribute name="plate\_column" type="xsd:string"/> <xsd:attribute name="plate\_row" type="xsd:string"/> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <Well\_Volumes> <Well channel="A" dispense\_order="1" plate\_column="1" plate\_row="1">0.209</Well> <Well channel="A" dispense\_order="2" plate\_column="2" plate\_row="1">0.212</Well> <Well channel="A" dispense\_order="3" plate\_column="3" plate\_row="1">0.219</Well> <Well channel="B" dispense\_order="1" plate\_column="4" plate\_row="2">0.212</Well> <Well channel="B" dispense\_order="2" plate\_column="5" plate\_row="2">0.222</Well> <Well channel="B" dispense\_order="3" plate\_column="6" plate\_row="2">0.212</Well> </Well\_Volumes>
You need a simpleContent[^] element as a child of the complexType. Then extend the simple type with attributes - like this:
<xsd:element name="Well_Volumes">
xsd:complexType
<xsd:sequence maxOccurs="unbounded"><xsd:element name="Well"> <xsd:complexType> <xsd:simpleContent> <xsd:extension base="xsd:decimal"> <xsd:attribute name="channel" type="xsd:string"/> <xsd:attribute name="dispense\_order" type="xsd:string"/> <xsd:attribute name="plate\_column" type="xsd:string"/> <xsd:attribute name="plate\_row" type="xsd:string"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> </xsd:element> </xsd:sequence>
</xsd:complexType>
</xsd:element>Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!