[
https://issues.apache.org/jira/browse/WSCOMMONS-24?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486681
]
Markus Schuch commented on WSCOMMONS-24:
----------------------------------------
Hi,
I currently use this API and i can confirm Peter's analysis. The attribute
groupe table is also affected by this issue.
Location:
class: org.apache.ws.commons.schema.SchemaBuilder
(http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java?view=markup)
in method: handleXmlSchemaElement(...)
168: ...
169: } else if (el.getLocalName().equals("group")) {
170: XmlSchemaGroup group = handleGroup(schema, el, schemaEl);
171: schema.groups.collection.put(group.name, group); // <-- here the
group table is filled with keys of type string
172: schema.items.add(group);
173: } ...
Instead of "group.name" something like "new QName(schema.getTargetNamespace(),
group.name)" has to be used as key object since a specific item in a
XmlSchemaObjectTable can only be accessed with a key of type QName:
XmlSchemaObjectTable.getItem(QName name)
(I am not sure if the "schema.getTargetNamespace()" is the correct solution for
all cases.)
Same for AttributeGroups in lines 173-177
Hope this helps!
Regards,
Markus
> Schema "groups" XmlSchemaObjectTable is filled using invalid HashMap keys
> -------------------------------------------------------------------------
>
> Key: WSCOMMONS-24
> URL: https://issues.apache.org/jira/browse/WSCOMMONS-24
> Project: WS-Commons
> Issue Type: Bug
> Components: XmlSchema
> Environment: WS Commons XML Schema 1.0.2
> Reporter: Peter Hendriks
>
> The XmlSchemaObjectTable retrieved using XmlSchema.getGroups() is filled in
> SchemaBuilder by using the package scope collection variable instead of its
> public API. For groups and attribute groups a key of the wrong type is used
> (String instead of QName).
> As a result groups cannot be accessed using the public API, because you can
> only query using a QName, and the keys are only Strings. As a result groups
> cannot be read by key and the API is broken.
> The issue can be worked around by using the getValues() method to search
> through all groups directly.
> This should be very easy to fix and I am willing to provide a patch. The code
> is riddled with package scoped fields and methods. This is generally bad
> practice because of these kinds of problems. Please consider refactoring the
> code to more restrictive field/method scoping to have a cleaner API and
> prevent errors.
--
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]