Skip to content

Fix EAC-CPF namespace handling in XPath queries#9

Merged
alexdryden merged 3 commits intoindex_creatorsfrom
copilot/sub-pr-8
Feb 11, 2026
Merged

Fix EAC-CPF namespace handling in XPath queries#9
alexdryden merged 3 commits intoindex_creatorsfrom
copilot/sub-pr-8

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 11, 2026

Addresses namespace inconsistency in traject_config_eac_cpf.rb where XPath queries mixed prefixed and unprefixed element names. Since EAC-CPF documents use a default namespace (xmlns="urn:isbn:1-931666-33-4"), unprefixed XPath queries fail to match elements.

Changes

  • Define namespace constant: EAC_NS = { 'eac' => 'urn:isbn:1-931666-33-4' }
  • Standardize all XPath queries: Use eac: prefix consistently across all 24 queries
  • Remove fallback queries: Eliminate unprefixed fallback logic that would never execute

Before:

# Mixed approaches - inline mapping with unprefixed elements, or no namespace
entity = record.xpath('//cpfDescription/identity/entityType', 
                     'eac-cpf' => 'urn:isbn:1-931666-33-4').first
entity ||= record.xpath('//identity/entityType').first  # Fallback never matches

After:

# Consistent prefix with shared namespace constant
entity = record.xpath('//eac:cpfDescription/eac:identity/eac:entityType', EAC_NS).first

This ensures reliable extraction from ArchivesSpace EAC-CPF exports.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants