How would I properly define my element RandomAmount_
//when RandomAmount can be RandomAmount_1 to RandomAmount_N
<xs:element name="RandomAmount">
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element type="xs:float" name="RandomAmount_" />
</xs:choice>
</xs:complexType>
</xs:element>
I feel that RandomAmount should be named = ” RandomAmount_* ” to do the trick, but that doesn’t work.
XSD element declarations must specify a single name for the element; there is no provision for families of names of the kind you apparently are looking for.
It’s not clear what to advise you to do, mostly because it’s not clear why you want to have numbers in the names of your elements. If you want to return the value of a call to a random-number generator, by naming an element
RandomAmount_1419when the random number generator returns the value 1419, then I’d advise you just to name the elementRandomAmountand return the value in the element’s content, or in an attribute.If on the other hand you want the numbers so that the children of the parent
RandomAmountelement will be namedRandomAmount_1,RandomAmount_2,RandomAmount_3, etc., then my advice would still be the same: just give all the children the same name, and let your data be (for example):There is no need to give the children different names; indeed, if all the children contain the same kind of information (I’m guessing from your naming that they contain random numbers), it’s almost always better practice not to give them different names. (If you need to be able to refer to the third number in the sequence, XPath has simple ways to do that; if you are mapping into an object system that cannot handle multiple child elements with the same name, get a better object mapping system.)