Class XMLFormattingProfile


public class XMLFormattingProfile extends DocumentMatcher
A formatting profile that overrides global xml.format.* settings for documents matching specific criteria. Extends DocumentMatcher so that matching criteria (pattern, namespaceURI, publicId, systemId, grammarURI) and format override fields all live at the same JSON level (flat structure).

Profiles are declared in xml.format.profiles and evaluated in order; the first matching profile wins. All format fields use boxed types (Boolean, Integer, String) so that null means "not specified — use the global default".

Matching criteria (all optional, combined with AND)

  • pattern — glob on the file URI (inherited from PathPatternMatcher).
  • namespaceURI — root element namespace URI (inherited from DocumentMatcher).
  • rootElement — root element local name (inherited from DocumentMatcher).
  • publicId — DOCTYPE public identifier (inherited from DocumentMatcher).
  • systemId — DOCTYPE system identifier (inherited from DocumentMatcher).
  • grammarURI — resolved grammar URI from any source: DOCTYPE systemId, <?xml-model?> href, file association, or XML catalog (inherited from DocumentMatcher).

Use case: DocBook formatting

 "xml.format.profiles": [{
   "namespaceURI": ["http://docbook.org/ns/docbook*"],
   "mixedContent": "preserve"
 }]
 

Use case: MyBatis via DOCTYPE

 "xml.format.profiles": [{
   "publicId": ["-//mybatis.org//DTD Mapper 3.0//EN"],
   "splitAttributes": "preserve"
 }]
 

Use case: POM files by path

 "xml.format.profiles": [{
   "pattern": "**/pom.xml",
   "splitAttributes": "force-expand-multiline"
 }]
 

Use case: AND combination — DocBook files in a specific folder

 "xml.format.profiles": [{
   "pattern": "**/docs/**/*.xml",
   "namespaceURI": ["http://docbook.org/ns/docbook*"],
   "mixedContent": "preserve"
 }]
 
See Also:
  • Constructor Details

    • XMLFormattingProfile

      public XMLFormattingProfile()
  • Method Details

    • applyTo

      public void applyTo(XMLFormattingOptions target)
      Applies all non-null format override fields from this profile onto the given target formatting options. Fields that are null are left unchanged in the target (the global default is kept).

      Use case: given global settings with splitAttributes=preserve and a profile with splitAttributes=force-expand-multiline, calling applyTo(globalCopy) changes only splitAttributes while keeping all other fields from the global settings.

      Parameters:
      target - the formatting options to modify (typically a copy of the global settings).
    • getSplitAttributes

      public String getSplitAttributes()
    • setSplitAttributes

      public void setSplitAttributes(String splitAttributes)
    • getJoinCDATALines

      public Boolean getJoinCDATALines()
    • setJoinCDATALines

      public void setJoinCDATALines(Boolean joinCDATALines)
    • getFormatComments

      public Boolean getFormatComments()
    • setFormatComments

      public void setFormatComments(Boolean formatComments)
    • getJoinCommentLines

      public Boolean getJoinCommentLines()
    • setJoinCommentLines

      public void setJoinCommentLines(Boolean joinCommentLines)
    • getJoinContentLines

      public Boolean getJoinContentLines()
    • setJoinContentLines

      public void setJoinContentLines(Boolean joinContentLines)
    • getEnabled

      public Boolean getEnabled()
    • setEnabled

      public void setEnabled(Boolean enabled)
    • getSpaceBeforeEmptyCloseTag

      public Boolean getSpaceBeforeEmptyCloseTag()
    • setSpaceBeforeEmptyCloseTag

      public void setSpaceBeforeEmptyCloseTag(Boolean spaceBeforeEmptyCloseTag)
    • getPreservedNewlines

      public Integer getPreservedNewlines()
    • setPreservedNewlines

      public void setPreservedNewlines(Integer preservedNewlines)
    • getEnforceQuoteStyle

      public String getEnforceQuoteStyle()
    • setEnforceQuoteStyle

      public void setEnforceQuoteStyle(String enforceQuoteStyle)
    • getPreserveAttributeLineBreaks

      public Boolean getPreserveAttributeLineBreaks()
    • setPreserveAttributeLineBreaks

      public void setPreserveAttributeLineBreaks(Boolean preserveAttributeLineBreaks)
    • getPreserveEmptyContent

      public Boolean getPreserveEmptyContent()
    • setPreserveEmptyContent

      public void setPreserveEmptyContent(Boolean preserveEmptyContent)
    • getSplitAttributesIndentSize

      public Integer getSplitAttributesIndentSize()
    • setSplitAttributesIndentSize

      public void setSplitAttributesIndentSize(Integer splitAttributesIndentSize)
    • getClosingBracketNewLine

      public Boolean getClosingBracketNewLine()
    • setClosingBracketNewLine

      public void setClosingBracketNewLine(Boolean closingBracketNewLine)
    • getEmptyElements

      public String getEmptyElements()
    • setEmptyElements

      public void setEmptyElements(String emptyElements)
    • getPreserveSpace

      public List<String> getPreserveSpace()
    • setPreserveSpace

      public void setPreserveSpace(List<String> preserveSpace)
    • getBlockElements

      public List<String> getBlockElements()
    • setBlockElements

      public void setBlockElements(List<String> blockElements)
    • getMixedContent

      public String getMixedContent()
    • setMixedContent

      public void setMixedContent(String mixedContent)
    • getGrammarAwareFormatting

      public Boolean getGrammarAwareFormatting()
    • setGrammarAwareFormatting

      public void setGrammarAwareFormatting(Boolean grammarAwareFormatting)
    • getXsiSchemaLocationSplit

      public String getXsiSchemaLocationSplit()
    • setXsiSchemaLocationSplit

      public void setXsiSchemaLocationSplit(String xsiSchemaLocationSplit)
    • getLegacy

      public Boolean getLegacy()
    • setLegacy

      public void setLegacy(Boolean legacy)
    • getMaxLineWidth

      public Integer getMaxLineWidth()
    • setMaxLineWidth

      public void setMaxLineWidth(Integer maxLineWidth)