Skip to content

ArcGIS: read item metadata XML for field labels and definitions #41

Description

@sgarcese

Problem

get_schema now reports each field's name, type, alias, string length and domain (#38). Many ArcGIS items also carry formal metadata (ISO 19139 / FGDC / ArcGIS format). Its entity-and-attribute section defines each field: a label, a definition, units and sometimes value ranges. Aliases rarely say that much. HUD's layers, for example, define no domains, so analysts still have to find out elsewhere what a field such as HCV_PUBLIC_PCT is a percentage of.

This was the optional last item in thealphacubicle#84 and was deferred from #38.

Proposal

  • Fetch the item's metadata document ({portal}/sharing/rest/content/items/{id}/info/metadata/metadata.xml on ArcGIS Online/Enterprise). Do it best-effort and cache it like layer descriptions, so a missing document or a 404 never fails the call.
  • Parse it with the standard library xml.etree.ElementTree, with no new dependency. Read the entity/attribute entries (eainfo/detailed/attr: attrlabl, attrdef, attrunit, and rdom/edom where present).
  • get_schema adds a Definition: line (and units) per field when the metadata has one, matched by field name. Treat the text as portal content: html_to_text, portal_block, and caps.
  • Security: parse with entity expansion off. ElementTree does not resolve external entities, but guard against oversized documents with a size cap before parsing, and consider defusedxml only if its size fits the Lambda budget.
  • Tests: an FGDC-style fixture, a missing document, malformed XML, a size cap, and name matching that's case-insensitive.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions