ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hudson (JIRA)" <>
Subject [jira] [Commented] (XMLSCHEMA-56) Element defined in a base type sometimes isn't visited by an XmlSchemaWalker's visitor
Date Sat, 01 Jun 2019 08:07:00 GMT


Hudson commented on XMLSCHEMA-56:

SUCCESS: Integrated in Jenkins build xmlschema-trunk-analysis #43 (See [])
XMLSCHEMA-56 - Element defined in a base type sometimes isn't visited by an XmlSchemaWalker's
visitor. Thanks to kgi. This closes #4. (coheigea: rev 1860436)
* (add) xmlschema-walker/src/main/java/org/apache/ws/commons/schema/walker/
* (edit) xmlschema-walker/src/main/java/org/apache/ws/commons/schema/walker/
* (edit) xmlschema-walker/src/main/java/org/apache/ws/commons/schema/walker/
* (add) xmlschema-walker/src/test/java/org/apache/ws/commons/schema/walker/
* (edit) xmlschema-walker/src/test/java/org/apache/ws/commons/schema/walker/
* (add) xmlschema-walker/src/test/resources/test_mfpn2_included1.xsd
* (add) xmlschema-walker/src/test/resources/test_mfpn2_included2.xsd
* (add) xmlschema-walker/src/test/resources/test_mfpn_included1.xsd
* (add) xmlschema-walker/src/test/resources/test_mfpn_included2.xsd
* (add) xmlschema-walker/src/test/resources/test_mfpn_included3.xsd
* (add) xmlschema-walker/src/test/resources/test_multiple_files_per_namespace.xsd
* (add) xmlschema-walker/src/test/resources/test_multiple_files_per_namespace2.xsd

> Element defined in a base type sometimes isn't visited by an XmlSchemaWalker's visitor
> --------------------------------------------------------------------------------------
>                 Key: XMLSCHEMA-56
>                 URL:
>             Project: XmlSchema
>          Issue Type: Bug
>    Affects Versions: 2.2.3, 2.2.4
>         Environment: openSUSE Leap 15
> open-jdk 11 (but I've tried 1.8 and same thing happens)
> xmlschema 2.2.3 and 2.2.4 (core and walker)
>            Reporter: Kevin
>            Assignee: Colm O hEigeartaigh
>            Priority: Major
>             Fix For: 2.2.5
>         Attachments: walk2.tar
> EDIT 9 May 2019: I have found the source of this bug. It is in the
package. Here, both the XmlSchemaWalker and XmlSchemaScope classes use HashMaps to store XmlSchemas
indexed by namespace. For example, in the XmlSchemaWalker's first constructor, each schema
in the given XmlSchemaCollection (the argument) is added to schemasByNamespace (the HashMap).
The problem is that if two or more xsd files have schemas with the same target namespace (which
is legal, and indeed useful), and they are in the schema collection (e.g. one file is included
by another using <xs:include>), each call to schemasByNamespace.put(namespace, schema)
will overwrite the previously put schema for that namespace. Then, for example, when XmlSchemaScope
looks up a schema by namespace and calls schema.getTypeByName(...) around line 326 that type
will not be found unless it was defined in the last schema for that namespace to be stored
in the Map. This results in the behaviour I reported, where an element in a base type (i.e.
one which was extended using <xs:extension>) was not visited by the walker: the base
type was not found because a schema with the same target namespace defined in an included
xsd file was found in the map instead of the one defining the type.
> One way to remedy this is for the schemasByNamespace member variables in both XmlSchemaWalker
and XmlSchemaScope to store a list of schemas for each namespace, i.e. be a Map<String,
List<XmlSchema>> rather than a Map<String, XmlSchema>. Then, whenever looking
up, for example, a type defined in a schema with a certain namespace, access the list of XmlSchemas
using schemasByNamespace.get(namespace), and then iterate through the list of schemas calling
getTypeByName(...) until the type in question is found.
> --- original bug report:
> (EDIT: I have attached a new version of the project (walk2.tar) which takes the path
to the xsd files as a command line argument. It should now be possible to use the .class files
without recompiling.)
> Hi,
> I have a strange issue where the element in a base type (i.e. one which is extended
by another type) is not visited by the xmlschema-walker. It is strange because it only happens
in some instances of the test project (i.e. when I copy all project files to a new directory
it will sometimes happen in that directory and sometimes not!). I cannot for the life of me
discern a pattern.
> This occurs with both 2.2.3 and 2.2.4 of xmlschema (core and walker). I am on openSUSE
Leap 15 and openjdk 11 (but I've tried 1.8 and same thing happens).
> Please see my attached tar file. There are two xsd files in the "xsd" directory. The
first is "test.xsd". It defines a type "Test" which extends the type "Base". The type "Base"
has an element "baseElement". The "test.xsd" file also includes another xsd file "unused.xsd"
which is empty, but the behaviour also occurred when "unused.xsd" defined a used type, I just
simplified that part away for this test. My java file "" creates an "XmlSchemaWalker"
with a visitor "MyVisitor". "MyVisitor" prints the element name when it visits an element.
The file "myOutput" shows what happens when I compile and run the test.
> *The bug I'm seeing* is that "baseElement" is not visited by the visitor in some instances
of the project. The root element ("test") is visited. If "baseElement" is visited when you
test the project, please create a few directories, copy the project files into each, and see
if you can reproduce the error (this is what I mean by "instances" of the project). *NOTE:*
you must provide as an argument to the program the full path to the xsd files which are in
the "xsd" subdirectory of the project. You'll also need xmlschema-core and xmlschema-walker
jar files on the classpath.
> I hope you can reproduce the bug. Please let me know if you need more info.
> cheers,
> Kevin.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message