使用xmlstarlet直接在另一个元素之后插入一个元素不会';t工作

使用xmlstarlet直接在另一个元素之后插入一个元素不会';t工作,xml,xml-parsing,xmlstarlet,Xml,Xml Parsing,Xmlstarlet,我知道像这样的问题已经被回答了很多次,但没有一个对我有用,至少。。。使用我的XML文件。我用更简单的XML树尝试了这些答案,但它们奏效了,而我的却没有。这就是为什么我要发布一个问题,希望有人能启发我:-) 我的XML(Liferay内容)如下所示: <?xml version="1.0"?> <beans> <bean id="liferayDataSource" class="org.springframework.jdbc.datasource.Laz

我知道像这样的问题已经被回答了很多次,但没有一个对我有用,至少。。。使用我的XML文件。我用更简单的XML树尝试了这些答案,但它们奏效了,而我的却没有。这就是为什么我要发布一个问题,希望有人能启发我:-)

我的XML(Liferay内容)如下所示:

<?xml version="1.0"?>

<beans>
    <bean id="liferayDataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
        <property name="targetDataSource">
            <bean class="org.springframework.aop.framework.ProxyFactoryBean">
                <property name="targetSource" ref="shardDataSourceTargetSource" />
            </bean>
        </property>
    </bean>

    <bean id="liferayHibernateSessionFactory" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="targetSource" ref="shardSessionFactoryTargetSource" />
    </bean>

    <bean id="shardDataSource0" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
        <property name="targetDataSource">
            <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
                <property name="propertyPrefix" value="jdbc.default." />
            </bean>
        </property>
    </bean>

    <bean id="shardDataSource1" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
        <property name="targetDataSource">
            <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
                <property name="propertyPrefix" value="jdbc.NIGERIA." />
            </bean>
        </property>
    </bean>

    <bean id="shardDataSource2" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
        <property name="targetDataSource">
            <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
                <property name="propertyPrefix" value="jdbc.MEDLAHO." />
            </bean>
        </property>
    </bean>

    <bean id="shardDataSourceTargetSource" class="com.liferay.portal.dao.shard.ShardDataSourceTargetSource">    
        <property name="dataSources">
            <map>
                <entry>
                    <key>
                        <value>default</value>
                    </key>
                    <ref bean="shardDataSource0" />
                </entry>
                <entry>
                    <key>
                        <value>NIGERIA</value>
                    </key>
                    <ref bean="shardDataSource1" />
                </entry>
                <entry>
                    <key>
                        <value>MEDLAHO</value>
                    </key>
                    <ref bean="shardDataSource2" />
                </entry>
            </map>
        </property>
    </bean>
    <bean id="shardSessionFactoryTargetSource" class="com.liferay.portal.dao.shard.ShardSessionFactoryTargetSource">
        <property name="shardDataSourceTargetSource" ref="shardDataSourceTargetSource" />
    </bean>
    <bean id="com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil" class="com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil">
        <property name="mappingSqlQueryFactory">
            <bean class="com.liferay.portal.dao.shard.ShardMappingSqlQueryFactoryImpl" />
        </property>
    </bean>
    <bean id="com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil" class="com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil">
        <property name="sqlUpdateFactory">
            <bean class="com.liferay.portal.dao.shard.ShardSqlUpdateFactoryImpl" />
        </property>
    </bean>
    <bean id="com.liferay.portal.kernel.dao.shard.ShardUtil" class="com.liferay.portal.kernel.dao.shard.ShardUtil">
        <property name="shard">
            <bean class="com.liferay.portal.dao.shard.ShardImpl">
                <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
            </bean>
        </property>
    </bean>
    <bean id="com.liferay.portal.kernel.util.InfrastructureUtil" class="com.liferay.portal.kernel.util.InfrastructureUtil">
        <property name="dataSource" ref="liferayDataSource" />
        <property name="mailSession" ref="mailSession" />
        <property name="shardDataSourceTargetSource" ref="shardDataSourceTargetSource" />
        <property name="shardSessionFactoryTargetSource" ref="shardSessionFactoryTargetSource" />
        <property name="transactionManager" ref="liferayTransactionManager" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardAdvice" class="com.liferay.portal.dao.shard.advice.ShardAdvice">
        <property name="shardDataSourceTargetSource" ref="shardDataSourceTargetSource" />
        <property name="shardSessionFactoryTargetSource" ref="shardSessionFactoryTargetSource" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardCompanyAdvice" class="com.liferay.portal.dao.shard.advice.ShardCompanyAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardPortletAdvice" class="com.liferay.portal.dao.shard.advice.ShardPortletAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice" class="com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" class="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardIterativelyAdvice" class="com.liferay.portal.dao.shard.advice.ShardIterativelyAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardParameterAdvice" class="com.liferay.portal.dao.shard.advice.ShardParameterAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <aop:config proxy-target-class="false">
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardCompanyAdvice" pointcut="bean(com.liferay.portal.service.CompanyLocalService)" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portal.convert.messaging.ConvertProcessMessageListener.receive(..))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portal.events.StartupHelper.updateIndexes())" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portal.events.StartupHelper.upgradeProcess(int))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(* com.liferay.portal.service.ReleaseLocalService.getBuildNumberOrCreate())" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portal.service.ServiceComponentLocalService.upgradeDB(..))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portlet.journal.service.JournalArticleLocalService.checkArticles())" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardIterativelyAdvice" pointcut="execution(void com.liferay.portal.events.StartupHelper.verifyProcess(boolean, boolean))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardParameterAdvice" pointcut="execution(* com.liferay.portal.service.AccountLocalService.getAccount(long, long))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardParameterAdvice" pointcut="execution(* com.liferay.portal.service.GroupLocalService.getCompanyGroup(long))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardParameterAdvice" pointcut="execution(* com.liferay.portal.service.UserLocalService.searchCount(..))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice" pointcut="bean(*Persistence) || bean(*Finder)" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardPortletAdvice" pointcut="bean(com.liferay.portal.service.PortletLocalService)" />
    </aop:config>
</beans>
xmlstarlet ed -a "/beans/bean[@id='shardDataSource0']" -t elem -n beanTMP -v ""  \
    -i //beanTMP -t attr -n "id" -v "shardDataSource1" \
    -i //beanTMP -t attr -n "class" -v "org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy" \
    -s //beanTMP -t elem -n "propertyTMP" -v "" \
    -i //propertyTMP -t attr -n "name" -v "targetDataSource" \
    -s //propertyTMP -t elem -n "beanTMP2" -v "" \
    -i //beanTMP2 -t attr -n "class" -v "com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean" \
    -s //beanTMP2 -t elem -n "propertyTMP2" -i //propertyTMP2 -t attr -n "name" -v "propertyPrefix" \
    -i //propertyTMP2 -t attr -n "value" -v "jdbc.default." \
    -r //propertyTMP -v "property" \
    -r //propertyTMP2 -v "property" \
    -r //beanTMP -v "bean" \
    -r //beanTMP2 -v "bean" \
    file.xml
<?xml version="1.0"?>
<beans>
  <bean id="shardDataSource0" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
    <property name="targetDataSource">
      <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
        <property name="propertyPrefix" value="jdbc.default."/>
      </bean>
    </property>
  </bean>
  <bean id="shardDataSource1" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"><property name="targetDataSource"><bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean"><property name="propertyPrefix" value="jdbc.default."/></bean></property></bean>
</beans>
不起作用:-(它什么也不做,文件没有修改,退出代码为0

那么…我在这里错过了什么,伙计们

非常非常感谢

注意:我正在运行SLES扩展支持平台6.7版,xmlstarlet包是:xmlstarlet-1.5.0-1.el6.rf.x86_64


更新

感谢@npostavs的回答,我成功地添加了整个bean块。正确的行如下:

<?xml version="1.0"?>

<beans>
    <bean id="liferayDataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
        <property name="targetDataSource">
            <bean class="org.springframework.aop.framework.ProxyFactoryBean">
                <property name="targetSource" ref="shardDataSourceTargetSource" />
            </bean>
        </property>
    </bean>

    <bean id="liferayHibernateSessionFactory" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="targetSource" ref="shardSessionFactoryTargetSource" />
    </bean>

    <bean id="shardDataSource0" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
        <property name="targetDataSource">
            <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
                <property name="propertyPrefix" value="jdbc.default." />
            </bean>
        </property>
    </bean>

    <bean id="shardDataSource1" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
        <property name="targetDataSource">
            <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
                <property name="propertyPrefix" value="jdbc.NIGERIA." />
            </bean>
        </property>
    </bean>

    <bean id="shardDataSource2" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
        <property name="targetDataSource">
            <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
                <property name="propertyPrefix" value="jdbc.MEDLAHO." />
            </bean>
        </property>
    </bean>

    <bean id="shardDataSourceTargetSource" class="com.liferay.portal.dao.shard.ShardDataSourceTargetSource">    
        <property name="dataSources">
            <map>
                <entry>
                    <key>
                        <value>default</value>
                    </key>
                    <ref bean="shardDataSource0" />
                </entry>
                <entry>
                    <key>
                        <value>NIGERIA</value>
                    </key>
                    <ref bean="shardDataSource1" />
                </entry>
                <entry>
                    <key>
                        <value>MEDLAHO</value>
                    </key>
                    <ref bean="shardDataSource2" />
                </entry>
            </map>
        </property>
    </bean>
    <bean id="shardSessionFactoryTargetSource" class="com.liferay.portal.dao.shard.ShardSessionFactoryTargetSource">
        <property name="shardDataSourceTargetSource" ref="shardDataSourceTargetSource" />
    </bean>
    <bean id="com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil" class="com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil">
        <property name="mappingSqlQueryFactory">
            <bean class="com.liferay.portal.dao.shard.ShardMappingSqlQueryFactoryImpl" />
        </property>
    </bean>
    <bean id="com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil" class="com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil">
        <property name="sqlUpdateFactory">
            <bean class="com.liferay.portal.dao.shard.ShardSqlUpdateFactoryImpl" />
        </property>
    </bean>
    <bean id="com.liferay.portal.kernel.dao.shard.ShardUtil" class="com.liferay.portal.kernel.dao.shard.ShardUtil">
        <property name="shard">
            <bean class="com.liferay.portal.dao.shard.ShardImpl">
                <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
            </bean>
        </property>
    </bean>
    <bean id="com.liferay.portal.kernel.util.InfrastructureUtil" class="com.liferay.portal.kernel.util.InfrastructureUtil">
        <property name="dataSource" ref="liferayDataSource" />
        <property name="mailSession" ref="mailSession" />
        <property name="shardDataSourceTargetSource" ref="shardDataSourceTargetSource" />
        <property name="shardSessionFactoryTargetSource" ref="shardSessionFactoryTargetSource" />
        <property name="transactionManager" ref="liferayTransactionManager" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardAdvice" class="com.liferay.portal.dao.shard.advice.ShardAdvice">
        <property name="shardDataSourceTargetSource" ref="shardDataSourceTargetSource" />
        <property name="shardSessionFactoryTargetSource" ref="shardSessionFactoryTargetSource" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardCompanyAdvice" class="com.liferay.portal.dao.shard.advice.ShardCompanyAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardPortletAdvice" class="com.liferay.portal.dao.shard.advice.ShardPortletAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice" class="com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" class="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardIterativelyAdvice" class="com.liferay.portal.dao.shard.advice.ShardIterativelyAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardParameterAdvice" class="com.liferay.portal.dao.shard.advice.ShardParameterAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <aop:config proxy-target-class="false">
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardCompanyAdvice" pointcut="bean(com.liferay.portal.service.CompanyLocalService)" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portal.convert.messaging.ConvertProcessMessageListener.receive(..))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portal.events.StartupHelper.updateIndexes())" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portal.events.StartupHelper.upgradeProcess(int))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(* com.liferay.portal.service.ReleaseLocalService.getBuildNumberOrCreate())" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portal.service.ServiceComponentLocalService.upgradeDB(..))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portlet.journal.service.JournalArticleLocalService.checkArticles())" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardIterativelyAdvice" pointcut="execution(void com.liferay.portal.events.StartupHelper.verifyProcess(boolean, boolean))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardParameterAdvice" pointcut="execution(* com.liferay.portal.service.AccountLocalService.getAccount(long, long))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardParameterAdvice" pointcut="execution(* com.liferay.portal.service.GroupLocalService.getCompanyGroup(long))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardParameterAdvice" pointcut="execution(* com.liferay.portal.service.UserLocalService.searchCount(..))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice" pointcut="bean(*Persistence) || bean(*Finder)" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardPortletAdvice" pointcut="bean(com.liferay.portal.service.PortletLocalService)" />
    </aop:config>
</beans>
xmlstarlet ed -a "/beans/bean[@id='shardDataSource0']" -t elem -n beanTMP -v ""  \
    -i //beanTMP -t attr -n "id" -v "shardDataSource1" \
    -i //beanTMP -t attr -n "class" -v "org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy" \
    -s //beanTMP -t elem -n "propertyTMP" -v "" \
    -i //propertyTMP -t attr -n "name" -v "targetDataSource" \
    -s //propertyTMP -t elem -n "beanTMP2" -v "" \
    -i //beanTMP2 -t attr -n "class" -v "com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean" \
    -s //beanTMP2 -t elem -n "propertyTMP2" -i //propertyTMP2 -t attr -n "name" -v "propertyPrefix" \
    -i //propertyTMP2 -t attr -n "value" -v "jdbc.default." \
    -r //propertyTMP -v "property" \
    -r //propertyTMP2 -v "property" \
    -r //beanTMP -v "bean" \
    -r //beanTMP2 -v "bean" \
    file.xml
<?xml version="1.0"?>
<beans>
  <bean id="shardDataSource0" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
    <property name="targetDataSource">
      <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
        <property name="propertyPrefix" value="jdbc.default."/>
      </bean>
    </property>
  </bean>
  <bean id="shardDataSource1" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"><property name="targetDataSource"><bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean"><property name="propertyPrefix" value="jdbc.default."/></bean></property></bean>
</beans>
然而,结果如下:

<?xml version="1.0"?>

<beans>
    <bean id="liferayDataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
        <property name="targetDataSource">
            <bean class="org.springframework.aop.framework.ProxyFactoryBean">
                <property name="targetSource" ref="shardDataSourceTargetSource" />
            </bean>
        </property>
    </bean>

    <bean id="liferayHibernateSessionFactory" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="targetSource" ref="shardSessionFactoryTargetSource" />
    </bean>

    <bean id="shardDataSource0" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
        <property name="targetDataSource">
            <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
                <property name="propertyPrefix" value="jdbc.default." />
            </bean>
        </property>
    </bean>

    <bean id="shardDataSource1" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
        <property name="targetDataSource">
            <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
                <property name="propertyPrefix" value="jdbc.NIGERIA." />
            </bean>
        </property>
    </bean>

    <bean id="shardDataSource2" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
        <property name="targetDataSource">
            <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
                <property name="propertyPrefix" value="jdbc.MEDLAHO." />
            </bean>
        </property>
    </bean>

    <bean id="shardDataSourceTargetSource" class="com.liferay.portal.dao.shard.ShardDataSourceTargetSource">    
        <property name="dataSources">
            <map>
                <entry>
                    <key>
                        <value>default</value>
                    </key>
                    <ref bean="shardDataSource0" />
                </entry>
                <entry>
                    <key>
                        <value>NIGERIA</value>
                    </key>
                    <ref bean="shardDataSource1" />
                </entry>
                <entry>
                    <key>
                        <value>MEDLAHO</value>
                    </key>
                    <ref bean="shardDataSource2" />
                </entry>
            </map>
        </property>
    </bean>
    <bean id="shardSessionFactoryTargetSource" class="com.liferay.portal.dao.shard.ShardSessionFactoryTargetSource">
        <property name="shardDataSourceTargetSource" ref="shardDataSourceTargetSource" />
    </bean>
    <bean id="com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil" class="com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil">
        <property name="mappingSqlQueryFactory">
            <bean class="com.liferay.portal.dao.shard.ShardMappingSqlQueryFactoryImpl" />
        </property>
    </bean>
    <bean id="com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil" class="com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil">
        <property name="sqlUpdateFactory">
            <bean class="com.liferay.portal.dao.shard.ShardSqlUpdateFactoryImpl" />
        </property>
    </bean>
    <bean id="com.liferay.portal.kernel.dao.shard.ShardUtil" class="com.liferay.portal.kernel.dao.shard.ShardUtil">
        <property name="shard">
            <bean class="com.liferay.portal.dao.shard.ShardImpl">
                <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
            </bean>
        </property>
    </bean>
    <bean id="com.liferay.portal.kernel.util.InfrastructureUtil" class="com.liferay.portal.kernel.util.InfrastructureUtil">
        <property name="dataSource" ref="liferayDataSource" />
        <property name="mailSession" ref="mailSession" />
        <property name="shardDataSourceTargetSource" ref="shardDataSourceTargetSource" />
        <property name="shardSessionFactoryTargetSource" ref="shardSessionFactoryTargetSource" />
        <property name="transactionManager" ref="liferayTransactionManager" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardAdvice" class="com.liferay.portal.dao.shard.advice.ShardAdvice">
        <property name="shardDataSourceTargetSource" ref="shardDataSourceTargetSource" />
        <property name="shardSessionFactoryTargetSource" ref="shardSessionFactoryTargetSource" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardCompanyAdvice" class="com.liferay.portal.dao.shard.advice.ShardCompanyAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardPortletAdvice" class="com.liferay.portal.dao.shard.advice.ShardPortletAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice" class="com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" class="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardIterativelyAdvice" class="com.liferay.portal.dao.shard.advice.ShardIterativelyAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <bean id="com.liferay.portal.dao.shard.advice.ShardParameterAdvice" class="com.liferay.portal.dao.shard.advice.ShardParameterAdvice">
        <property name="shardAdvice" ref="com.liferay.portal.dao.shard.advice.ShardAdvice" />
    </bean>
    <aop:config proxy-target-class="false">
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardCompanyAdvice" pointcut="bean(com.liferay.portal.service.CompanyLocalService)" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portal.convert.messaging.ConvertProcessMessageListener.receive(..))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portal.events.StartupHelper.updateIndexes())" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portal.events.StartupHelper.upgradeProcess(int))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(* com.liferay.portal.service.ReleaseLocalService.getBuildNumberOrCreate())" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portal.service.ServiceComponentLocalService.upgradeDB(..))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardGloballyAdvice" pointcut="execution(void com.liferay.portlet.journal.service.JournalArticleLocalService.checkArticles())" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardIterativelyAdvice" pointcut="execution(void com.liferay.portal.events.StartupHelper.verifyProcess(boolean, boolean))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardParameterAdvice" pointcut="execution(* com.liferay.portal.service.AccountLocalService.getAccount(long, long))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardParameterAdvice" pointcut="execution(* com.liferay.portal.service.GroupLocalService.getCompanyGroup(long))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardParameterAdvice" pointcut="execution(* com.liferay.portal.service.UserLocalService.searchCount(..))" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice" pointcut="bean(*Persistence) || bean(*Finder)" />
        <aop:advisor advice-ref="com.liferay.portal.dao.shard.advice.ShardPortletAdvice" pointcut="bean(com.liferay.portal.service.PortletLocalService)" />
    </aop:config>
</beans>
xmlstarlet ed -a "/beans/bean[@id='shardDataSource0']" -t elem -n beanTMP -v ""  \
    -i //beanTMP -t attr -n "id" -v "shardDataSource1" \
    -i //beanTMP -t attr -n "class" -v "org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy" \
    -s //beanTMP -t elem -n "propertyTMP" -v "" \
    -i //propertyTMP -t attr -n "name" -v "targetDataSource" \
    -s //propertyTMP -t elem -n "beanTMP2" -v "" \
    -i //beanTMP2 -t attr -n "class" -v "com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean" \
    -s //beanTMP2 -t elem -n "propertyTMP2" -i //propertyTMP2 -t attr -n "name" -v "propertyPrefix" \
    -i //propertyTMP2 -t attr -n "value" -v "jdbc.default." \
    -r //propertyTMP -v "property" \
    -r //propertyTMP2 -v "property" \
    -r //beanTMP -v "bean" \
    -r //beanTMP2 -v "bean" \
    file.xml
<?xml version="1.0"?>
<beans>
  <bean id="shardDataSource0" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
    <property name="targetDataSource">
      <bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean">
        <property name="propertyPrefix" value="jdbc.default."/>
      </bean>
    </property>
  </bean>
  <bean id="shardDataSource1" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"><property name="targetDataSource"><bean class="com.liferay.portal.dao.jdbc.spring.DataSourceFactoryBean"><property name="propertyPrefix" value="jdbc.default."/></bean></property></bean>
</beans>

这意味着我没有得到正确的格式。我尝试了全局选项-p-S和--ps或--pf,但它们都不起作用。。。。 有人知道为什么会发生这种情况吗

提前向所有人表示感谢


更新2


我成功地将第一行xmlstarlet的格式设置为:xmlstarlet fo-R,这将格式化整个文档。但我确定这不是解决方法……伙计们,有什么线索吗?

XML名称空间问题。实际上,我发布了包含bean元素所有属性的文件,但为了测试,我将它们全部删除。我很抱歉要更新OP。您需要一组额外的引号:
“/beans/bean[@id='shardatasource0']”
@npostavs,非常感谢您的回答,这确实是该命令无法运行的地方。现在我有以下一行代码来创建整个bean块。不过,我没有一个合适的fomatting,(即使添加了-P-S全局选项)我也在更新OP。再次感谢您的帮助!XML命名空间问题。实际上,我发布了包含bean元素所有属性的文件,但为了测试,我将它们全部删除。我将更新OP。您需要一组额外的引号:
“/beans/bean[@id='shardatasource0']”
@npostavs,非常感谢您的回答,这确实是该命令无法运行的地方。现在我有以下几行代码来创建整个bean块。不过,我没有一个合适的fomatting(即使添加了-P-S全局选项),我正在更新OP。再次感谢您的帮助!