Reputation: 21
I am receiving an invalid XPath error from my enterprise service exit class, even though the XPath validates and returns data in an online validator. Can anyone explain what is causing the error?
Error in log:
[9/10/18 18:50:45:969 EDT] 00000024 SystemOut O 10 Sep 2018 18:50:45:969 [ERROR] [MXServer01] [] BMXAA1297E - Integration processing failed because the message includes an invalid XPath expression, such as the attribute indicator [@]. null psdi.util.MXApplicationException: BMXAA1297E - Integration processing failed because the message includes an invalid XPath expression, such as the attribute indicator [@]. null at psdi.iface.mic.StructureData.getStructureObjectList(StructureData.java:1219) at kub.iface.migexits.FwToMaxFollowupWoCreate.setUserValueIn(FwToMaxFollowupWoCreate.java:65) at psdi.iface.migexits.UserExit.callExitsIn(UserExit.java:112)
Partial Java code in user exit (last line shown is throwing the error):
public class FwToMaxFollowupWoCreate extends UserExit {
private static MXLogger myLogger = MXLoggerFactory.getLogger("maximo.abc.custom");
private static final String STREET_CUTS_XPATH = "//*[name()='streetCuts']";
@Override
public StructureData setUserValueIn(StructureData erData) {
try {
if (myLogger.isDebugEnabled()) {
myLogger.debug(className + ": Checking for street cuts");
myLogger.debug(erData.toString());
myLogger.debug("xpath = " + STREET_CUTS_XPATH);
}
List << ? > streetCuts = erData.getStructureObjectList(STREET_CUTS_XPATH);
Value of erData:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<metaId>2248684-A-388417</metaId>
<WONUM>D18-6286</WONUM>
<ASSETNUM>385691</ASSETNUM>
<LOCATION>G-VALVE-CONTROL-10134902</LOCATION>
<DESCRIPTION_LONGDESCRIPTION>This is a follow up work order created from field work</DESCRIPTION_LONGDESCRIPTION>
<COMMODITYGROUP>UTILITY</COMMODITYGROUP>
<COMMODITY>GAS</COMMODITY>
<REPORTEDBY>THA06318</REPORTEDBY>
<streetCuts>
<workDetails>
<WORKTYPE>PM</WORKTYPE>
<WOPRIORITY>3</WOPRIORITY>
</workDetails>
<specifications>
<ASSETATTRID>LENGTH</ASSETATTRID>
<DATATYPE>NUMERIC</DATATYPE>
<DISPLAYSEQUENCE>1</DISPLAYSEQUENCE>
<CLASSSPECID>2971</CLASSSPECID>
<VALUE>4</VALUE>
<MEASUREUNITID>FEET</MEASUREUNITID>
<MANDATORY>1</MANDATORY>
</specifications>
<specifications>
<ASSETATTRID>WIDTH</ASSETATTRID>
<DATATYPE>NUMERIC</DATATYPE>
<DISPLAYSEQUENCE>2</DISPLAYSEQUENCE>
<CLASSSPECID>2972</CLASSSPECID>
<VALUE>2</VALUE>
<MEASUREUNITID>FEET</MEASUREUNITID>
<MANDATORY>1</MANDATORY>
</specifications>
</streetCuts>
</root>
XPath expression: //*[name()='streetCuts']
Upvotes: 1
Views: 569
Reputation: 113
yes. the inbound data has to have a namespace of http://www.ibm.com/maximo or actually whatever is in the property mxe.int.xmlnamepace. IBM says that this is: "Represents the integration XML namespace.". Note that changing this can affect migration manager (source and target system values for this have to be the same for Migration Manager packages). In my case I got the same error, but the inbound data coming from a foreign system had a namespace of "http://schemas.xmlsoap.org/soap/envelope/.
It seems like the first thing invoked is a call to erData.breakData() which does this check.
So if you change your property to match then something else will probably break. if you can insert the namespace "http://www.ibm.com/maximo" into your data correctly, then you may be able to process it.
make sense? That is what apparently is causing the error.
Upvotes: 1
Reputation: 5730
If you are trying to select the element streetCuts
, the proper Xpath expression would be //streetCuts
. //streetCuts
means to select all the streetCuts
elements, regardless of their position in the document tree.
//*[name()='streetCuts']
could work too, if the name()
function is supported in your version of XPath. It is a roundabout way of doing the selection, as it would test each node to see if the name of the node were streetCuts
, rather than doing the native XML traversal that XPath offers. Additionally,
Because the result depends on the choice of namespace prefixes in the source document, it is not good practice to use the result of this function for anything other than display purposes. For example, the test name(.) = 'my:profile' will fail if the source document uses an unexpected namespace prefix. Such a test (assuming it relates to an element node) is better written as boolean(self::my:profile).W3 XPath documentation
Currently, java uses version version 1 of XSLT unless you specify otherwise.
Upvotes: 1