
    HR-e                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZmZmZmZ g dZddZddZdZddZddZddZddZd
S )z 
Various XML-related utilities.
    )log)data)check)validate   )W02W03W04W05vo_warnwarn_or_raise)check_idfix_idcheck_tokencheck_mime_content_typecheck_anyurivalidate_schemaIDNc                 t    | 5t          j        |           s!t          t          t          || f||           dS dS )z
    Raises a `~astropy.io.votable.exceptions.VOTableSpecError` if *ID*
    is not a valid XML ID_.

    *name* is the name of the attribute being checked (used only for
    error messages).
    NFT)	xml_checkr   r   r   )r   nameconfigposs       :lib/python3.11/site-packages/astropy/io/votable/xmlutil.pyr   r      s<     
~i044~c3r
FC888u4    c                 t    | dS t          j        |           }|| k    rt          t          | |f||           |S )z
    Given an arbitrary string, create one that can be used as an xml id.

    This is rather simplistic at the moment, since it just replaces
    non-valid characters with underscores.
    N)r   r   r   r	   )r   r   r   	correcteds       r   r   r   (   sE     
zt $$IBb)_fc222r   z$(?![\r\l\t ])[^\r\l\t]*(?![\r\l\t ])c                 6    | t          j        |           sdS dS )zj
    Raises a `ValueError` if *token* is not a valid XML token.

    As defined by XML Schema Part 2.
    NFT)r   r   )token	attr_namer   r   s       r   r   r   :   s$     !6u!=!=u4r   c                 p    | 3t          j        |           st          t          t          | ||           dS dS )z
    Raises a `~astropy.io.votable.exceptions.VOTableSpecError` if
    *content_type* is not a valid MIME content type.

    As defined by RFC 2045 (syntactically, at least).
    NFT)r   r   r   r
   )content_typer   r   s      r   r   r   E   s:     	(I,(W(Wc3fc:::u4r   c                 p    | 3t          j        |           st          t          t          | ||           dS dS )z
    Raises a `~astropy.io.votable.exceptions.VOTableSpecError` if
    *uri* is not a valid URI.

    As defined in RFC 2396.
    NFT)r   r   r   r   )urir   r   s      r   r   r   R   s8     y5c::c3VS111u4r   1.1c                     |dvrt          j        |  d| d           d}|dv rt          j        d| d          }nt          j        d          }t	          j        | |          S )	ax  
    Validates the given file against the appropriate VOTable schema.

    Parameters
    ----------
    filename : str
        The path to the XML file to validate

    version : str, optional
        The VOTABLE version to check, which must be a string "1.0",
        "1.1", "1.2" or "1.3".  If it is not one of these,
        version "1.1" is assumed.

        For version "1.0", it is checked against a DTD, since that
        version did not have an XML Schema.

    Returns
    -------
    returncode, stdout, stderr : int, str, str
        Returns the returncode from xmllint and the stdout and stderr
        as strings
    )z1.0r%   1.21.3z has version z, using schema 1.1r%   )r%   r'   r(   zdata/VOTable.vz.xsdzdata/VOTable.dtd)r   infor   get_pkg_data_filenamer   r   )filenameversionschema_paths      r   r   r   _   s    . 222HFF7FFFGGG'''01O'1O1O1OPP01CDD#Hk:::r   )r   NN)NN)r%   )__doc__astropy.loggerr   astropy.utilsr   astropy.utils.xmlr   r   r   
exceptionsr   r	   r
   r   r   r   __all__r   r   _token_regexr   r   r   r    r   r   <module>r6      s&                0 0 0 0 0 0 & & & & & & C B B B B B B B B B B B B B B B         7   
 
 
 

 
 
 
 ;  ;  ;  ;  ;  ;r   