Maven pom.xml & MyBatis Mapper Troubleshooting: Unclosed Tags, Quoted Attributes & CDATA
Getting SAXParseException after writing <= in a MyBatis query or editing pom.xml dependencies? Fix special-character escaping, CDATA blocks, and tag mismatches fast.
1. Unescaped < / <= / & Operators Inside MyBatis SQL
In XML, < starts a tag and & starts an entity reference. Writing created_at <= #{endTime} or flag & 1 directly inside a MyBatis Mapper causes the parser to abort with a SAXParseException.
<select id=findOrders resultType="Order">
SELECT * FROM t_order
WHERE amount <= #{maxAmount} AND flag & 1 = 1
</select> <select id="findOrders" resultType="Order">
SELECT * FROM t_order
WHERE <![CDATA[amount <= #{maxAmount} AND flag & 1 = 1]]>
</select> 2. Mismatched Closing Tags, Case Sensitivity & Unquoted Attributes
XML is case-sensitive, mandates quoted attribute values, forbids duplicate attributes on the same element, and requires every non-self-closing tag to pair cleanly. Manual merges in pom.xml often leave stray or missing </dependency> tags.
- Exact line/column diagnostics: ITGrocery Fmt pinpoints mismatched tags, unclosed elements, and duplicate attributes immediately.
- Instant autofix preview: Missing closing tags, unquoted attribute values (id=findOrders), and full-width tag punctuation generate a live fix preview.
- Lossless formatting: Preserves <!-- comments -->, <![CDATA[...]]>, <?xml?> declarations, attribute quote styles, and exact numeric literals.
Pre-Commit XML Checklist
- Wrapped <, <=, <>, and & in MyBatis SQL with <![CDATA[...]]> or escaped as < / &?
- Quoted every attribute value and eliminated duplicate attributes on the same tag?
- Verified balanced closing tags after resolving merge conflicts in pom.xml?
Validate & Format XML Losslessly
Preserves comments and CDATA verbatim while diagnosing unclosed tags, duplicate attributes, and unquoted values.