# Path: packtools/validations.py
# def is_valid_value_for_pid_v2(value):
# VALIDATE_FUNCTIONS = dict((
#     ("scielo_pid_v2", is_valid_value_for_pid_v2),
# ))
# 
# Path: packtools/sps/exceptions.py
# class NotAllowedtoChangeAttributeValueError(Exception):
# class InvalidAttributeValueError(Exception):
# class InvalidValueForOrderError(Exception):
# class SPSLoadToXMLError(Exception):
# class SHA1Error(Exception):
# class SPSConnectionError(Exception):
# class SPSHTTPError(Exception):
# class SPSHTTPForbiddenError(Exception):
# class SPSHTTPResourceNotFoundError(Exception):
# class SPSHTTPInternalServerError(Exception):
# class SPSHTTPBadGatewayError(Exception):
# class SPSHTTPServiceUnavailableError(Exception):
# class SPSDownloadXMLError(Exception):
# class SPSXMLLinkError(Exception):
# class SPSXMLContentError(Exception):
# class SPSXMLFileError(Exception):
# class SPSAssetOrRenditionFileError(Exception):
# class SPSMakePackageFromPathsMissingKeyError(Exception):
# 
# Path: packtools/file_utils.py
# def is_folder(source):
# def is_zipfile(source):
# def xml_files_list(path):
# def files_list(path):
# def read_file(path, encoding="utf-8", mode="r"):
# def read_from_zipfile(zip_path, filename):
# def xml_files_list_from_zipfile(zip_path):
# def files_list_from_zipfile(zip_path):
# def write_file(path, source, mode="w"):
# def create_zip_file(files, zip_name, zip_folder=None):
# def delete_folder(path):
# def create_temp_file(filename, content=None, mode='w'):
# def copy_file(source, target):
# def size(file_path):
# def get_prefix_by_xml_filename(xml_filename):
# def get_file_role(file_path, prefix, pdf_langs):
# def extract_issn_from_zip_uri(zip_uri):
# def is_valid_file(file_path, check_mimetype=False):
# def get_mimetype(file_path):
# def get_filename(file_path):


import logging
import re
from copy import deepcopy
from lxml import etree
from packtools import validations
from packtools.sps import exceptions
from packtools import file_utils
    node = deepcopy(title_node)

    for xref in node.findall(".//xref"):
        parent = xref.getparent()
        parent.remove(xref)

    return node_text(node)


def fix_xml(xml_str):
    return fix_namespace_prefix_w(xml_str)


def fix_namespace_prefix_w(content):
    """
    Convert os textos cujo padrão é `w:st="` em `w-st="`
    """
    pattern = r"\bw:[a-z]{1,}=\""
    found_items = re.findall(pattern, content)
    logger.debug("Found %i namespace prefix w", len(found_items))
    for item in set(found_items):
        new_namespace = item.replace(":", "-")
        logger.debug("%s -> %s" % (item, new_namespace))
        content = content.replace(item, new_namespace)
    return content


def _get_xml_content(xml):
    if isinstance(xml, str):
        try:

# Path: packtools/validations.py
# def is_valid_value_for_pid_v2(value):
# VALIDATE_FUNCTIONS = dict((
#     ("scielo_pid_v2", is_valid_value_for_pid_v2),
# ))
# 
# Path: packtools/sps/exceptions.py
# class NotAllowedtoChangeAttributeValueError(Exception):
# class InvalidAttributeValueError(Exception):
# class InvalidValueForOrderError(Exception):
# class SPSLoadToXMLError(Exception):
# class SHA1Error(Exception):
# class SPSConnectionError(Exception):
# class SPSHTTPError(Exception):
# class SPSHTTPForbiddenError(Exception):
# class SPSHTTPResourceNotFoundError(Exception):
# class SPSHTTPInternalServerError(Exception):
# class SPSHTTPBadGatewayError(Exception):
# class SPSHTTPServiceUnavailableError(Exception):
# class SPSDownloadXMLError(Exception):
# class SPSXMLLinkError(Exception):
# class SPSXMLContentError(Exception):
# class SPSXMLFileError(Exception):
# class SPSAssetOrRenditionFileError(Exception):
# class SPSMakePackageFromPathsMissingKeyError(Exception):
# 
# Path: packtools/file_utils.py
# def is_folder(source):
# def is_zipfile(source):
# def xml_files_list(path):
# def files_list(path):
# def read_file(path, encoding="utf-8", mode="r"):
# def read_from_zipfile(zip_path, filename):
# def xml_files_list_from_zipfile(zip_path):
# def files_list_from_zipfile(zip_path):
# def write_file(path, source, mode="w"):
# def create_zip_file(files, zip_name, zip_folder=None):
# def delete_folder(path):
# def create_temp_file(filename, content=None, mode='w'):
# def copy_file(source, target):
# def size(file_path):
# def get_prefix_by_xml_filename(xml_filename):
# def get_file_role(file_path, prefix, pdf_langs):
# def extract_issn_from_zip_uri(zip_uri):
# def is_valid_file(file_path, check_mimetype=False):
# def get_mimetype(file_path):
# def get_filename(file_path):


# Path: packtools/sps/utils/xml_utils.py
import logging
import re
from copy import deepcopy
from lxml import etree
from packtools import validations
from packtools.sps import exceptions
from packtools import file_utils

    node = deepcopy(title_node)

    for xref in node.findall(".//xref"):
        parent = xref.getparent()
        parent.remove(xref)

    return node_text(node)


def fix_xml(xml_str):
    return fix_namespace_prefix_w(xml_str)


def fix_namespace_prefix_w(content):
    """
    Convert os textos cujo padrão é `w:st="` em `w-st="`
    """
    pattern = r"\bw:[a-z]{1,}=\""
    found_items = re.findall(pattern, content)
    logger.debug("Found %i namespace prefix w", len(found_items))
    for item in set(found_items):
        new_namespace = item.replace(":", "-")
        logger.debug("%s -> %s" % (item, new_namespace))
        content = content.replace(item, new_namespace)
    return content


def _get_xml_content(xml):
    if isinstance(xml, str):
        try:

            content = file_utils.read_file(xml)