private void resetXsdSimpleTypeUuids(final Resource resource) throws Exception {
    if (resource instanceof XSDResourceImpl) {
      final XSDResourceImpl xsdResource = (XSDResourceImpl) resource;
      final XSDSchema schema = xsdResource.getSchema();
      if (schema != null) {
        for (final Iterator iter = schema.getContents().iterator(); iter.hasNext(); ) {
          EObject eObj = (EObject) iter.next();

          // Only process global simple type definitions ...
          if (eObj instanceof XSDSimpleTypeDefinition) {
            final XSDSimpleTypeDefinition type = (XSDSimpleTypeDefinition) eObj;

            // Get the application information ...
            final XSDAnnotation annotation = type.getAnnotation();

            // If no annotation exists then no UUID attribute exists to reset ...
            if (annotation == null) {
              continue;
            }
            for (final Iterator appInfos = annotation.getApplicationInformation().iterator();
                appInfos.hasNext(); ) {
              final Element appInfo = (Element) appInfos.next();
              String uuid = appInfo.getAttribute(UUID_ATTRIBUTE_NAME);
              if (uuid != null) {
                uuid = IDGenerator.getInstance().create().toString();
                appInfo.setAttribute(UUID_ATTRIBUTE_NAME, uuid);
                uuid = appInfo.getAttribute(UUID_ATTRIBUTE_NAME);
              }
            }
          }
        }
      }
    }
  }
Exemple #2
0
  protected void processTypeFacets(
      XSDSimpleTypeDefinition type, Node typeNode, XSDTypeDefinition baseType)
      throws RepositoryException {
    if (baseType == null) {
      baseType = type.getBaseType();
    }
    if (baseType == type) {
      // The base type is the anytype ...
      baseType =
          type.getSchema()
              .getSchemaForSchema()
              .resolveSimpleTypeDefinition("http://www.w3.org/2001/XMLSchema", "anyType");
    }
    if (baseType != null) {
      typeNode.setProperty(XsdLexicon.BASE_TYPE_NAME, baseType.getName());
      typeNode.setProperty(XsdLexicon.BASE_TYPE_NAMESPACE, baseType.getTargetNamespace());
      setReference(
          typeNode,
          XsdLexicon.BASE_TYPE_REFERENCE,
          TYPE_DEFINITIONS,
          baseType.getTargetNamespace(),
          baseType.getName());
    }

    processFacet(
        type.getEffectiveMaxLengthFacet(), typeNode, XsdLexicon.MAX_LENGTH, PropertyType.LONG);
    processFacet(type.getMaxLengthFacet(), typeNode, XsdLexicon.MAX_LENGTH, PropertyType.LONG);
    processFacet(
        type.getEffectiveMinLengthFacet(), typeNode, XsdLexicon.MIN_LENGTH, PropertyType.LONG);
    processFacet(type.getMinLengthFacet(), typeNode, XsdLexicon.MIN_LENGTH, PropertyType.LONG);
    processFacet(
        type.getEffectiveMaxFacet(), typeNode, XsdLexicon.MAX_VALUE_EXCLUSIVE, PropertyType.LONG);
    processFacet(
        type.getMaxExclusiveFacet(), typeNode, XsdLexicon.MAX_VALUE_EXCLUSIVE, PropertyType.LONG);
    processFacet(
        type.getEffectiveMinFacet(), typeNode, XsdLexicon.MIN_VALUE_EXCLUSIVE, PropertyType.LONG);
    processFacet(
        type.getMinExclusiveFacet(), typeNode, XsdLexicon.MIN_VALUE_EXCLUSIVE, PropertyType.LONG);
    processFacet(
        type.getMaxInclusiveFacet(), typeNode, XsdLexicon.MAX_VALUE_INCLUSIVE, PropertyType.LONG);
    processFacet(
        type.getMinInclusiveFacet(), typeNode, XsdLexicon.MIN_VALUE_INCLUSIVE, PropertyType.LONG);
    processFacet(
        type.getEffectiveTotalDigitsFacet(), typeNode, XsdLexicon.TOTAL_DIGITS, PropertyType.LONG);
    processFacet(type.getTotalDigitsFacet(), typeNode, XsdLexicon.TOTAL_DIGITS, PropertyType.LONG);
    processFacet(
        type.getEffectiveFractionDigitsFacet(),
        typeNode,
        XsdLexicon.FRACTION_DIGITS,
        PropertyType.LONG);
    processFacet(
        type.getFractionDigitsFacet(), typeNode, XsdLexicon.FRACTION_DIGITS, PropertyType.LONG);

    processFacet(
        type.getEffectiveWhiteSpaceFacet(), typeNode, XsdLexicon.WHITESPACE, PropertyType.STRING);
    processFacet(type.getWhiteSpaceFacet(), typeNode, XsdLexicon.WHITESPACE, PropertyType.STRING);

    processFacet(
        type.getEffectivePatternFacet(), typeNode, XsdLexicon.PATTERN, PropertyType.STRING);
    @SuppressWarnings("unchecked")
    List<XSDPatternFacet> patternFacets = type.getPatternFacets();
    processFacetsList(patternFacets, typeNode, XsdLexicon.PATTERN);

    processFacet(
        type.getEffectiveEnumerationFacet(),
        typeNode,
        XsdLexicon.ENUMERATED_VALUES,
        PropertyType.STRING);
    @SuppressWarnings("unchecked")
    List<XSDEnumerationFacet> enumFacets = type.getEnumerationFacets();
    processFacetsList(enumFacets, typeNode, XsdLexicon.ENUMERATED_VALUES);

    @SuppressWarnings("unchecked")
    List<XSDSimpleFinal> finalFacets2 = type.getFinal();
    processEnumerators(finalFacets2, typeNode, XsdLexicon.FINAL);

    processAnnotation(type.getAnnotation(), typeNode);
  }