diff --git a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/addon/episode/PluginImpl.java b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/addon/episode/PluginImpl.java index 331f0476a..f441f1bec 100644 --- a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/addon/episode/PluginImpl.java +++ b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/addon/episode/PluginImpl.java @@ -160,6 +160,7 @@ public boolean run(Outline model, Options opt, ErrorHandler errorHandler) throws group.scd("x-schema::"+(tns.equals("")?"":"tns")); group._attribute("if-exists", true); + group._attribute("auto-acknowledge", true); SchemaBindings schemaBindings = group.schemaBindings(); schemaBindings.map(false); if (ps.packageNames.size() == 1) { @@ -337,6 +338,7 @@ public OutlineAdaptor(XSComponent schemaComponent, OutlineType outlineType, private void buildBindings(Bindings bindings) { bindings.scd(schemaComponent.apply(SCD)); bindings._attribute("if-exists", true); + bindings._attribute("auto-acknowledge", true); outlineType.bindingsBuilder.build(this, bindings); } } diff --git a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/internalizer/SCDBasedBindingSet.java b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/internalizer/SCDBasedBindingSet.java index 2e6401d3b..dab422212 100644 --- a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/internalizer/SCDBasedBindingSet.java +++ b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/internalizer/SCDBasedBindingSet.java @@ -141,35 +141,43 @@ private void apply(Collection contextNode) { errorReceiver.error( itr.next().getLocator(), Messages.format(Messages.ERR_SCD_MATCHED_MULTIPLE_NODES_SECOND) ); } - // apply bindings to the target - for (Element binding : bindings) { - for (Element item : DOMUtils.getChildElements(binding)) { - String localName = item.getLocalName(); - - if ("bindings".equals(localName)) - continue; // this should be already in Target.bindings of some SpecVersion. - - try { - new DOMForestScanner(forest).scan(item,loader); - BIDeclaration decl = (BIDeclaration)unmarshaller.getResult(); - - // add this binding to the target - XSAnnotation ann = target.getAnnotation(true); - BindInfo bi = (BindInfo)ann.getAnnotation(); - if(bi==null) { - bi = new BindInfo(); - ann.setAnnotation(bi); + Ring old = Ring.begin(); + try { + // apply bindings to the target + for (Element binding : bindings) { + for (Element item : DOMUtils.getChildElements(binding)) { + String localName = item.getLocalName(); + + if ("bindings".equals(localName)) + continue; // this should be already in Target.bindings of some SpecVersion. + + try { + new DOMForestScanner(forest).scan(item,loader); + BIDeclaration decl = (BIDeclaration)unmarshaller.getResult(); + + // add this binding to the target + XSAnnotation ann = target.getAnnotation(true); + BindInfo bi = (BindInfo)ann.getAnnotation(); + if(bi==null) { + bi = new BindInfo(); + ann.setAnnotation(bi); + } + bi.addDecl(decl); + if (src.getAttributeNode("auto-acknowledge") != null) { + target.visit(Ring.get(AcknowledgePluginCustomizationBinder.class)); + } + } catch (SAXException e) { + // the error should have already been reported. + } catch (JAXBException e) { + // if validation didn't fail, then unmarshalling can't go wrong + throw new AssertionError(e); } - bi.addDecl(decl); - target.visit(Ring.get(AcknowledgePluginCustomizationBinder.class)); - } catch (SAXException e) { - // the error should have already been reported. - } catch (JAXBException e) { - // if validation didn't fail, then unmarshalling can't go wrong - throw new AssertionError(e); } } + } finally { + Ring.end(old); } + } } } diff --git a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/BGMBuilder.java b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/BGMBuilder.java index 5e76db8d1..936979c46 100644 --- a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/BGMBuilder.java +++ b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/BGMBuilder.java @@ -44,6 +44,7 @@ import org.glassfish.jaxb.core.api.impl.NameConverter; import org.glassfish.jaxb.core.v2.util.XmlFactory; import com.sun.xml.xsom.XSAnnotation; +import com.sun.xml.xsom.XSAttributeDecl; import com.sun.xml.xsom.XSAttributeUse; import com.sun.xml.xsom.XSComponent; import com.sun.xml.xsom.XSDeclaration; @@ -355,7 +356,7 @@ private void processPackageJavadoc( XSSchema s ) { */ public BindInfo getOrCreateBindInfo( XSComponent schemaComponent ) { - BindInfo bi = _getBindInfoReadOnly(schemaComponent); + BindInfo bi = _getBindInfoReadOnly(schemaComponent, false); if(bi!=null) return bi; // XSOM is read-only, so we cannot add new annotations. @@ -382,10 +383,24 @@ public BindInfo getOrCreateBindInfo( XSComponent schemaComponent ) { * will be returned. */ public BindInfo getBindInfo( XSComponent schemaComponent ) { - BindInfo bi = _getBindInfoReadOnly(schemaComponent); + BindInfo bi = _getBindInfoReadOnly(schemaComponent, false); if(bi!=null) return bi; else return emptyBindInfo; } + /** + * Gets the documentation object associated to a schema component. + * + * @return + * return the documentation tag for the given component, null if none found + */ + public String getDocumentation( XSComponent schemaComponent ) { + BindInfo bi = _getBindInfoReadOnly(schemaComponent, true); + if (bi != null) { + String doc = bi.getDocumentation(); + return doc == null ? null : doc.trim(); + } + return null; + } /** * Gets the BindInfo object associated to a schema component. @@ -393,33 +408,44 @@ public BindInfo getBindInfo( XSComponent schemaComponent ) { * @return * null if no bind info is associated to this schema component. */ - private BindInfo _getBindInfoReadOnly( XSComponent schemaComponent ) { + private BindInfo _getBindInfoReadOnly( XSComponent schemaComponent, boolean extended ) { BindInfo bi = externalBindInfos.get(schemaComponent); if(bi!=null) return bi; - XSAnnotation annon = _getXSAnnotation(schemaComponent); - if(annon!=null) { - bi = (BindInfo)annon.getAnnotation(); - if(bi!=null) { - if(bi.getOwner()==null) - bi.setOwner(this,schemaComponent); - return bi; - } + XSAnnotation annon = _getXSAnnotation(schemaComponent, extended); + if (annon != null) { + return (BindInfo) annon.getAnnotation(); } return null; } - private XSAnnotation _getXSAnnotation(XSComponent schemaComponent) { + private XSAnnotation _getXSAnnotation(XSComponent schemaComponent, boolean extended) { XSAnnotation annon = schemaComponent.getAnnotation(); if (annon != null) { - return annon; + return enhanceBindInfo(annon, schemaComponent); } - if (schemaComponent instanceof XSParticle) { - annon = ((XSParticle) schemaComponent).getTerm().getAnnotation(); - } else if (schemaComponent instanceof XSAttributeUse) { - annon = ((XSAttributeUse) schemaComponent).getDecl().getAnnotation(); + if (extended) { + if (schemaComponent instanceof XSParticle) { + XSTerm term = ((XSParticle) schemaComponent).getTerm(); + return enhanceBindInfo(term.getAnnotation(), term); + } else if (schemaComponent instanceof XSAttributeUse) { + XSAttributeDecl decl = ((XSAttributeUse) schemaComponent).getDecl(); + return enhanceBindInfo(decl.getAnnotation(), decl); + } + } + return null; + } + + private XSAnnotation enhanceBindInfo(XSAnnotation annon, XSComponent schemaComponent) { + if (annon != null) { + BindInfo bi = (BindInfo) annon.getAnnotation(); + if (bi != null) { + if (bi.getOwner() == null) { + bi.setOwner(this, schemaComponent); + } + } } return annon; } diff --git a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/ClassSelector.java b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/ClassSelector.java index 90fed06fb..a9dc37fad 100644 --- a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/ClassSelector.java +++ b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/ClassSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -366,9 +366,10 @@ public void queueBuild( XSComponent sc, CElement bean ) { private void addSchemaFragmentJavadoc( CClassInfo bean, XSComponent sc ) { // first, pick it up from if any. - String doc = builder.getBindInfo(sc).getDocumentation(); - if(doc!=null) + String doc = builder.getDocumentation(sc); + if (doc != null) { append(bean, doc); + } // then the description of where this component came from Locator loc = sc.getLocator(); diff --git a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/SimpleTypeBuilder.java b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/SimpleTypeBuilder.java index 94b26d7af..47eb72161 100644 --- a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/SimpleTypeBuilder.java +++ b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/SimpleTypeBuilder.java @@ -392,8 +392,9 @@ private TypeUse find( XSSimpleType type ) { } String documentation = ""; - if (info.getDocumentation() != null && info.getDocumentation().length() > 0) { - documentation = info.getDocumentation().trim(); + String extDocumentation = builder.getDocumentation(type); + if (extDocumentation != null) { + documentation = extDocumentation; } // see if this type should be mapped to a type-safe enumeration by default. @@ -648,7 +649,7 @@ private List buildCEnumConstants(XSRestrictionSimpleType type, bo for( XSFacet facet : type.getDeclaredFacets(XSFacet.FACET_ENUMERATION)) { String name=null; - String mdoc=builder.getBindInfo(facet).getDocumentation().trim(); + String mdoc= builder.getDocumentation(facet); if(!enums.add(facet.getValue().value)) continue; // ignore the 2nd occasion diff --git a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/bindinfo/BIProperty.java b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/bindinfo/BIProperty.java index d72f0557f..23cdac3ea 100644 --- a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/bindinfo/BIProperty.java +++ b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/xmlschema/bindinfo/BIProperty.java @@ -441,8 +441,7 @@ public CPropertyInfo createElementOrReferenceProperty( * Common finalization of {@link CPropertyInfo} for the create***Property methods. */ private T wrapUp(T prop, XSComponent source) { - prop.javadoc = concat(javadoc, - getBuilder().getBindInfo(source).getDocumentation()); + prop.javadoc = concat(javadoc, getBuilder().getDocumentation(source)); if (prop.javadoc == null) { prop.javadoc = ""; } else {