cancel
Showing results for 
Search instead for 
Did you mean: 

'Cannot create target element' error

Former Member
0 Kudos

Hello,

I am very new to PI so please bear with me as I attempt my problem...

In one of my message mappings I am get the following error:

Cannot create target element /ns1:MeterReadingResults/Route/ReadingInformation[269]/Reading/AddressCode1. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD

From my research, I thought that the mapWithDefault function might help here (I inserted it between the last IfThenElse output and the target node); I tried mapWithDefault in all sorts of combinations here but the error remains. For a sanity check, I sent a Constant value directly to the target node which allowed the entire mapping to run successfully -- so the error must be in here. I'm not sure what to try next and this is becoming a crucial issue for my company; would anyone be able to assist this PI newbie?

........................................................................................................................

The intended flow of this node mapping is as follows: If the MeterChangeData ('MeterCha...') node exists, use the NewReadingInstructionCode1 ('NewRead...') node value. Otherwise, use the ReadInstructionCode1 ('ReadInstr...'). If the resulting value is either 98 or 99, map it to another value (via FixValues function). Output the resulting value to the target node.

........................................................................................................................

Here is my mapping ('collapseC' below is the collapseContexts function, 'queue' is a UDF and the code for it is at the bottom of the post):

BTW, here is the code for the 'queue' UDF (I'm not sure exactly how it's supposed to work, it was already in place when I came on board):

public void queue(String[] node, String[] flag, ResultList result, String type, Container container) throws StreamTransformationException{

Map<String, String[]> map = new HashMap<String, String[]>();

AbstractTrace trace = container.getTrace();

GlobalContainer globalContainer = container.getGlobalContainer();

trace.addInfo("Node Length (queue) = " + node.length);   // trace

trace.addInfo("Flag Value = " + flag[0].toString());  // trace

// Get global queue.

Object o = globalContainer.getParameter("queue");

if( o != null ) {  // queue exists

  map = (Map)o;

}

// Add node values to global queue.

if( node.length > 0 ) {

          map.put(type, node);

          trace.addInfo("Node Added to Queue");  // trace

}

globalContainer.setParameter("queue", map);

// Set result value based on flag and type.

if( flag[0].toString().equalsIgnoreCase("true") && map.containsKey(type) ) {  // flag = true

 

          // Get node values from queue.

          node = new String[map.get(type).length];

          node = map.get(type);

    trace.addInfo("Node Values Retrieved from Queue");  // trace

          // Add node value to result.

          trace.addInfo("Node [0] Value = " + node[0].toString());  // trace

          result.addValue(node[0]);

          trace.addInfo("Node Added to Result");  // trace

          // Delete node value from queue.

          for( int i = 1; i < node.length; i++ ) {

                    node[i-1] = node[i];

          }

 

          // Save updated queue.

          map.put(type, node);

          globalContainer.setParameter("queue", map);

          trace.addInfo("Node Values Updated in Global Queue");  // trace

}

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I think the values you are sending in that 269th node contains values which conflict with the mapping thats why its not able to create the node.

Former Member
0 Kudos

Thank you for your comments Ankit,

It turned out to be a context switching issue. We resolved this by utilizing the useOneAsMany function (the last IfThenElse output went to parameter 1, parameters 2 and 3 were supplied with another node and one of it's subnodes from the input structure).

-Nadir

Former Member
0 Kudos

Hi Nadir,

Looking at your problem the problem seems to be in the XML node 269 as it is mentioned:

Cannot create target element /ns1:MeterReadingResults/Route/ReadingInformation[269]/Reading/AddressCode1.

And the problem is with the field above addresscode1 i guess.

You first have to find out thta node that is creating problem because if the mapping was not working then above 268 nodes must not have gone through. So i know it is a bit difficult to find out the 269 number node but you can download free version of Foxe XML editor to achieve this through this website: http://www.firstobject.com/dn_editor.htm.

Please find out the errored node and then use only that node in test mapping you will easily know the error.

Thanks.

Former Member
0 Kudos

Hello Gaurav,

Thank you for the response. I downloaded the Foxe XML Editor and it showed me the 269th node (which happens to be the very last node). When testing against this individual node, strangely I got a successful mapping...

When you say problem may be with the node above AddressCode1 do you mean the parent node or the node in the same context but directly preceding AddressCode1? The directly preceding node ('Identification', shown below) takes in a constant value:

Some observations here:

1. I am able to successfully map the entire payload when passing a constant value to the AddressCode1 field. Wouldn't that be my indication that the problem lies with AddressCode1 or am I not seeing the bigger picture?

2. This message mapping is the second of three message mappings in the operation mapping (shown below):

When I run the entire payload through the whole operation mapping I get the expected error. But if I run the entire payload through the first individual message mapping and run the resulting payload through this problematic second message mapping, the mapping is successful. Why would it be successful here but not during the operation mapping test?

Thank you for any help you can provide.

-Nadir

Former Member
0 Kudos

Hi..when you display the queue for the field AddressCode1, how many values do you see in that?

The error seems to suggest that the mapping expects at least 269 values where as the source does not provide that many values.

Regards,

RR

Former Member
0 Kudos

Hello Rajith,

Thank you for your reply... Here is the queue for AddressCode1 showing the 269th entry (there are 652 entries in the queue):

Here are final entries in the queue:

Former Member
0 Kudos

any luck ?