dianping/cat · error · Error

elements closed character '/' and '>' must be connected to

Error message

elements closed character '/' and '>' must be connected to

What it means

Whitespace between '/' and '>' inside a start tag is rejected by the XML worker's attribute scanner (worker-css.js sibling worker-xml.js:~1632). After '/' the state becomes S_C; the space case at line 1628-1632 hits S_C and throws, because this parser requires the empty-element close sequence to be exactly '/>' with nothing between.

Source

Thrown at cat-home/src/main/webapp/assets/js/editor/worker-xml.js:1632

				switch(s){
				case S_ATTR_S:
					errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead!!')
					el.add(attrName,attrName,start);
					start = p;
					s = S_ATTR;
					break;
				case S_E:
					errorHandler.warning('attribute space is required"'+attrName+'"!!')
				case S_S:
					s = S_ATTR;
					start = p;
					break;
				case S_EQ:
					s = S_V;
					start = p;
					break;
				case S_C:
					throw new Error("elements closed character '/' and '>' must be connected to");
				}
			}
		}
		p++;
	}
}
function appendElement(el,domBuilder,parseStack){
	var tagName = el.tagName;
	var localNSMap = null;
	var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
	var i = el.length;
	while(i--){
		var a = el[i];
		var qName = a.qName;
		var value = a.value;
		var nsp = qName.indexOf(':');
		if(nsp>0){
			var prefix = a.prefix = qName.slice(0,nsp);

View on GitHub (pinned to e815e74d4c)

Solutions

  1. Write the empty-element close as '/>' with no whitespace between the two characters.
  2. If you need whitespace formatting, put it before the '/', not between '/' and '>'.
  3. Re-run the XML parse/lint to confirm the annotation clears.

Example fix

<!-- before -->
<br / >

<!-- after -->
<br/>
Defensive patterns

Strategy: validation

Validate before calling

// Normalize '/ >' (and longer splits) to '/>' before parsing:
function normalizeSelfClosing(xml) {
  return xml.replace(/\s+\/\s*>/g, '/>');
}

Try / catch

try {
  parseStartTag(source, start, tagNameReplacer);
} catch (ex) {
  if (/closed character/.test(ex.message)) reportXmlError(ex); else throw ex;
}

Prevention

When it happens

Trigger: '<br / >' or '<img src="x.png" / >' — a space (or any c<=' ' char) after the closing slash. The default/space switch case for S_C throws at line 1632.

Common situations: HTML habits ('<br />' is fine, but '<br / >' after extra editing), code reformatters that insert spaces around punctuation, hand-edited XHTML.

Related errors


AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14). Data as JSON: /api/errors/e407fe2adea4f450. Report an issue: GitHub.