Question

I want to use a random xml generator tool in order to perform random testing by generating random xml files from xsd. ( I am using Oxygen tool)

The random generator will not apply semantic restrictions on the generated values. for example I have an element "parameters" that has multiple element "parameter" for example p1 and p2 , on the other hand I have another element "constraint" which will using "parameter". I mean if I have P1, P2 , it should use a subset of p1 and p2. I want to force the random generator tool to use them ( p1 and p2) instead of randomly generate some other parameters again for the constraint. I used "key", "keyref" and.. but still it doesnt work. it just generate random string everywhere with out any restrictions , I have to mention that I select the option "values of elements and attributes: Random (apply restrictions) " So it should consider the restriction when generating random values but it doesn't! please help..

SAMPLE of a valid XML:

 <system>
         <parameters>
             <parameter id="1" name="p1" >
                  <value id="1" name="value1"/>
                  <value id="2" name="value2"/>
              </parameter>
              <parameter id="2" name="p2" >
                  <value id="1" name="value1"/>
                  <value id="2" name="value2"/>
              </parameter>
          </parameters>
          <constraint text="p1=p2">
               <parameter name="p1"/>
               <parameter name="p2"/> 
          </constraint>
       </system>

So I want the use subset of parameters that already generated (p1 and p2) ,as you can see in above example ,instead of generating some other random parameters because then all generated xmls are invalid and I want a valid one.

SAMPLE of a invalid XML:

   <system>
         <parameters>
             <parameter id="1" name="p1" >
                  <value id="1" name="value1"/>
                  <value id="2" name="value2"/>
              </parameter>
              <parameter id="2" name="p2" >
                  <value id="1" name="value1"/>
                  <value id="2" name="value2"/>
              </parameter>
          </parameters>
          <constraint text="**p3**=**p5**">
               <parameter name="**p8**"/>
               <parameter name="**p9**"/> 
          </constraint>
       </system>

Thanks

No correct solution

OTHER TIPS

In general, checking identity constraints makes the task of document generation much more complex. (I believe I saw a claim once that it makes it NP complete, but I may have misunderstood.) So I doubt that you are going to have much luck telling Oxygen's example-document generator to obey the constraint you have in mind; most generators content themselves with producing data the satisfies the content models.

You may have better luck writing either a filter to distinguish examples that obey the constraint you have in mind from examples that don't (so you can generate 100 examples and run the filter to find the ones that are usable for your purposes), or a transformation to take an arbitrary example and change it to satisfy your constraint.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top