private void generateDummyGroupUsages ( final Options opts ) throws BadCommandLineException { try { final Transformer transformer = GroupInterfacePlugin . TRANSFORMER_FACTORY . newTransformer ( ) ; final XPath xPath = GroupInterfacePlugin . X_PATH_FACTORY . newXPath ( ) ; final MappingNamespaceContext namespaceContext = new MappingNamespaceContext ( ) . add ( "xs" , Namespaces . XS_NS ) . add ( "kscs" , Namespaces . KSCS_BINDINGS_NS ) . add ( "jxb" , Namespaces . JAXB_NS ) ; xPath . setNamespaceContext ( namespaceContext ) ; final XPathExpression attGroupExpression = xPath . compile ( "/xs:schema/xs:attributeGroup" ) ; final XPathExpression modelGroupExpression = xPath . compile ( "/xs:schema/xs:group" ) ; final XPathExpression targetNamespaceExpression = xPath . compile ( "/xs:schema/@targetNamespace" ) ; final Map < String , List < String > > includeMappings = findIncludeMappings ( xPath , opts . getGrammars ( ) ) ; final List < InputSource > newGrammars = new ArrayList <> ( ) ; for ( final InputSource grammarSource : opts . getGrammars ( ) ) { final Document grammar = copyInputSource ( grammarSource ) ; final String declaredTargetNamespaceUri = targetNamespaceExpression . evaluate ( grammar ) ; for ( final String targetNamespaceUri : declaredTargetNamespaceUri == null ? includeMappings . get ( grammarSource . getSystemId ( ) ) : Collections . singletonList ( declaredTargetNamespaceUri ) ) { final NodeList attGroupNodes = ( NodeList ) attGroupExpression . evaluate ( grammar , XPathConstants . NODESET ) ; final NodeList modelGroupNodes = ( NodeList ) modelGroupExpression . evaluate ( grammar , XPathConstants . NODESET ) ; final Groups currentGroups = new Groups ( targetNamespaceUri ) ; for ( int i = 0 ; i < attGroupNodes . getLength ( ) ; i ++ ) { final Element node = ( Element ) attGroupNodes . item ( i ) ; currentGroups . attGroupNames . add ( node . getAttribute ( "name" ) ) ; } for ( int i = 0 ; i < modelGroupNodes . getLength ( ) ; i ++ ) { final Element node = ( Element ) modelGroupNodes . item ( i ) ; currentGroups . modelGroupNames . add ( node . getAttribute ( "name" ) ) ; } final InputSource newSchema = generateImplementationSchema ( opts , transformer , currentGroups , grammarSource . getSystemId ( ) ) ; if ( newSchema != null ) { newGrammars . add ( newSchema ) ; } } } for ( final InputSource newGrammar : newGrammars ) { opts . addGrammar ( newGrammar ) ; } } catch ( final Exception e ) { throw new BadCommandLineException ( getMessage ( "error.plugin-setup" , e ) ) ; } }
Generates dummy complexTypes that implement the interface generated from group decls . These complexTypes will be transformed into classes by the default code generator . Later this plugin will transform the classes into interface declarations . This approach avoids tedious re - implementation of the property generation code with all the effects of settings options and customizations in this plugin .