I have an input XML something on this line:
<Holding id="12">
<Policy>
<HoldingForm tc="1">Individual</HoldingForm>
<PolNumber>848433</PolNumber>
<LineOfBusiness tc="1">Life</LineOfBusiness>
<CarrierCode>67644</CarrierCode>
</Policy>
</Holding>
My manipulation on this XML depends on if <PolNumber>
(its an optional element in schema) has a value or not. I'm using Mule 3.3 xpath
evaluator to do this and my XPath expression looks this:
<expression-filter expression="#[xpath('//acord:Holding/acord:Policy/acord:PolNumber').text != empty]"/>
This works fine as long as <PolNumber>
element is present or <PolNumber/>
is empty element. But if <PolNumber>
is absent, above expression throws exception.
I tried using XPath boolean function but it returns true
for <PolNumber/>
. Is there a better way of checking if an element is present and non-empty?
EDIT:
This is the configuration of namespace manager in my mule config
<xm:namespace-manager includeConfigNamespaces="true">
<xm:namespace prefix="acord" uri="http://ACORD.org/Standards/Life/2" />
<xm:namespace prefix="soap" uri="http://schemas.xmlsoap.org/soap/encoding/" />
</xm:namespace-manager>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…