"""Lightweight XML Schema text detection helpers."""

from __future__ import annotations

from xml.etree import ElementTree as ET  # noqa: S405

XML_SCHEMA_NAMESPACE = "http://www.w3.org/2001/XMLSchema"
XML_SCHEMA_TAG = f"{{{XML_SCHEMA_NAMESPACE}}}schema"


def is_xml_schema_text(text: str) -> bool:
    """Return whether text is an XML Schema document."""
    try:
        root = ET.fromstring(text)  # noqa: S314
    except ET.ParseError:
        return False
    return root.tag == XML_SCHEMA_TAG


__all__ = ["XML_SCHEMA_NAMESPACE", "XML_SCHEMA_TAG", "is_xml_schema_text"]
