Is there a way to remove magic numbers from a XML Schema?
I have a WSDL with some types defined. Some elements accept lists of elements and on the service return I also have elements with list of values (or other elements).
As a result I have some magic numbers in the XSD (开发者_运维知识库e.g. minOccurs="10", maxOccurs="250" etc). These values 10, 250 etc are repeated throughout the XSD types.
Is there a way to declare them as some sort of constants? and then reuse them by name for the minOccurs and maxOccurs attributes?
No there isn't. The only thing you could do is to pre-process the schema using some sort of template processor before loading.
XSD is XML so you could use entities defined in a DTD:
minOccurs="&minOccurs;"
精彩评论