pub fn resolve_uri(system_id: &str, base: Option<&str>) -> StringExpand description
Resolve a SYSTEM literal to a filesystem path (joining against
base_url’s parent directory for relative literals), read the
file, and return its bytes. Used by external general-entity
loading; mirrors the path-resolution rule in
XmlBytesReader::load_external_subset.
http:// and https:// URIs are rejected — v0.1 doesn’t fetch
over the network. file:// prefixes are stripped.
Resolve a (possibly relative) SYSTEM identifier against a base URI
into an absolute URL string.
The parser is the authority on base URI semantics — see XML 1.0
§ 4.2.2 + errata E18. Doing the join here means every
EntityResolver implementation can stay a simple
“open-this-URL” function rather than re-implementing URI math.
Rules:
- If
system_idalready has a URI scheme (contains"://") or is an absolute filesystem path (starts with/), it’s returned verbatim — already absolute. - If
baseisNone,system_idis returned verbatim (best effort — the resolver will handle relative paths as it sees fit). - Otherwise the parent directory of
baseis joined withsystem_id(preserving anyfile://scheme onbase).
The result may still contain .. segments — they’re left for the
resolver’s own canonicalisation step (e.g.
FilesystemResolver::validate_path calls canonicalize, which
resolves them and follows the security check on the result).