Edit: I don’t think I asked this question very well. I’m completely re-phrasing it
All:
I am trying to represent the following XML in XSD (I’m working with the Visual Studio XSD editor, as I really don’t know XSD very well).
Here's the XML:
<TheParentNode>
<AnElement ID="x">123</AnElement>
</TheParentNode>
I want to specify that the value of AnElement must be a number. I also want to put some attributes into AnElement.
What should the XSD look like?
In the Visual Studio designer, I can see how to make AnElement a complex type, and that seems to be the only way to define attributes for it. However, if I do that, I don’t see a way to specify that the value of AnElement must be a number.
Do I need to use complex types? What would your XSD code look like?
You need to define a
complexTypewith asimpleContent:That should do the trick. And I’m afraid that’s the only way to achieve this. Is it really so bad??
UPDATE:
After your update, this is the XSD you’ll need:
You are aware I hope that if you have the XML file open in Visual Studio, you can go to the “XML” menu and pick “Create schema” from it? That does give you a good start usually for your XSD files.
Marc