Skip to content

Commit f95f0bc

Browse files
committed
Minor forward-lookign improvement
1 parent 9d45c6b commit f95f0bc

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/main/java/tools/jackson/dataformat/xml/ser/ToXmlGenerator.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,14 +707,26 @@ public final void _handleStartObject() throws JacksonException
707707
if (_nextName == null) {
708708
handleMissingName();
709709
}
710+
// 20-Apr-2026, tatu: special handling for Root Element...
711+
final boolean isRoot = _elementNameStack.isEmpty();
710712
// Need to keep track of names to make Lists work correctly
711713
_elementNameStack.addLast(_nextName);
712714
try {
713-
_xmlWriter.writeStartElement(_nextName.getNamespaceURI(), _nextName.getLocalPart());
715+
if (isRoot) {
716+
_handleStartRootObject(_nextName);
717+
} else {
718+
_xmlWriter.writeStartElement(_nextName.getNamespaceURI(), _nextName.getLocalPart());
719+
}
714720
} catch (XMLStreamException e) {
715721
StaxUtil.throwAsWriteException(e, this);
716722
}
717723
}
724+
725+
// @since 3.2
726+
protected void _handleStartRootObject(QName rootElemName) throws XMLStreamException {
727+
// !!! TODO: special handling
728+
_xmlWriter.writeStartElement(_nextName.getNamespaceURI(), _nextName.getLocalPart());
729+
}
718730

719731
// note: public just because pretty printer needs to make a callback
720732
public final void _handleEndObject() throws JacksonException

0 commit comments

Comments
 (0)