From dev-return-18659-archive-asf-public=cust-asf.ponee.io@ws.apache.org Fri May 31 08:26:03 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id CA2A7180627 for ; Fri, 31 May 2019 10:26:02 +0200 (CEST) Received: (qmail 7170 invoked by uid 500); 31 May 2019 08:26:02 -0000 Mailing-List: contact dev-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ws.apache.org Delivered-To: mailing list dev@ws.apache.org Received: (qmail 7159 invoked by uid 99); 31 May 2019 08:26:01 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 May 2019 08:26:01 +0000 Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 43834E0E4C for ; Fri, 31 May 2019 08:26:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id CF77E24599 for ; Fri, 31 May 2019 08:26:00 +0000 (UTC) Date: Fri, 31 May 2019 08:26:00 +0000 (UTC) From: "Colm O hEigeartaigh (JIRA)" To: dev@ws.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (XMLSCHEMA-56) Element defined in a base type sometimes isn't visited by an XmlSchemaWalker's visitor MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/XMLSCHEMA-56?page=3Dcom.atlass= ian.jira.plugin.system.issuetabpanels:all-tabpanel ] Colm O hEigeartaigh resolved XMLSCHEMA-56. ------------------------------------------ Resolution: Fixed > Element defined in a base type sometimes isn't visited by an XmlSchemaWal= ker's visitor > -------------------------------------------------------------------------= ------------- > > Key: XMLSCHEMA-56 > URL: https://issues.apache.org/jira/browse/XMLSCHEMA-56 > 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:=C2=A0I have found the source of this bug. It is in the o= rg.apache.ws.commons.schema.walker package. Here, both the XmlSchemaWalker = and XmlSchemaScope classes use HashMaps to store XmlSchemas indexed by name= space. For example, in the XmlSchemaWalker's first constructor, each schema= in the given XmlSchemaCollection (the argument) is added to schemasByNames= pace (the HashMap). The problem is that if two or more xsd files have schem= as 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 usi= ng ), each call to schemasByNamespace.put(namespace, schema) wi= ll overwrite the previously put schema for that namespace. Then, for exampl= e, when XmlSchemaScope looks up a schema by namespace and calls schema.getT= ypeByName(...) around line 326 that type will not be found unless it was de= fined in the last schema for that namespace to be stored in the Map. This r= esults in the behaviour I reported, where an element in a base type (i.e. o= ne which was extended using ) 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 de= fining 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> rather than a Map. Then, whenever looking up, for example, a type defined in a s= chema with a certain namespace, access the list of XmlSchemas using schemas= ByNamespace.get(namespace), and then iterate through the list of schemas ca= lling getTypeByName(...) until the type in question is found. > --- original bug report: > (EDIT: I have attached a new version of the project (walk2.tar) which tak= es the path to the xsd files as a command line argument. It should now be p= ossible to use the .class files without recompiling.) > Hi, > I have a strange issue where the=C2=A0element in a base type (i.e. one wh= ich 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 hap= pen in that directory and sometimes not!). I cannot for the life of me disc= ern a pattern. > This occurs with both 2.2.3 and 2.2.4 of xmlschema (core and walker). I a= m on openSUSE Leap 15 and openjdk 11 (but I've tried 1.8 and same thing hap= pens). > Please see my=C2=A0attached tar file. There are two xsd files in the "xsd= " directory. The first is "test.xsd". It defines a type "Test" which extend= s 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 t= he behaviour also occurred when "unused.xsd" defined a used type, I just si= mplified that part away for this test. My java file "Main.java" creates an = "XmlSchemaWalker" with a visitor "MyVisitor". "MyVisitor" prints the elemen= t name when it visits an element. The file "myOutput" shows what happens wh= en 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 dir= ectories, copy the project files into each, and see if you can reproduce th= e error (this is what I mean by "instances" of the project). *NOTE:* you mu= st provide as an argument to the program the full path to the xsd files whi= ch=C2=A0are in the "xsd" subdirectory of the project. You'll also need xmls= chema-core and xmlschema-walker jar files on the classpath. > I hope you can reproduce the bug. Please let me know if you need more inf= o. > cheers, > Kevin. > =C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org For additional commands, e-mail: dev-help@ws.apache.org