You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by "Ajith Harshana Ranabahu (JIRA)" <ji...@apache.org> on 2007/04/06 09:24:32 UTC

[jira] Resolved: (WSCOMMONS-102) XSD parsing not functioning properly for Enumerations

     [ https://issues.apache.org/jira/browse/WSCOMMONS-102?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ajith Harshana Ranabahu resolved WSCOMMONS-102.
-----------------------------------------------

    Resolution: Fixed

The code is added. Thanks for the contribution

> XSD parsing not functioning properly for Enumerations
> -----------------------------------------------------
>
>                 Key: WSCOMMONS-102
>                 URL: https://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.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org