I'm used to create XML file but quite new to create my own XSD file for validating the XML content. So i want to ask few questions about XSD file.
First, i have an XML file. Now i need to create an XSD file to strictly validate the XML content. But i also want to use the same XSD file to generate some UI in my website for user to input the value. Like for each tag or each attribute within each tag, we will have 1 input, select box, toggle button, etc. After that, using the inputted value and the XSD file structure to generate the XML file.
But now i have a problem with these two case:
I will need a label to show our user what this input field for. I can put an attribute with fixed value in each tag to use it for the label. But the out XML tag doesn't need this attribute. So how can i add something in the XSD file to store the label for each tag without affecting the XML file?
I want to create a dropdown list, choose one of its value and then when generate, the XML file will have the selected value as one of its attribate value. Well to do this, i can use restriction using the enumeration constraint. But sometime the value is hard to understand so i need something else to show instead, like the value is 1 but the text show as "Running" for example. This will be kind of like the above question, but need for the restriction part.
So can anyone help me with these 2 case. What tag, attribute should i use in the XSD file to store these unrelated information to XML file?
Thanks you.
====================================================
Update : To be more specific about my question. So for example i have this in my xsd file
<xs:element name="car">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Audi"/>
<xs:enumeration value="Golf"/>
<xs:enumeration value="BMW"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
This one only have a restricted value to validate the xml tag. But i want to add another value to each enumeration tag to store a label or something like that:
<xs:element name="car">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Audi" label="Option 1"/>
<xs:enumeration value="Golf" label="Option 2"/>
<xs:enumeration value="BMW" label="Option 3"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
And this added thing won't make the xsd file invalid nor effect the validation of the xml file.
============================================================
Update 2:
I would need to use the xsd file to generate UI like this
With the value as value of each option and label as the display text of each option. When user choose for example option 2 which is Golf, the generate xml will be like this:
<car>Golf</car>
So these labels purpose purely to generate the UI, nothing to do with the xml.