Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xmlstarlet doesn't work with xml version 1.1 files. Any alternative to use with Bash?

New Jenkins versions are using xml version 1.1 for configuration files. I used XMLStarlet to manipulate these files from a Bash script but XMLStarlet doesn't support xml version 1.1

Do you know of any alternative to XMLStarlet?

like image 488
Pedro Avatar asked Dec 28 '25 19:12

Pedro


2 Answers

Since I first posted this question I've found a couple of workarounds valid only if you're not using a xml 1.1 specific feature that is usually the case:

1st- xmlstarlet 2>/dev/null xmlstarlet recognizes that xml 1.1 is unsupported and outputs a warning to STDERR (fd2) that you can see in the console. Redirecting (only) STDERR to dev/null makes the trick.

2nd- removing the xml 1.1 first line declaration in the file. According to the xml standard if the declaration is missing, the file is considered to be xml 1.0. Does a valid XML file require an XML declaration?

like image 105
Pedro Avatar answered Dec 31 '25 13:12

Pedro


I got the same issue before, in my case I had to install jenkins job config.xml and edit it and then upload it again to Jenkins.

As a workaround to fix this issue I used to replace the version from version='1.1' to version='1.0' and then apply XmlStarlet command and before upload the file I return the version to be version='1.1'

like image 36
Saleh Ibrahim Avatar answered Dec 31 '25 12:12

Saleh Ibrahim