Reputation: 636
I can't replace an attribute with xmlstarlet.
dog.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd">
<rabbit:connection-factory id="mqConnectionFactory"
host="localhost"
port="9999" />
</beans>
Many variations of the following have been tried:
xmlstarlet ed -N B="http://www.springframework.org/schema/beans" -N R="http://www.springframework.org/schema/rabbit" --update "/B/R:connection-factor/@host" --value "myserver" dog.xml
What am I missing? I've tried beans and B:beans for B and many variations of R, but I don't see to be selecting the right element.
Upvotes: 1
Views: 365
Reputation: 1801
With full namespace declarations,
xmlstarlet ed \
-N B="http://www.springframework.org/schema/beans" \
-N rabbit="http://www.springframework.org/schema/rabbit" \
--update '/B:beans/rabbit:connection-factory/@host' \
--value "myserver" dog.xml
or, with an xmlstarlet
shortcut, per the
user guide:
xmlstarlet ed \
-N rabbit="http://www.springframework.org/schema/rabbit" \
--update '/_:beans/rabbit:connection-factory/@host' \
--value "myserver" dog.xml
Spot the typo: your command is missing
the final y
in connection-factory
.
Upvotes: 2
Reputation: 88646
Two ways around the problem with failed to load external entity
with your example:
xmlstarlet edit --update "//@host" --value "myserver" file.xml
or
xmlstarlet edit --update "//*[local-name()='connection-factory']/@host" --value "myserver" file.xml
Upvotes: 2