EXTRACT SERVICE

The EXTRACT SERVICE of DATA FORMATS ANALYZER is implemented in the DfaExtractor.py file as a DfaExtractor module class.

Public Interface

class DfaExtractor.ExtractService(verbosity='IWE', filepath=None)

Provides methods to extract information and descriptions data about attributes, elements and types from the given XSD schema.

Attributes data are stored in the extractedAttributesdictionary with the following structure:

DICTIONARY{
    Attribute name (STRING):DICTIONARY{
        parents (STRING):LIST[Parent name (STRING)],
        description (STRING):LIST[Attribute documentation (STRING)]
    }
}

Elements data are stored in the extractedElementsdictionary with the following structure:

DICTIONARY{
    Element name (STRING):DICTIONARY{
        attributes (STRING):LIST[Attribute name (STRING)],
        children (STRING):LIST[Child name (STRING)],
        parents (STRING):LIST[Parent name (STRING)],
        description (STRING):LIST[Element documentation (STRING)]
    }
}

Types data are stored in the extractedTypesdictionary with the following structure:

DICTIONARY{
    Type name (STRING):DICTIONARY{
        attributes (STRING):LIST[Attribute name (STRING)],
        children (STRING):LIST[Child name (STRING)],

        usages (STRING):DICTIONARY{
            attributes (STRING):LIST[Attribute name (STRING)],
            elements (STRING):LIST[Element name (STRING)]
        },

        description (STRING):LIST[Type documentation (STRING)]
    }
}

Substitution groups data are stored in the substitutionGroupsdictionary with the following structure:

DICTIONARY{
    Head element name (STRING):LIST[Element name (STRING)]
}

Parameters:

  • verbosity: The string specifying verbosity. See details in INIT SERVICE.
  • filepath: The string specifying the full path to the given XSD schema, which will be parsed.
extractData(extractDescriptions=False)

Extracts information and if requested also descriptions data about attributes, elements and types from the given XSD schema.

Parameters:

  • extractDescriptions: The boolean specifying whether descriptions data should be extracted from the documentation annotations in the given XSD schema. Use true (True) only when the XSD schema contains documentation annotations, otherwise use false (False).

Returns: The tuple containing extractedAttributes, extractedElements and extractedTypesdictionaries. It has the following structure: TUPLE(3*DICTIONARY).

Private Methods

ExtractService._extractAttributeNames(element, extractDescriptions)

Extracts attribute names from a given <*:element> element in the XSD schema.

Parameters:

  • element: The xml.dom.minidom.Element with the current <*:element> element, which will be used to extract attribute names.
  • extractDescriptions: The boolean specifying whether descriptions data should be extracted.
ExtractService._saveAttributeName(attributeName)

Saves the attribute name in the extractedAttributesdictionary and in the attributes lists of extractedElements and extractedTypesdictionaries.

Parameters:

  • attributeName: The string specifying the current attribute name, which will be saved.
ExtractService._saveAttributeDocumentation(element)

Saves the attribute documentation in the extractedAttributesdictionary.

Parameters:

  • element: The xml.dom.minidom.Element with the current <*:attribute> element, which will be used to extract the attribute documentation.
ExtractService._extractElementNames(element)

Extracts element names from a given <*:element> element in the XSD schema.

Parameters:

  • element: The xml.dom.minidom.Element with the current <*:element> element, which will be used to extract element names.
ExtractService._saveElementName(elementName)

Saves the element name in the extractedElementsdictionary, children and parents lists of extractedElementsdictionary and in the children lists of extractedTypesdictionary.

Parameters:

  • elementName: The string specifying the current element name, which will be saved.
ExtractService._saveElementDocumentation(element)

Saves the element documentation in the extractedElementsdictionary.

Parameters:

  • element: The xml.dom.minidom.Element with the current <*:element> element, which will be used to extract the element documentation.
ExtractService._saveTypeName(typeName, extractDescriptions)

Saves the type name in the extractedTypesdictionary.

Parameters:

  • typeName: The string specifying the current type name, which will be saved.
  • extractDescriptions: The boolean specifying whether descriptions data should be extracted.
ExtractService._saveTypeUsages(typeName, usageName, extractDescriptions)

Saves and extracts type usages to the usage lists of extractedTypesdictionary.

Parameters:

  • typeName: The string specifying the current type name, which will be saved.
  • usageName: The string specifying the current type usage name, which will be extracted and saved.
  • extractDescriptions: The boolean specifying whether descriptions data should be extracted.
ExtractService._saveTypeDocumentation(element)

Saves the type documentation in the extractedTypesdictionary.

Parameters:

  • element: The xml.dom.minidom.Element with the current <*:complexType> or <*:simpleType> element, which will be used to extract the type documentation.
ExtractService._cleanupDocumentation(maincall, element)

Returns a clean documentation for saving in the extractedAttributes, extractedElements or extractedTypesdictionary.

Parameters:

  • maincall: The boolean specifying whether this method is being called by another method (True) or recursively (False).
  • element: The xml.dom.minidom.Element with the current <*:documentation> element, which will be used to extract the cleaned documentation.

Returns: The string with a clean documentation from the given <*:documentation> element.

ExtractService._cleanupDocumentationText(element)

Returns a clean documentation text from the given child element of the <*:documentation> element.

Parameters:

  • element: The xml.dom.minidom.Element with the current child element of the <*:documentation> element, which will be used to extract the cleaned documentation text.

Returns: The string with a clean documentation text from the given child element of the <*:documentation> element.

ExtractService._extractAndSaveSubstitutionGroup(element)

Extracts and saves a substitution group for the given <*:element> element in the substitutionGroupsdictionary.

Parameters:

  • element: The xml.dom.minidom.Element with the current <*:element> element, which will be used to extract the element name and substitution group.
ExtractService._processSubstitutionGroups()

Processes the substitutionGroupsdictionary to update the extractedElementsdictionary to take substitution groups into account.

ExtractService._processTypeUsages()

Processes the extractedTypesdictionary to update the extractedElements and extractedAttributesdictionaries to take types into account.

Table Of Contents

Previous topic

CONVERT SERVICE

Next topic

OUTPUT SERVICE