XSD parsing not functioning properly for Enumerations
-----------------------------------------------------
Key: WSCOMMONS-102
URL: http://issues.apache.org/jira/browse/WSCOMMONS-102
Project: WS-Commons
Issue Type: Bug
Components: XmlSchema
Environment: Windows XP, Java project using XmlSchema1.1
Reporter: Dave MacLean
(As sent to the email list)
Hello there,
We're using the XmlSchema library to "simplify" some of our XSDs so that they
appear in a nicer format when included in WSDL files for our exposed web
services. When writing a utility to manage the simplification process, I ran
into a minor bug in XmlSchema. If an enumeration is present that contains id
values, the id values are lost when parsed:
<xs:simpleType name="RoleEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="ADVANCED"
id="RoleEnum_0"/>
<xs:enumeration value="NO_ACCESS"
id="RoleEnum_1"/>
<xs:enumeration value="VIEW"
id="RoleEnum_2"/>
</xs:restriction>
</xs:simpleType>
Just as an example. When parsed, the "facet" objects representing the enum
values will have an empty "id" string.
To fix this, I added the following code to XmlSchemaFacet.java (new code is in
bold):
public static XmlSchemaFacet construct(Element el) {
String name = el.getLocalName();
boolean fixed = false;
if (el.getAttribute("fixed").equals("true")) {
fixed = true;
}
XmlSchemaFacet facet;
if (name.equals("enumeration")) {
facet = new XmlSchemaEnumerationFacet();
} else if (name.equals("fractionDigits")) {
facet = new XmlSchemaFractionDigitsFacet();
} else if (name.equals("length")) {
facet = new XmlSchemaLengthFacet();
} else if (name.equals("maxExclusive")) {
facet = new XmlSchemaMaxExclusiveFacet();
} else if (name.equals("maxInclusive")) {
facet = new XmlSchemaMaxInclusiveFacet();
} else if (name.equals("maxLength")) {
facet = new XmlSchemaMaxLengthFacet();
} else if (name.equals("minLength")) {
facet = new XmlSchemaMinLengthFacet();
} else if (name.equals("minExclusive")) {
facet = new XmlSchemaMinExclusiveFacet();
} else if (name.equals("minInclusive")) {
facet = new XmlSchemaMinInclusiveFacet();
} else if (name.equals("pattern")) {
facet = new XmlSchemaPatternFacet();
} else if (name.equals("totalDigits")) {
facet = new XmlSchemaTotalDigitsFacet();
} else if (name.equals("whiteSpace")) {
facet = new XmlSchemaWhiteSpaceFacet();
} else {
throw new XmlSchemaException("Incorrect facet with name \""
+ name + "\" found.");
}
//Begin additions
if (el.hasAttribute("id"))
{
facet.setId(el.getAttribute("id"));
}
//End additions
facet.setFixed(fixed);
facet.setValue(el.getAttribute("value"));
return facet;
}
This seems like the correct fix. Is it possible to get this fix added for
future XmlSchema releases?
The source I modified was the packaged XmlSchema-1.1 source.
Thanks in advance,
Dave
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]