How to tell using xpath if an element is present and non empty

zhoutao

New Member
I have an input XML something on this line:\[code\]<Holding id="12"> <Policy> <HoldingForm tc="1">Individual</HoldingForm> <PolNumber>848433</PolNumber> <LineOfBusiness tc="1">Life</LineOfBusiness> <CarrierCode>67644</CarrierCode> </Policy></Holding>\[/code\]My manipulation on this XML depends on if \[code\]<PolNumber>\[/code\] (its an optional element in schema) has a value or not. I'm using Mule 3.3 \[code\]xpath\[/code\] evaluator to do this and my xpath looks this:\[code\]<expression-filter expression="#[xpath('//acord:Holding/acord:policy/acord:polNumber').text != empty]"/> \[/code\]This works fine as long as \[code\]<PolNumber>\[/code\] element is present or \[code\]<PolNumber/>\[/code\] is empty element. But if \[code\]<PolNumber>\[/code\] is absent, above expression throws exception.I tried using xpath boolean function but it returns \[code\]true\[/code\] for \[code\]<PolNumber/>\[/code\]. 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\[code\]<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>\[/code\]
 
Top