Skip to content

xmllint

xmllint documentation

Configuration in MegaLinter

Variable Description Default value
XML_XMLLINT_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
XML_XMLLINT_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src\|lib)
Include every file
XML_XMLLINT_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test\|examples)
Exclude no file
XML_XMLLINT_CLI_LINT_MODE Override default CLI lint mode
- file: Calls the linter for each file
- list_of_files: Call the linter with the list of files as argument
- project: Call the linter from the root of the project
list_of_files
XML_XMLLINT_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
[".xml"]
XML_XMLLINT_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
XML_XMLLINT_PRE_COMMANDS List of bash commands to run before the linter None
XML_XMLLINT_POST_COMMANDS List of bash commands to run after the linter None
XML_XMLLINT_DISABLE_ERRORS Run linter but consider errors as warnings false
XML_XMLLINT_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0

MegaLinter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 97 Docker Image Size (tag) Docker Pulls
ci_light Optimized for CI items (Dockerfile, Jenkinsfile, JSON/YAML schemas,XML 16 Docker Image Size (tag) Docker Pulls
dart Optimized for DART based projects 42 Docker Image Size (tag) Docker Pulls
documentation MegaLinter for documentation projects 41 Docker Image Size (tag) Docker Pulls
dotnet Optimized for C, C++, C# or VB based projects 49 Docker Image Size (tag) Docker Pulls
go Optimized for GO based projects 43 Docker Image Size (tag) Docker Pulls
java Optimized for JAVA based projects 43 Docker Image Size (tag) Docker Pulls
javascript Optimized for JAVASCRIPT or TYPESCRIPT based projects 50 Docker Image Size (tag) Docker Pulls
php Optimized for PHP based projects 46 Docker Image Size (tag) Docker Pulls
python Optimized for PYTHON based projects 49 Docker Image Size (tag) Docker Pulls
ruby Optimized for RUBY based projects 42 Docker Image Size (tag) Docker Pulls
rust Optimized for RUST based projects 42 Docker Image Size (tag) Docker Pulls
salesforce Optimized for Salesforce based projects 44 Docker Image Size (tag) Docker Pulls
scala Optimized for SCALA based projects 42 Docker Image Size (tag) Docker Pulls
swift Optimized for SWIFT based projects 42 Docker Image Size (tag) Docker Pulls
terraform Optimized for TERRAFORM based projects 47 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • File extensions: .xml

How the linting is performed

  • xmllint is called once with the list of files as arguments

Example calls

xmllint myfile.xml

Help content

Unknown option --help
Usage : xmllint [options] XMLfiles ...
  Parse the XML files and output the result of the parsing
  --version : display the version of the XML library used
  --debug : dump a debug tree of the in-memory document
  --shell : run a navigating shell
  --debugent : debug the entities defined in the document
  --copy : used to test the internal copy implementation
  --recover : output what was parsable on broken XML documents
  --huge : remove any internal arbitrary parser limits
  --noent : substitute entity references by their value
  --noenc : ignore any encoding specified inside the document
  --noout : don't output the result tree
  --path 'paths': provide a set of paths for resources
  --load-trace : print trace of all external entities loaded
  --nonet : refuse to fetch DTDs or entities over network
  --nocompact : do not generate compact text nodes
  --htmlout : output results as HTML
  --nowrap : do not put HTML doc wrapper
  --valid : validate the document in addition to std well-formed check
  --postvalid : do a posteriori validation, i.e after parsing
  --dtdvalid URL : do a posteriori validation against a given DTD
  --dtdvalidfpi FPI : same but name the DTD with a Public Identifier
  --quiet : be quiet when succeeded
  --timing : print some timings
  --output file or -o file: save to a given file
  --repeat : repeat 100 times, for timing or profiling
  --insert : ad-hoc test for valid insertions
  --compress : turn on gzip compression of output
  --html : use the HTML parser
  --xmlout : force to use the XML serializer when using --html
  --nodefdtd : do not default HTML doctype
  --push : use the push mode of the parser
  --pushsmall : use the push mode of the parser using tiny increments
  --memory : parse from memory
  --maxmem nbbytes : limits memory allocation to nbbytes bytes
  --nowarning : do not emit warnings from parser/validator
  --noblanks : drop (ignorable?) blanks spaces
  --nocdata : replace cdata section with text nodes
  --format : reformat/reindent the output
  --encode encoding : output in the given encoding
  --dropdtd : remove the DOCTYPE of the input docs
  --pretty STYLE : pretty-print in a particular style
                   0 Do not pretty print
                   1 Format the XML content, as --format
                   2 Add whitespace inside tags, preserving content
  --c14n : save in W3C canonical format v1.0 (with comments)
  --c14n11 : save in W3C canonical format v1.1 (with comments)
  --exc-c14n : save in W3C exclusive canonical format (with comments)
  --nsclean : remove redundant namespace declarations
  --testIO : test user I/O support
  --catalogs : use SGML catalogs from $SGML_CATALOG_FILES
               otherwise XML Catalogs starting from
           file:///etc/xml/catalog are activated by default
  --nocatalogs: deactivate all catalogs
  --auto : generate a small doc on the fly
  --xinclude : do XInclude processing
  --noxincludenode : same but do not generate XInclude nodes
  --nofixup-base-uris : do not fixup xml:base uris
  --loaddtd : fetch external DTD
  --dtdattr : loaddtd + populate the tree with inherited attributes
  --stream : use the streaming interface to process very large files
  --walker : create a reader and walk though the resulting doc
  --pattern pattern_value : test the pattern support
  --chkregister : verify the node registration code
  --relaxng schema : do RelaxNG validation against the schema
  --schema schema : do validation against the WXS schema
  --schematron schema : do validation against a schematron
  --sax1: use the old SAX1 interfaces for processing
  --sax: do not build a tree but work just at the SAX level
  --oldxml10: use XML-1.0 parsing rules before the 5th edition
  --xpath expr: evaluate the XPath expression, imply --noout

Libxml project home page: https://gitlab.gnome.org/GNOME/libxml2

Installation on mega-linter Docker image

Example success log

Results of xmllint linter (version 20910)
See documentation on https://megalinter.github.io/descriptors/xml_xmllint/
-----------------------------------------------

[SUCCESS] .automation/test/xml/xml_good_1.xml
    <?xml version="1.0"?>
    <note>
      <to>Tove</to>
      <from>Jani</from>
      <heading>Reminder</heading>
      <body>Don't forget me this weekend!</body>
    </note>

Example error log

Results of xmllint linter (version 20910)
See documentation on https://megalinter.github.io/descriptors/xml_xmllint/
-----------------------------------------------

[ERROR] .automation/test/xml/xml_bad_1.xml
    .automation/test/xml/xml_bad_1.xml:7: parser error : EndTag: '</' not found

    ^