xmlstarlet

XMLStarlet + XInclude + XSLT

此生再无相见时 提交于 2019-12-12 09:47:06
问题 I'd like to include contents of an XML document into another XML document and transform it via xmlstarlet+XSLT. I'm trying to use XInclude. (A newbie to both XInclude and XSLT, I am.) The xmlstarlet, though, won't process the included XML doc, it just leaves the inclusion node there untouched. File a.xml : <?xml version="1.0" ?> <doc xmlns:xi="http://www.w3.org/2001/XInclude"> a <xi:include href="b.xml" /> b </doc> File b.xml : <?xml version="1.0" ?> <snippet> c </snippet> The x.xsl "pass

search tag attribute value based on child node value using XmlStarlet

前提是你 提交于 2019-12-12 02:46:43
问题 I have a xml file having structure something like below: <role name="test" pattern=".*"> <assignedSIDs> <sid>abc</sid> <sid>cde</sid> <sid>def</sid> </assignedSIDs> </role> <role name="test1" pattern=".*"> <assignedSIDs> <sid>abc</sid> <sid>zxc</sid> <sid>vbn</sid> </assignedSIDs> </role> <role name="test2" pattern=".*"> <assignedSIDs> <sid>abc</sid> <sid>hex</sid> <sid>oct</sid> </assignedSIDs> </role> I want to find role tag name attribute based on value of sid tag. for eg: if I search for

XMLStarles removes closing tag

天涯浪子 提交于 2019-12-11 11:38:17
问题 Having trouble with xmlstar. It's removes empty tags, how to disable this? input: <tag1>test1</tag1> <tag3></tag3> <tag4>test3</tag4> output: <tag1>test1</tag1> <tag3/> <tag4>test3</tag4> And i want the same output so is's not removes the closing quote. Hope someone has a quick answer. 回答1: In XML, <a></a> and <a/> (note the / ) are semantically identical. Whatever application is consuming the document should not care about this change. I don't know anything about xmlstarlet in particular,

xmlstarlet: Selecting element by it's position number

不问归期 提交于 2019-12-11 09:18:53
问题 I have this XML file <?xml version="1.0" encoding="utf-8"?> <xObject version="3.0" xmlns="http://schemas.microsoft.com/random/2006/objects"> <section id="*" type="product"> <table name="XFile"> <row sourceLineNumber="D:\bla\bla\"> <field>Borderish.fo</field> <field>Documents</field> <field>1</field> <field>This line here 1</field> </row> <row sourceLineNumber="D:\blah\blah\"> <field>Charterish</field> <field>Documents</field> <field>1</field> <field>This line here 2</field> </row> </table> <

XMLStarlet Return attribute based on value (Reverse lookup)

点点圈 提交于 2019-12-11 05:03:24
问题 I have this xml: <block name="http-www.example.com"> <mapentry tag="AB12">bottlecap</mapentry> <mapentry tag="CD45">description goes here</mapentry> <mapentry tag="GH23">12345</mapentry> <mapentry tag="JK89">54321</mapentry> </block> And I want to find the "tag" based on the value. So I want to search for "bottlecap" and have it return "AB12" In all the examples I've seen, people search for the attribute to get the result, but in this type of xml that isn't possible since the nodes and

Updating XML with namespace with xmlstarlet 1.6.1

[亡魂溺海] 提交于 2019-12-11 02:46:46
问题 I am trying to update the host-slave.xml from a Wildfly Cluster configuration with xmlstarlet. I am using the following statement: xml ed -N my=urn:jboss:domain:2.2 -u "_:host/management/security-realms/security-realm[@name='UndertowRealm']/server-identities/ssl/keystore/@path" -v "test" Wildfly\wildfly-8.2.0.Final\WildFly-HOST\configuration\host-slave.xml The namespace definition in xml: <host name="172.16.1.11" xmlns="urn:jboss:domain:2.2" > The part of the xml I want to change: <security

How can I count the number of elements in an XML document using xmlstarlet in BASH?

妖精的绣舞 提交于 2019-12-11 01:01:40
问题 I need to count the number of times an element occurs within an XML document. The element I need to count is called 'ThreadGroup' Elelement to count: <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true"> There are three ThreadGroup elements in the following XML. How can we count them using xmlstarlet? Test XML <?xml version="1.0" encoding="UTF-8"?> <jmeterTestPlan version="1.2" properties="2.8" jmeter="2.13 r1665067"> <hashTree> <TestPlan

Xmlstarlet using --inplace option in updating xml

假如想象 提交于 2019-12-10 18:52:55
问题 im trying to update one xml tag using --inplace global option as shown below xml ed --inplace -N x="http://java.sun.com/xml/ns/j2ee" -u "//x:web-app/x:filter/x:init-param/x:param-value" -v "/cuadmin/showRecovery.do" WEB-INF/web.xml Above is giving me error **I/O warning : failed to load external entity "x=http%3A//java.sun.com/xml/ns/j2ee"** The xml im trying to modify looks like below :- <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http:/

How to insert elements with attributes to an XML file using XmlStarlet?

随声附和 提交于 2019-12-10 16:22:18
问题 Source XML <xml> <block> <el name="a">92346</el> <el name="b">lorem</el> </block> <block> <el name="a">89753</el> <el name="b">ipsum</el> </block> </xml> Object I would like to insert an <el name="c">0</el> element in every <block> with a Linux shell script: <xml> <block> <el name="a">92346</el> <el name="b">lorem</el> <el name="c">0</el> </block> <block> <el name="a">89753</el> <el name="b">ipsum</el> <el name="c">0</el> </block> </xml> I can append the elements using XmlStarlet: xmlstarlet

How do I update a string attribute with xmlstarlet?

这一生的挚爱 提交于 2019-12-10 16:01:06
问题 $ xmlstarlet edit -L -u "/parse-plugins/mimeType/plugin[@id='parse-html']/@id" -v 'parse-tika' conf/parse-plugins.xml Why doesn't it replace the plugin id of mimetpes currently using parse-html plugin? From xmlstarlet documentation: Update value of an attribute xml ed -u ’/xml/table/rec[@id=3]/@id’ -v 5 xml/tab-obj.xml I'm working on nutch parse-plugins.xml. 回答1: as Mark pointed out, it works! To check that things changed use $ xmlstarlet sel -t -c "/parse-plugins/mimeType/plugin[@id='parse