variable values generated for fixed elements in XSD
GoogleCodeExporter opened this issue · 1 comments
GoogleCodeExporter commented
What steps will reproduce the problem?
1. Select a XSD with a fixed element in it. See e.g. attached file.
2. Generate instance from XSD using XSInstance
3. Validate generated instance against XSD
What is the expected output? What do you see instead?
The validation fails. I would like the validation to pass.
What version of the product are you using? On what operating system?
The latest version from the svn archieve.
On windows.
Please provide any additional information below.
You can use the following code for JLIBS under the LGPL license when I am
acknowledge as co-author either in the file or (as currently illustrated) above
the function:
/**
* @author Santhosh Kumar T
* @author Pierre van de Laar - TNO-ESI
*/
public void postProcess(XSElementDeclaration elem, Path path){
if(path.getRecursionDepth()>2)
return;
try{
XSSimpleTypeDefinition simpleType = null;
if(elem.getTypeDefinition().getTypeCategory()==XSTypeDefinition.SIMPLE_TYPE)
simpleType = (XSSimpleTypeDefinition)elem.getTypeDefinition();
else{
XSComplexTypeDefinition complexType = (XSComplexTypeDefinition)elem.getTypeDefinition();
if(complexType.getContentType()==XSComplexTypeDefinition.CONTENTTYPE_SIMPLE)
simpleType = complexType.getSimpleType();
}
if(simpleType!=null){
String sampleValue = null;
switch(elem.getConstraintType()){
case XSConstants.VC_FIXED:
if(RandomUtil.randomBoolean(generateFixedAttributes)) //TODO: introduce generateFixedElements? sampleValue = elem.getValueConstraintValue().getNormalizedValue();
break;
case XSConstants.VC_DEFAULT:
if(RandomUtil.randomBoolean(generateDefaultAttributes)) //TODO: introduce generateDefaultElements?
sampleValue = elem.getValueConstraintValue().getNormalizedValue();
break;
default:
sampleValue = null;
}
if(sampleValueGenerator!=null)
sampleValue = sampleValueGenerator.generateSampleValue(elem, simpleType);
if(sampleValue==null)
sampleValue = generateSampleValue(simpleType, elem.getName());
doc.addText(sampleValue);
}
doc.endElement();
}catch(SAXException ex){
throw new ImpossibleException(ex);
}
}
Original issue reported on code.google.com by Pierre.v...@gmail.com
on 19 Dec 2013 at 12:54
Attachments:
GoogleCodeExporter commented
FIXED in r1781
Original comment by santhosh.tekuri@gmail.com
on 20 Dec 2013 at 10:43
- Changed state: Fixed