private void printNamespaces ( NodeTypeData nodeTypeData , OutputStreamWriter out ) throws RepositoryException , IOException { /** * Using set to store all prefixes found in node types to avoid * duplication */ Set < String > namespaces = new HashSet < String > ( ) ; /** Scanning nodeType definition for used namespaces */ printNameNamespace ( nodeTypeData . getName ( ) , namespaces ) ; printNameNamespace ( nodeTypeData . getPrimaryItemName ( ) , namespaces ) ; if ( nodeTypeData . getDeclaredSupertypeNames ( ) != null ) { for ( InternalQName reqType : nodeTypeData . getDeclaredSupertypeNames ( ) ) { printNameNamespace ( reqType , namespaces ) ; } } /** Scanning property definitions for used namespaces */ if ( nodeTypeData . getDeclaredPropertyDefinitions ( ) != null ) { for ( PropertyDefinitionData property : nodeTypeData . getDeclaredPropertyDefinitions ( ) ) { printNameNamespace ( property . getName ( ) , namespaces ) ; } } /** Scanning child definitions for used namespaces */ if ( nodeTypeData . getDeclaredChildNodeDefinitions ( ) != null ) { for ( NodeDefinitionData child : nodeTypeData . getDeclaredChildNodeDefinitions ( ) ) { printNameNamespace ( child . getName ( ) , namespaces ) ; printNameNamespace ( child . getDefaultPrimaryType ( ) , namespaces ) ; if ( child . getRequiredPrimaryTypes ( ) != null ) { for ( InternalQName reqType : child . getRequiredPrimaryTypes ( ) ) { printNameNamespace ( reqType , namespaces ) ; } } } } for ( String prefix : namespaces ) { String uri = namespaceRegistry . getURI ( prefix ) ; out . write ( "<" + prefix + "='" + uri + "'>\r\n" ) ; } }
Print namespaces to stream