@@ -258,10 +258,6 @@ public void testRaw()
258258 w .writeStartDocument ();
259259 w .writeStartElement ("test" );
260260 w .writeAttribute ("attr" , "value" );
261- // 13-May-2026, tatu: As of [woodstox-core#95], writeRaw() no longer
262- // closes an open start element; an empty writeCharacters() is the
263- // idiomatic way to commit the start tag before raw content.
264- w .writeCharacters ("" );
265261 w .writeRaw ("this or 'that'" );
266262 char [] cbuf = new char [RAW2 .length () + 10 ];
267263 RAW2 .getChars (0 , RAW2 .length (), cbuf , 3 );
@@ -293,55 +289,29 @@ public void testRaw()
293289 }
294290
295291 /**
296- * Unit test for [woodstox-core#95]: writeRaw() must not close an open
297- * start element, so it can be used to emit content (typically whitespace)
298- * between attributes within the start tag, e.g. for indenting attributes.
292+ * Unit test for [woodstox-core#290]: emitting whitespace (via
293+ * {@code writeSpace()}, which delegates to {@code writeRaw()}) right
294+ * after a start element must close the open start tag first, so that the
295+ * whitespace ends up as element content rather than inside the start tag.
299296 */
300297 @ Test
301- public void testRawBetweenAttributes ()
298+ public void testSpaceAfterStartElement ()
302299 throws XMLStreamException
303300 {
304301 for (int i = 0 ; i < 3 ; ++i ) {
305302 boolean ns = (i > 0 );
306303 StringWriter strw = new StringWriter ();
307304 XMLStreamWriter2 w = (i == 2 ) ? getRepairingWriter (strw )
308305 : getNonRepairingWriter (strw , ns );
309- w .writeStartDocument ();
310306 w .writeStartElement ("test" );
311- w .writeAttribute ("a" , "1" );
312- // Raw whitespace between attributes must be allowed and must
313- // not close the start tag.
314- w .writeRaw ("\n " );
315- w .writeAttribute ("b" , "2" );
316- w .writeRaw ("\n " );
317- w .writeAttribute ("c" , "3" );
307+ w .writeSpace ("\n " );
308+ w .writeComment ("comment" );
318309 w .writeEndElement ();
319310 w .writeEndDocument ();
320311 w .close ();
321312
322313 String xml = strw .toString ();
323- // Verify the literal raw whitespace made it into the start tag,
324- // between the attributes. (The writer also prepends its own ' '
325- // before each attribute name, so the exact number of spaces after
326- // the newline is implementation detail; we just check the newline
327- // and indentation we asked for is present.)
328- assertTrue ("Expected raw newline+indent between attributes, got: " + xml ,
329- xml .contains ("a=\" 1\" \n " )
330- && xml .contains ("b=\" 2\" \n " ));
331-
332- // And the result must still parse as well-formed XML with all
333- // three attributes present.
334- XMLStreamReader sr = constructNsStreamReader (xml , true );
335- assertTokenType (START_DOCUMENT , sr .getEventType ());
336- assertTokenType (START_ELEMENT , sr .next ());
337- assertEquals ("test" , sr .getLocalName ());
338- assertEquals (3 , sr .getAttributeCount ());
339- assertEquals ("1" , sr .getAttributeValue (null , "a" ));
340- assertEquals ("2" , sr .getAttributeValue (null , "b" ));
341- assertEquals ("3" , sr .getAttributeValue (null , "c" ));
342- assertTokenType (END_ELEMENT , sr .next ());
343- assertTokenType (END_DOCUMENT , sr .next ());
344- sr .close ();
314+ assertEquals ("<test>\n <!--comment--></test>" , xml );
345315 }
346316 }
347317
0 commit comments