Author: kiwiwings Date: Thu Jan 6 22:56:11 2022 New Revision: 1896770 URL: http://svn.apache.org/viewvc?rev=1896770&view=rev Log: XMLBEANS-416 - Allow referencing cross-xsd usertypes no test code supplied and on a second thought, the build would have need to be rearranged to allow cross-xsd invocations. The code changes are minimal enough to commit with the other tests being "green".
Modified: xmlbeans/site/src/documentation/content/xdocs/status.xml xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/config/BindingConfigImpl.java xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java Modified: xmlbeans/site/src/documentation/content/xdocs/status.xml URL: http://svn.apache.org/viewvc/xmlbeans/site/src/documentation/content/xdocs/status.xml?rev=1896770&r1=1896769&r2=1896770&view=diff ============================================================================== --- xmlbeans/site/src/documentation/content/xdocs/status.xml (original) +++ xmlbeans/site/src/documentation/content/xdocs/status.xml Thu Jan 6 22:56:11 2022 @@ -49,6 +49,7 @@ <release version="5.1.0" date="2022-03-??"> <actions> <action dev="PD" type="update" context="code" fixes-bug="XMLBEANS-586">Migrate ant build to gradle</action> + <action dev="PD" type="update" context="code" fixes-bug="XMLBEANS-416">Allow referencing cross-xsd usertypes</action> </actions> </release> Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/config/BindingConfigImpl.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/config/BindingConfigImpl.java?rev=1896770&r1=1896769&r2=1896770&view=diff ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/config/BindingConfigImpl.java (original) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/config/BindingConfigImpl.java Thu Jan 6 22:56:11 2022 @@ -309,6 +309,10 @@ public class BindingConfigImpl extends B return qname == null ? null : _userTypes.get(qname); } + public UserType[] getUserTypes() { + return this._userTypes.values().toArray(new UserType[0]); + } + public InterfaceExtension[] getInterfaceExtensions() { return _interfaceExtensions.toArray(new InterfaceExtension[0]); } Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java?rev=1896770&r1=1896769&r2=1896770&view=diff ============================================================================== --- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java (original) +++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java Thu Jan 6 22:56:11 2022 @@ -15,6 +15,8 @@ package org.apache.xmlbeans.impl.schema; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.common.NameUtil; @@ -24,6 +26,8 @@ import java.util.*; public class StscJavaizer { + private static final Logger LOG = LogManager.getLogger(StscJavaizer.class); + /** * XMLBEANS-307 * if enumeration count is greater than 3668, @@ -81,12 +85,12 @@ public class StscJavaizer { sImpl.setFullJavaName(pickFullJavaClassName(usedNames, findTopName(sImpl), pickedName, sImpl.isDocumentType(), sImpl.isAttributeType())); sImpl.setFullJavaImplName(pickFullJavaImplName(usedNames, sImpl.getFullJavaName())); - setUserTypes(sImpl, state); - setExtensions(sImpl, state); } } + setUserTypes(state); + verifyInterfaceNameCollisions(usedNames, state); } @@ -117,14 +121,18 @@ public class StscJavaizer { } } - private static void setUserTypes(SchemaTypeImpl sImpl, StscState state) { + private static void setUserTypes(StscState state) { BindingConfig config = state.getBindingConfig(); if (config != null) { - UserType utype = config.lookupUserTypeForQName(sImpl.getName()); - if (utype != null) { - sImpl.setUserTypeName(utype.getJavaName()); - sImpl.setUserTypeHandlerName(utype.getStaticHandler()); + for (UserType utype : config.getUserTypes()) { + SchemaTypeImpl sImpl = state.findGlobalType(utype.getName(), null, null); + if (sImpl != null) { + sImpl.setUserTypeName(utype.getJavaName()); + sImpl.setUserTypeHandlerName(utype.getStaticHandler()); + } else { + LOG.atWarn().log("Cannot match user type for {}", utype.getName()); + } } } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org