Skip to content

BaseStreamWriter.writeSpace(String) should not close open element #95

@kwin

Description

@kwin

Sometimes it is useful to also indent attributes within an element. For that org.codehaus.stag2.writeSpace(String) should be used. Unfortunately that will always close any open start tags so it cannot be used to indent attributes as internally it calls writeText (

) . As the javadoc is clearly stating this should be used for indentation (http://fasterxml.github.io/stax2-api/javadoc/3.1.4/org/codehaus/stax2/XMLStreamWriter2.html#writeSpace(java.lang.String)) it is unexpected that this behaves like writeRaw(String) as this prevents it being used for indenting attributes. Any subsequent calls of writeAttribute(...) lead to exception

javax.xml.stream.XMLStreamException: Trying to write an attribute when there is no open start element.
	at com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1589)
	at com.ctc.wstx.sw.SimpleNsStreamWriter.writeAttribute(SimpleNsStreamWriter.java:73)
	at ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssue that seems easy to resolve and is likely a good candidate for contributors new to project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions