码迷,mamicode.com
首页 > 其他好文 > 详细

Maven打包中用xpath替换的语法说明

时间:2015-05-22 09:47:43      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:maven   打包   xpath   xml   

  <bean id="myPropertyConfigurer"  class="com.jader.common.DecryptPropertyPlaceholderConfigurer">         
        <property name="locations" value="classpath:config.properties" />             
        <property name="fileEncoding" value="UTF-8"/>         
        <property name="keyLocation" value="classpath:key.key" />   
    </bean>
    <bean id="conf"  class="com.jader.common.DecryptPropertyPlaceholderConfigurer">         
        <property name="locations">
            <list>
                <value>classpath:jdbc.properties</value>
            </list>
        </property>             
        <property name="fileEncoding" value="UTF-8"/>         
        <property name="keyLocation" value="classpath:key.key" />   

以上面的xml文件为例:
XPath 使用路径表达式在 XML 文档中选取节点。节点是通过沿着路径或者 step 来选取的。
下面列出了最有用的路径表达式:
技术分享

例如:我替换classpath:config.properties
<replace xpath="/beans/bean[@id=myPropertyConfigurer]/property[@name=locations]/@value">classpath:config_test.propertis</replace>
替换class:jdbc.properties
<replace xpath="/beans/bean[@id=conf]/property[@name=locations]/list/value">classpath:config_test.propertis</replace>

选取未知节点
XPath 通配符可用来选取未知的 XML 元素。
技术分享
实例
在下面的表格中,我们列出了一些路径表达式,以及这些表达式的结果:
技术分享
xpath表达式在线验证:http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm

Maven打包中用xpath替换的语法说明

标签:maven   打包   xpath   xml   

原文地址:http://blog.csdn.net/fuyuwei2015/article/details/45897637

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!