- try {
-
- // Convert top level complex type definitions to node types
- log.debug("\n## TYPES");
- XSNamedMap map = xsModel.getComponents(XSConstants.TYPE_DEFINITION);
- for (int i = 0; i < map.getLength(); i++) {
- XSTypeDefinition tDef = (XSTypeDefinition) map.item(i);
- log.debug(tDef);
- }
- // Convert local (anonymous) complex type defs found in top level
- // element declarations
- log.debug("\n## ELEMENTS");
- map = xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
- for (int i = 0; i < map.getLength(); i++) {
- XSElementDeclaration eDec = (XSElementDeclaration) map.item(i);
- XSTypeDefinition tDef = eDec.getTypeDefinition();
- log.debug(eDec + ", " + tDef);
- }
- log.debug("\n## ATTRIBUTES");
- map = xsModel.getComponents(XSConstants.ATTRIBUTE_DECLARATION);
- for (int i = 0; i < map.getLength(); i++) {
- XSAttributeDeclaration eDec = (XSAttributeDeclaration) map.item(i);
- XSTypeDefinition tDef = eDec.getTypeDefinition();
- log.debug(eDec.getNamespace() + ":" + eDec.getName() + ", " + tDef);
+ if (xsModel != null)
+ try {
+
+ // Convert top level complex type definitions to node types
+ log.debug("\n## TYPES");
+ XSNamedMap map = xsModel.getComponents(XSConstants.TYPE_DEFINITION);
+ for (int i = 0; i < map.getLength(); i++) {
+ XSTypeDefinition tDef = (XSTypeDefinition) map.item(i);
+ log.debug(tDef);
+ }
+ // Convert local (anonymous) complex type defs found in top level
+ // element declarations
+ log.debug("\n## ELEMENTS");
+ map = xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
+ for (int i = 0; i < map.getLength(); i++) {
+ XSElementDeclaration eDec = (XSElementDeclaration) map.item(i);
+ XSTypeDefinition tDef = eDec.getTypeDefinition();
+ log.debug(eDec + ", " + tDef);
+ }
+ log.debug("\n## ATTRIBUTES");
+ map = xsModel.getComponents(XSConstants.ATTRIBUTE_DECLARATION);
+ for (int i = 0; i < map.getLength(); i++) {
+ XSAttributeDeclaration eDec = (XSAttributeDeclaration) map.item(i);
+ XSTypeDefinition tDef = eDec.getTypeDefinition();
+ log.debug(eDec.getNamespace() + ":" + eDec.getName() + ", " + tDef);
+ }
+ } catch (ClassCastException | XSException e) {
+ throw new RuntimeException(e);