简体   繁体   中英

Xml Sample Generator - Wrong output?

I am trying to generate a sample xml from a given xsd at runtime. For this purpose I am using the XML Sample Generator which can be found here.

It works great and everything, however i noticed that the output created differs from the output created by the default xml generator utilized by Visual Studio. You can see the difference in the picture (just a sample).

左边是Xml Sample Generator的输出,右边是VS 2012的输出

Does anybody have experience with the Sample Generator and could tell me what factor decides between generating a node and not generating a node in each generator? Also, is it possible to tell the XML Sample Generator to create EVERY possible node, up the maxOccurs defined in the corresponding xsd?

In the general case, no, it's not possible for any sample generator to create every possible node. The maximum number of occurrences of an element may be unbounded, and an element which is allowed to occur only once may offer a choice of child a or child b , without allowing both.

The obvious way to generate samples is to allow some run-time configuration of policy (take the first alternative? take the longest alternative? take the simplest alternative? choose arbitrarily?) and use a random number generator to make choices when choices must be made. It would surprise me if two samples generated at different times by the same generator were alike; it would surprise me even more if two different generators generated identical samples for any non-trivial grammar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM