Convert the UNTL elements structure into a DC structure.

    kwargs can be passed to the function for certain effects:

    ark: Takes an ark string and creates an identifier element out of it.
    domain_name: Takes a domain string and creates an ark URL from it
    (ark and domain_name must be passed together to work properly).

    resolve_values: Converts abbreviated content into resolved vocabulary
    labels.
    resolve_urls: Converts abbreviated content into resolved vocabulary
    URLs.
    verbose_vocabularies: Uses the verbose vocabularies passed to the
    function instead of this function being required to retrieve them.

    # Create a DC Python object from a UNTL XML file.
    from pyuntl.untldoc import untlxml2py
    untl_elements = untlxml2py(untl_filename) # Or pass a file-like object.

    # OR Create a DC Python object from a UNTL dictionary.
    from pyuntl.untldoc import untldict2py
    untl_elements = untldict2py(untl_dict)

    # Convert to UNTL Python object to DC Python object.
    dc_elements = untlpy2dcpy(untl_elements)
    dc_dict = dcpy2dict(dc_elements)

    # Output DC in a specified string format.
    from pyuntl.untldoc
    import generate_dc_xml, generate_dc_json, generate_dc_txt
    # Create a DC XML string.
    generate_dc_xml(dc_dict)
    # Create a DC JSON string.
    generate_dc_json(dc_dict)
    # Create a DC text string.
    generate_dc_txt(dc_dict)

def untlpy2dcpy(untl_elements, **kwargs):
    """Convert the UNTL elements structure into a DC structure.

    kwargs can be passed to the function for certain effects:

    ark: Takes an ark string and creates an identifier element out of it.
    domain_name: Takes a domain string and creates an ark URL from it
    (ark and domain_name must be passed together to work properly).

    resolve_values: Converts abbreviated content into resolved vocabulary
    labels.
    resolve_urls: Converts abbreviated content into resolved vocabulary
    URLs.
    verbose_vocabularies: Uses the verbose vocabularies passed to the
    function instead of this function being required to retrieve them.

    # Create a DC Python object from a UNTL XML file.
    from pyuntl.untldoc import untlxml2py
    untl_elements = untlxml2py(untl_filename) # Or pass a file-like object.

    # OR Create a DC Python object from a UNTL dictionary.
    from pyuntl.untldoc import untldict2py
    untl_elements = untldict2py(untl_dict)

    # Convert to UNTL Python object to DC Python object.
    dc_elements = untlpy2dcpy(untl_elements)
    dc_dict = dcpy2dict(dc_elements)

    # Output DC in a specified string format.
    from pyuntl.untldoc
    import generate_dc_xml, generate_dc_json, generate_dc_txt
    # Create a DC XML string.
    generate_dc_xml(dc_dict)
    # Create a DC JSON string.
    generate_dc_json(dc_dict)
    # Create a DC text string.
    generate_dc_txt(dc_dict)
    """
    sDate = None
    eDate = None
    ark = kwargs.get('ark', None)
    domain_name = kwargs.get('domain_name', None)
    scheme = kwargs.get('scheme', 'http')
    resolve_values = kwargs.get('resolve_values', None)
    resolve_urls = kwargs.get('resolve_urls', None)
    verbose_vocabularies = kwargs.get('verbose_vocabularies', None)
    # If either resolvers were requested, get the vocabulary data.
    if resolve_values or resolve_urls:
        if verbose_vocabularies:
            # If the vocabularies were passed to the function, use them.
            vocab_data = verbose_vocabularies
        else:
            # Otherwise, retrieve them using the pyuntl method.
            vocab_data = retrieve_vocab()
    else:
        vocab_data = None
    # Create the DC parent element.
    dc_root = DC_CONVERSION_DISPATCH['dc']()
    for element in untl_elements.children:
        # Check if the UNTL element should be converted to DC.
        if element.tag in DC_CONVERSION_DISPATCH:
            # Check if the element has its content stored in children nodes.
            if element.children:
                dc_element = DC_CONVERSION_DISPATCH[element.tag](
                    qualifier=element.qualifier,
                    children=element.children,
                    resolve_values=resolve_values,
                    resolve_urls=resolve_urls,
                    vocab_data=vocab_data,
                )
            # It is a normal element.
            else:
                dc_element = DC_CONVERSION_DISPATCH[element.tag](
                    qualifier=element.qualifier,
                    content=element.content,
                    resolve_values=resolve_values,
                    resolve_urls=resolve_urls,
                    vocab_data=vocab_data,
                )
            if element.tag == 'coverage':
                # Handle start and end dates.
                if element.qualifier == 'sDate':
                    sDate = dc_element
                elif element.qualifier == 'eDate':
                    eDate = dc_element
                # Otherwise, add the coverage element to the structure.
                else:
                    dc_root.add_child(dc_element)
            # Add non coverage DC element to the structure.
            elif dc_element:
                dc_root.add_child(dc_element)
    # If the domain and ark were specified
    # try to turn them into indentifier elements.
    if ark and domain_name:
        # Create and add the permalink identifier.
        permalink_identifier = DC_CONVERSION_DISPATCH['identifier'](
            qualifier='permalink',
            domain_name=domain_name,
            ark=ark,
            scheme=scheme
        )
        dc_root.add_child(permalink_identifier)
        # Create and add the ark identifier.
        ark_identifier = DC_CONVERSION_DISPATCH['identifier'](
            qualifier='ark',
            content=ark,
        )
        dc_root.add_child(ark_identifier)
    if sDate and eDate:
        # If a start and end date exist, combine them into one element.
        dc_element = DC_CONVERSION_DISPATCH['coverage'](
            content='%s-%s' % (sDate.content, eDate.content),
        )
        dc_root.add_child(dc_element)
    elif sDate:
        dc_root.add_child(sDate)
    elif eDate:
        dc_root.add_child(eDate)
    return dc_root