无法弄清楚如何在augeas中正确添加

时间:2017-07-18 09:57:11

标签: xml xml-parsing augeas

我有以下xml:

<subsystem xmlns="urn:jboss:domain:undertow:1.1">
    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener max-post-size="104857600" name="undertow-http" proxy-address-forwarding="${proxy.address.forwarding}" receive-buffer="524288" redirect-socket="https" send-buffer="524288" socket-binding="http"/>
        <https-listener max-post-size="104857600" name="undertow-https" proxy-address-forwarding="${proxy.address.forwarding}" receive-buffer="524288" security-realm="ewb-ssl" send-buffer="524288" socket-binding="https" verify-client="NOT_REQUESTED"/>
        <host alias="localhost" name="default-host"/>
    </server>
    <servlet-container name="default">
        <jsp-config/>
        <persistent-sessions/>
    </servlet-container>
    <handlers/>
</subsystem>

augeas我正在改变xml中的一些值:

 set subsystem[#attribute/xmlns='urn:jboss:domain:undertow:1.1']/server[#attribute/name='default-server']/http-listener[#attribute/name='undertow-http']/#attribute/proxy-address-forwarding 'true'",

但在运行应用程序之后xml中的以下属性

xmlns='urn:jboss:domain:undertow:1.1

更改为:

xmlns='urn:jboss:domain:undertow:1.2

然后augeas开始在xml文件中添加新字段:

<subsystem><server><http-listener proxy-address-forwarding="true"></http-listener>

我试图添加onlyif条件以避免添加额外的字段但没有成功,有人可以帮忙吗?感谢

1 个答案:

答案 0 :(得分:0)

适用于:

onlyif  => "get #attribute/xmlns == 'urn:jboss:domain:undertow:1.1'",