Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Any idea how to loop and add all the value to the attribute of the xml node?

Avatar

Level 1

I am working on a batch flattening project using Watched Folder.

I have a parent process for locating the directory and invokes a subprocess for flattening the PDF files.

I want to write the failed directory to the XML.

If there are multiple failed directory locations and if I want to add it to the node, it won't let me do.

If I set the Xpath location as /process_data/outputXML/flattenDirectoryRequestMessage/failureFileLocation[x]/@path it gives me invalid character exception.I am using 'x' for looping and incrementing.

If I don't use the [x]. The directory is overwritten.

Any idea how to loop and add all the failed directories to the attribute of the xml node?

1 Accepted Solution

Avatar

Correct answer by
Level 1

I understood that you cannot loop through the xml to assign value to each node. Rather you can assign it only once to the node.

I figured out that, it is not possible to do it that way. So we have to concatenate it as Strings and then attach to the xml once.

View solution in original post

3 Replies

Avatar

Level 10

I presume that X is a variable of type int.

Just modify the XPATH expression as below and give it a try..

OR

Nith

Avatar

Level 1

Hi Nith,

I tried all this options, Still I get the same error. Anytime I use square parenthesis ([]) I am getting this error. I think may be in Xpath we cannot use the [] to assign values, we can only parse to retreive the values and assign it to another variable in the procees_data. I am not sure tho.

org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.

    at org.apache.xerces.dom.CoreDocumentImpl.createElement(Unknown Source)

    at com.adobe.workflow.datatype.runtime.impl.xml.XMLDataTypeNode.newElement(XMLDataTypeNode.java:59)

    at com.adobe.workflow.dom.InstanceElement.createAndAppendElement(InstanceElement.java:455)

    at com.adobe.workflow.pat.service.PATExecutionContextImpl.createNodesForXPathExpression(PATExecutionContextImpl.java:899)

    at com.adobe.workflow.pat.service.PATExecutionContextImpl.setProcessDataValue(PATExecutionContextImpl.java:687)

    at com.adobe.workflow.pat.service.PATExecutionContextImpl.setProcessDataWithExpression(PATExecutionContextImpl.java:376)

    at com.adobe.idp.workflow.dsc.service.SetValueService.execute(SetValueService.java:54)

    at sun.reflect.GeneratedMethodAccessor210.invoke(Unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

    at java.lang.reflect.Method.invoke(Method.java:600)

    at com.adobe.idp.dsc.component.impl.DefaultPOJOInvokerImpl.invoke(DefaultPOJOInvokerImpl.java:118)

    at com.adobe.idp.workflow.dsc.invoker.WorkflowDSCInvoker.invoke(WorkflowDSCInvoker.java:154)

    at com.adobe.idp.dsc.interceptor.impl.InvocationInterceptor.intercept(InvocationInterceptor.java:140)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.interceptor.impl.DocumentPassivationInterceptor.intercept(DocumentPassivationInterceptor.java:53)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.transaction.interceptor.TransactionInterceptor$1.doInTransaction(TransactionInterceptor.java:74)

    at com.adobe.idp.dsc.transaction.impl.ejb.adapter.EjbTransactionCMTAdapterBean.execute(EjbTransactionCMTAdapterBean.java:357)

    at com.adobe.idp.dsc.transaction.impl.ejb.adapter.EjbTransactionCMTAdapterBean.doSupports(EjbTransactionCMTAdapterBean.java:227)

    at com.adobe.idp.dsc.transaction.impl.ejb.adapter.EJSLocalStatelessEjbTransactionCMTAdapter_caf58c4f.doSupports(Unknown Source)

    at com.adobe.idp.dsc.transaction.impl.ejb.EjbTransactionProvider.execute(EjbTransactionProvider.java:104)

    at com.adobe.idp.dsc.transaction.interceptor.TransactionInterceptor.intercept(TransactionInterceptor.java:72)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.interceptor.impl.InvocationStrategyInterceptor.intercept(InvocationStrategyInterceptor.java:55)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.interceptor.impl.InvalidStateInterceptor.intercept(InvalidStateInterceptor.java:37)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.interceptor.impl.AuthorizationInterceptor.intercept(AuthorizationInterceptor.java:188)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.interceptor.impl.JMXInterceptor.intercept(JMXInterceptor.java:48)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.engine.impl.ServiceEngineImpl.invoke(ServiceEngineImpl.java:115)

    at com.adobe.idp.dsc.routing.Router.routeRequest(Router.java:129)

    at com.adobe.idp.dsc.provider.impl.base.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:93)

    at com.adobe.idp.dsc.provider.impl.vm.VMMessageDispatcher.doSend(VMMessageDispatcher.java:225)

    at com.adobe.idp.dsc.provider.impl.base.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:66)

    at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:167)

    at com.adobe.workflow.engine.PEUtil.invokeAction(PEUtil.java:885)

    at com.adobe.idp.workflow.dsc.invoker.WorkflowDSCInvoker.transientInvoke(WorkflowDSCInvoker.java:347)

    at com.adobe.idp.workflow.dsc.invoker.WorkflowDSCInvoker.invoke(WorkflowDSCInvoker.java:158)

    at com.adobe.idp.dsc.interceptor.impl.InvocationInterceptor.intercept(InvocationInterceptor.java:140)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.interceptor.impl.DocumentPassivationInterceptor.intercept(DocumentPassivationInterceptor.java:53)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.transaction.interceptor.TransactionInterceptor$1.doInTransaction(TransactionInterceptor.java:74)

    at com.adobe.idp.dsc.transaction.impl.ejb.adapter.EjbTransactionCMTAdapterBean.execute(EjbTransactionCMTAdapterBean.java:357)

    at com.adobe.idp.dsc.transaction.impl.ejb.adapter.EjbTransactionCMTAdapterBean.doRequiresNew(EjbTransactionCMTAdapterBean.java:299)

    at com.adobe.idp.dsc.transaction.impl.ejb.adapter.EJSLocalStatelessEjbTransactionCMTAdapter_caf58c4f.doRequiresNew(Unknown Source)

    at com.adobe.idp.dsc.transaction.impl.ejb.EjbTransactionProvider.execute(EjbTransactionProvider.java:143)

    at com.adobe.idp.dsc.transaction.interceptor.TransactionInterceptor.intercept(TransactionInterceptor.java:72)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.interceptor.impl.InvocationStrategyInterceptor.intercept(InvocationStrategyInterceptor.java:55)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.interceptor.impl.InvalidStateInterceptor.intercept(InvalidStateInterceptor.java:37)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.interceptor.impl.AuthorizationInterceptor.intercept(AuthorizationInterceptor.java:188)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.interceptor.impl.JMXInterceptor.intercept(JMXInterceptor.java:48)

    at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptorChainImpl.java:60)

    at com.adobe.idp.dsc.engine.impl.ServiceEngineImpl.invoke(ServiceEngineImpl.java:115)

    at com.adobe.idp.dsc.routing.Router.routeRequest(Router.java:129)

    at com.adobe.idp.dsc.provider.impl.base.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:93)

    at com.adobe.idp.dsc.provider.impl.vm.VMMessageDispatcher.doSend(VMMessageDispatcher.java:225)

    at com.adobe.idp.dsc.provider.impl.base.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:66)

    at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:167)

    at com.adobe.idp.jobmanager.execution.workadapter.AbstractExecutableJob.invokeRequest(AbstractExecutableJob.java:127)

    at com.adobe.idp.jobmanager.execution.workadapter.PersistentExecutableJob.execute(PersistentExecutableJob.java:60)

    at com.adobe.idp.dsc.workmanager.adapter.UnManagedAsynchronousWorkAdapter.run(UnManagedAsynchronousWorkAdapter.java:39)

    at com.adobe.idp.dsc.workmanager.adapter.websphere.J2WA_Work.run(J2WA_Work.java:34)

    at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:782)

    at com.ibm.ws.asynchbeans.WorkWithExecutionContextImpl.go(WorkWithExecutionContextImpl.java:222)

    at com.ibm.ws.asynchbeans.ABWorkItemImpl.run(ABWorkItemImpl.java:159)

    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)

Avatar

Correct answer by
Level 1

I understood that you cannot loop through the xml to assign value to each node. Rather you can assign it only once to the node.

I figured out that, it is not possible to do it that way. So we have to concatenate it as Strings and then attach to the xml once.