xmlstarlet

Why does xmlstarlet say there's no 'ends-with' function?

感情迁移 提交于 2019-12-06 08:18:50
I'm using xmlstarlet to extract changeSet nodes from a liquibase XML changelog where the viewName ends with "v". However, xmlstarlet is complaining that the ends-with XPATH function does not exist: $ xmlstarlet sel -N x="http://www.liquibase.org/xml/ns/dbchangelog" -t -m \ "/x:databaseChangeLog/x:changeSet[x:createView[ends-with(@viewName, 'v')]]" \ -c . public.db.changelog.xml xmlXPathCompOpEval: function ends-with not found Unregistered function Stack usage errror xmlXPathCompiledEval: 3 objects left on the stack. runtime error: element for-each Failed to evaluate the 'select' expression.

xmlstarlet select value based on condition

空扰寡人 提交于 2019-12-06 02:31:26
Based on this link , I am trying to solve a similar problem. <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"> <modelVersion>4.0.0</modelVersion> <groupId>com.foo</groupId> <artifactId>iwidget</artifactId> <packaging>jar</packaging> <version>0.9.1b</version> <name>iwidget</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project> I want to extract the groupId if artifactId is equal to iwidget . What I

How to use XML namespaces with xmlstarlet XPaths?

我只是一个虾纸丫 提交于 2019-12-05 16:05:56
at the moment I am struggeling editing a XML file. When I write the command xml ed -u "/project/version" -v "2.7.13-NEW-SNAPSHOT" pom.xml > ./pom_new.xml it writes the new xml file, but when I open the file nothings changed in it. Heres a part of the given xml, i want to edit: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.groupID.test</groupId>

xmlstarlet- Update a value on a specific node

回眸只為那壹抹淺笑 提交于 2019-12-04 15:45:15
I want to update a value in the xml file through command line. I'm new to xmlstartlet I tried with the following command but its not working xml ed -u "/web-app/welcome-file-list/welcome-file" -v 'Login.jsp' web.xml In the followig XML file I want to update the value as login.jsp on the welcome-file node. This is my web.xml file <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

Convert xml to key-value pair notation

久未见 提交于 2019-12-04 13:40:14
问题 I use xmlstarlet el -v to display the structure of an xml file, including all the attributes and values. I would like to convert its output to some sort of key-value pairs, i.e. each attribute with its value on a separate line (including the XPath); each line must be unique. Current result: topRoot/topSystem/commSvcEp/commSyslog[@descr='Syslog Service' and @name='syslog' and @policyOwner='local' and @severity='critical'] topRoot/topSystem/commSvcEp/commSyslog/commSyslogClient[@adminState=

Parsing xml to and replacing specific tags shell script

给你一囗甜甜゛ 提交于 2019-12-03 09:08:26
For the below xml ,I need to replace <studentStatus> for <studentName>CLASSA</studentName> to <studentStatus>failed</studentStatus> . <studentFile> <student> <studentName>CLASSA</studentName> <studentStatus>Success</studentStatus> <studentActions> <studentAction> <studentType>Juniour</studentType> <studentStatus>Completed</studentStatus> <studentMsg/> </studentAction> <studentAction> <studentType>HighSchool</studentType> <studentStatus>Completed</studentStatus> <studentMsg/> </studentAction> </studentActions> </student> <student> <studentName>CLASSB</studentName> <studentStatus>Success<

Convert xml to key-value pair notation

ぐ巨炮叔叔 提交于 2019-12-03 08:32:38
I use xmlstarlet el -v to display the structure of an xml file, including all the attributes and values. I would like to convert its output to some sort of key-value pairs, i.e. each attribute with its value on a separate line (including the XPath); each line must be unique. Current result: topRoot/topSystem/commSvcEp/commSyslog[@descr='Syslog Service' and @name='syslog' and @policyOwner='local' and @severity='critical'] topRoot/topSystem/commSvcEp/commSyslog/commSyslogClient[@adminState='disabled' and @forwardingFacility='local7' and @hostname='none' and @name='secondary' and @severity=

XMLStarlet does not select anything

六月ゝ 毕业季﹏ 提交于 2019-12-03 01:53:29
I have a typical pom.xml, and want to print the groupId, artifactId and version, separated by colon. I think that XMLStarlet is the right tool for that. I tried several ways, but I always get an empty line. xml sel -t -m project -v groupId -o : -v artifactId -o : -v version pom.xml Expected output: org.something.apps:app-acct:5.4 Real output: empty line Even if I try to print just the groupId I get nothing: xml sel -t -v project/groupId pom.xml I am sure that the tool sees the elements because I can list them without problem: xml el pom.xml prints the following (correctly): project project

Testing for an XML attribute

隐身守侯 提交于 2019-12-03 01:24:12
I have a piece of XML like so: <root> <foo src=""/> <foo src="bar"/> <foo /> </root> I want to know which elements have a src attribute , which are empty and which have values. The furthest I have come is with $ xmlstarlet sel -t -m '//foo' -v @src -n foo.xml bar Though that doesn't tell me the third foo is missing the attribute. This will select the foos with no src attribute. /root/foo[not(@src)] For the other two tasks, I would use a mix of the expressions pointed out by @TOUDIdel and @Dimitre Novatchev: /root/foo[@src and string-length(@src)=0] for foos with an empty src , and /root/foo[

xmlstarlet replace value after pattern

我只是一个虾纸丫 提交于 2019-12-02 21:15:35
问题 I have a pom.xml, that I want to change the properties values for tags that starting in a certain pattern. I usually use xmlstarlet to manipulate XML but I never did it with "regex", Is that possible? my pom.xml is such: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0<