← LeaderboardThe Skill Leaderboard
rust-roxmltree-expanded-names
Match Rust XML elements and attributes by namespace URI and local name with roxmltree. Verify prefix aliases and unqualified attributes.
Try your first task
A source-grounded starter task has not been verified for this skill yet.
SKILL.md
name: rust-roxmltree-expanded-namesdescription: Match Rust XML elements and attributes by namespace URI and local name with roxmltree. Verify prefix aliases and unqualified attributes.category: developmentrisk: criticalsource: selfsource_type: selfauthor: ShianMikedate_added: "2026-12-03"tags: [rust, xml, roxmltree, namespaces, testing]Rust roxmltree expanded names
When to Use
- An XML extractor selects entries with the right local name from the wrong namespace.
- Equivalent documents use different prefixes or place elements in a default namespace.
- A qualified and unqualified attribute share a local name and must be read separately.
Prerequisites
- Identify the namespace URI and local name required by the data contract.
- Check which elements and attributes are namespace-qualified, including any optional fields.
- Use representative XML with prefix aliases, a rebound prefix, and an unqualified attribute.
Workflow
- Reproduce with similar local names. Include equivalent elements under different prefixes, a foreign element with the same local name, and an element that clears the default namespace. Record which entries the old extractor returns.
- Match the expanded element name. Use
node.has_tag_name((namespace_uri, local_name))in roxmltree. A bare string tests the local name. If the contract requires an unqualified element, checktag_name().namespace().is_none()explicitly. - Check attribute names independently. Use
node.attribute((namespace_uri, local_name))for a qualified attribute. The default namespace of the element leaves unprefixed attributes unqualified. To require an unqualified attribute, inspectAttribute::namespace()while matching its local name. - Preserve the missing-field behavior. For each expected field, keep the application's rule for required values, optional values, and rejection. Test an element with a same-named attribute in a different namespace.
- Verify the complete extracted result. Assert the order, IDs, and values expected by the consumer. Change only a prefix alias and confirm that the equivalent expanded name still matches.
Example
Run Match namespace and local name. The local-name scan includes unrelated records. The expanded-name scan selects the intended entries and keeps the unqualified label distinct from its qualified ID.
Limitations
- The fixture uses roxmltree 0.21.2 and an in-memory document. Streaming readers expose namespace resolution through other APIs.
- This example checks selection by name. Schema validation, cardinality, and document-specific requirements need separate checks.
- Namespace URIs in the fixture are identifiers. Their role here is string identity within the parsed XML model.
Safety and Side Effects
- Run the example in a scratch Cargo project. It uses synthetic XML and writes local build artifacts.
- Keep existing input size and parser configuration when changing extraction rules.
- Verify what happens to previously selected records before applying a migration to stored data.