# Metadata XML Examples: Fields and API Version [← Back to Metadata XML Examples Index](metadata-xml-examples.md) ## Example 2: Require Description on Custom Fields **Problem:** Custom fields without descriptions make orgs hard to maintain. **Target file:** `*.field-meta.xml` **Sample violating metadata:** ```xml Revenue__c Currency ``` **XPath (PMD 7):** ```xpath //*[local-name()='CustomField'][not(*[local-name()='description']) or *[local-name()='description'][not(@Text)]] ``` **How it works:** Matches `CustomField` elements that either lack a `` child entirely, or have one with no text content (`@Text` absent means empty). **PMD ruleset:** ```xml Enforces that all custom fields have a description for documentation 3 ``` --- ## Example 3: Enforce Minimum API Version **Problem:** Metadata using API versions older than 60.0 should be updated. **Target file:** Any `*-meta.xml` with `` **Sample violating metadata:** ```xml 52.0 Active ``` **XPath (PMD 7):** ```xpath //*[local-name()='apiVersion']/*[number(@Text) < 60] ``` **How it works:** Finds `` elements, then navigates to their child text node with `/*`. The `@Text` attribute on the text node holds the value (e.g., "52.0"). `number(@Text)` converts it to a float, and flags if < 60. ⚠️ **Key insight:** `@Text` lives on CHILD text nodes, not on elements. You must use `/*` to reach the text node — putting `[@Text]` directly on the element (after `local-name()='apiVersion'`) returns 0 matches. **PMD ruleset:** ```xml Enforces minimum API version of 60.0 across all metadata 3 ```