I have an XSD file including some patterns and need to create a bunch of XML documents for testing matching this schema. I know there are some tools and frameworks out there like xsd.exe, JAXB, etc. which create classes out of the XSD.
Basically I need to do the following steps:
- Load XSD
- Parse XSD
- Create matching XML document
Example:
<xs:simpleType name="typeName">
<xs:restriction base="xs:string">
<xs:pattern value="[A-ZÄÖÜß][A-ZÄÖÜß'/\-.+ ]*"/>
<xs:pattern value="+[ ]*"/>
</xs:restriction>
</xs:simpleType>
What would be a standard way doing this? The point is that all this shall happen at runtime, i.e. not creating classes via xsd.exe or else. Preferrably in C# or Java but any language is welcome.
Microsoft has something called the XmlSampleGenerator. Check this out:
http://msdn.microsoft.com/en-us/library/aa302296.aspx
here are it’s limitations:
xs:unique) are not supported while generating an instance document.
conform to the pattern.
work as expected since this requires the prefixes in the schema to be
preserved.
supported.
exist in the schema for that type.