xml - Complex types and XSDs -


Edit: I do not think I asked this question very well. I'm completely re-interpreting it

All: I'm trying to represent the following XML in XSD (I'm working with the Visual Studio XSD editor, Because I do not really know XSD is very well).

 Here is the XML:  & lt; TheParentNode> & lt; ANNlue id = "X"> 123 & lt; / AnElement> & lt; / TheParentNode>  

I want to specify that the value of the annelment should be a number. I want to put some specialties in the enlightenment.

What kind of XSD should you look like?

In Visual Studio Designer, I can see how the annexation can make a complex type, and it seems the only way to define the attributes for it, however, if I do this, There is no way to specify that the value of the annex should be a number.

Do I need to use complex types? What does your XSD code look like?

You have to define a complex type a simpleContent < / Code> with:

  & lt; Xs: element name = "anElement" & gt; & Lt; XS: complexType & gt; & Lt; XS: simpleContent & gt; & Lt; X: extension base = "x: int" & gt; & Lt; Xs: attribute name = "id" type = "x: string" /> & Lt; / XS: Expansion & gt; & Lt; / XS: simpleContent & gt; & Lt; / XS: complexType & gt; & Lt; / XS: element & gt;  

This should do the trick and I am afraid that this is the only way to achieve it. Is this really bad ??

Update: After your update, this is the required XSD:

  & lt; Xs: Schema ID = "The Western Knot" xmlns = "" xmlns: xs = "http://www.w3.org/2001/XMLSchema" & gt; & Lt; Xs: element name = "The parallel node" & gt; & Lt; XS: complexType & gt; & Lt; XS: Sequence & gt; & Lt; Xs: element name = "unallribute" & gt; & Lt; XS: complexType & gt; & Lt; XS: simpleContent & gt; & Lt; X: extension base = "x: int" & gt; & Lt; Xs: attribute name = "id" type = "x: string" /> & Lt; / XS: Expansion & gt; & Lt; / XS: simpleContent & gt; & Lt; / XS: complexType & gt; & Lt; / XS: element & gt; & Lt; / XS: sequence & gt; & Lt; / XS: complexType & gt; & Lt; / XS: element & gt; & Lt; / XS: Schema & gt;  

You know I hope that if you have the XML file open in the Visual Studio, then you can go to the "XML" menu and choose "Create Schema" from this? This usually gives you a good start for your XSD files

Mark


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -