Skip to content

Decorate xmllint error messages with extra information (tag name and offset)

Notifications You must be signed in to change notification settings

andxor/xmllint-extra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

xmllint-extra

Decorate xmllint error messages with extra information (tag name and offset).

This wrapper also adds some heuristics to fix imports between the passed schemas, by recognizing their defined namespace.

example

When parsing with direct xmllint you could get:

{ errors:
  [
    "file_0.xml:2: element FatturaElettronica: Schemas validity error : Element '{http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2}FatturaElettronica', attribute 'versione': [facet 'enumeration'] The value '1.1' is not an element of the set {'FPA12', 'FPR12'}.",
    "file_0.xml:10: element FormatoTrasmissione: Schemas validity error : Element 'FormatoTrasmissione': [facet 'enumeration'] The value 'SDI11' is not an element of the set {'FPA12', 'FPR12'}.",
    "file_0.xml:10: element FormatoTrasmissione: Schemas validity error : Element 'FormatoTrasmissione': 'SDI11' is not a valid value of the atomic type '{http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2}FormatoTrasmissioneType'.",
    "file_0.xml:101: element PrezzoUnitario: Schemas validity error : Element 'PrezzoUnitario': '2459.020a' is not a valid value of the atomic type '{http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2}Amount8DecimalType'."
  ]
}

using this package that will be converted to:

{ errors:
  [
    { message: "Element '{http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2}FatturaElettronica', attribute 'versione': [facet enumeration'] The value '1.1' is not an element of the set {'FPA12', 'FPR12'}.",
      offset: 39,
      element: 'FatturaElettronica',
      context: '<ns3:FatturaElettronica xmlns:ns3="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" mlns:ns2="http://www.w3.org/2000/09/xmldsig#" versione="1.1">' },
    { message: "Element 'FormatoTrasmissione': [facet 'enumeration'] The value 'SDI11' is not an element of the set {'FPA12', 'FPR12'}.",
      offset: 425,
      element: 'FormatoTrasmissione',
      context: '<FormatoTrasmissione>SDI11</FormatoTrasmissione>' },
    { message: "Element 'FormatoTrasmissione': 'SDI11' is not a valid value of the atomic type 'http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2}FormatoTrasmissioneType'.",
      offset: 425,
      element: 'FormatoTrasmissione',
      context: '<FormatoTrasmissione>SDI11</FormatoTrasmissione>' },
    { message: "Element 'PrezzoUnitario': '2459.020a' is not a valid value of the atomic type 'http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2}Amount8DecimalType'.",
      offset: 3760,
      element: 'PrezzoUnitario',
      context: '<PrezzoUnitario>2459.020a</PrezzoUnitario>' }
  ]
}

About

Decorate xmllint error messages with extra information (tag name and offset)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published