问题:
如何在下面的 xml 中构建一个表达式来查找给定属性值“ServiceBController”的 bean id“serviceB”?
XML:
<bean id="serviceA"
class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
<property name="jndiName">
<value>java:comp/env/ejb/ServiceAController</value>
</property>
</bean>
<bean id="serviceB"
class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
<property name="jndiName">
<value>java:comp/env/ejb/ServiceBController</value>
</property>
</bean>
<bean id="serviceC"
class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
<property name="jndiName">
<value>java:comp/env/ejb/ServiceCController</value>
</property>
</bean>
我尝试过的:
此模式具有正向前瞻以确保匹配在
id="
之前进行,然后是正向前瞻以确保匹配在 ServiceBController
之前进行。但这也匹配“serviceA”。
(?<=id=\")[^\"]+(?=[^\f]+ServiceBController)
我也尝试过对“serviceA”的结束 xml 标记进行负向后查找,但我不确定如何构造这个表达式。我想说的是:比赛必须以
ServiceBController
进行,但不能包含/bean
。
(?<=id=\")[^\"]+(?=[^\f]+ServiceBController(?
我会做什么::
$ xmllint --xpath 'string(//bean[@id="serviceB"])' file | perl -pe 's/\s+//g'
java:comp/env/ejb/ServiceBControllers