文件根据内容进行拆分

时间:2016-06-29 10:30:22

标签: java file

我有一个巨大的日志文件,里面有多个xml文件,我想检索每个xml然后用它来进行进一步的操作.xml会有相同的开始和结束字符串,我试过基于此分裂。我们该怎么做?

org.mule.config.spring.MuleArtifactContext@4044fb95: startup date [Wed Jun 29 04:37:43 EDT 2016]; root of context hierarchy
INFO  2016-06-29 04:37:46,560 [main] org.springframework.context.support.PropertySourcesPlaceholderConfigurer: Loading properties file from class path resource [workday-mule-presclub-bonusbase.properties]
INFO  2016-06-29 04:37:46,560 [main] org.springframework.context.support.PropertySourcesPlaceholderConfigurer: Loading properties file from class path resource [workday-mule-presclub-bonusbase-dev.properties]
INFO  2016-06-29 04:37:46,560 [main] org.springframework.context.support.PropertySourcesPlaceholderConfigurer: Loading properties file from class path resource [env/workday-mule-presclub-bonusbase-jz.properties]
INFO  2016-06-29 04:37:46,560 [main] org.springframework.context.support.PropertySourcesPlaceholderConfigurer: Loading properties file from URL [file:/var/wawa/properties/workday-mule-presclub-bonusbase.properties]
WARN  2016-06-29 04:37:46,560 [main] org.springframework.context.support.PropertySourcesPlaceholderConfigurer: Could not load properties from URL [file:/var/wawa/properties/workday-mule-presclub-bonusbase.properties]: \var\wawa\properties\workday-mule-presclub-bonusbase.properties (The system cannot find the path specified)
INFO  2016-06-29 04:37:46,561 [main] org.springframework.context.support.PropertySourcesPlaceholderConfigurer: Loading properties file from class path resource [workday-mule-presclub-bonusbase.properties]
INFO  2016-06-29 04:37:46,581 [main] org.springframework.context.support.PropertySourcesPlaceholderConfigurer: Loading properties file from class path resource [workday-mule-presclub-bonusbase-dev.properties]
INFO  2016-06-29 04:37:46,581 [main] org.springframework.context.support.PropertySourcesPlaceholderConfigurer: Loading properties file from class path resource [env/workday-mule-presclub-bonusbase-jz.properties]
INFO  2016-06-29 04:37:46,581 [main] org.springframework.context.support.PropertySourcesPlaceholderConfigurer: Loading properties file from URL [file:/var/wawa/properties/workday-mule-presclub-bonusbase.properties]
WARN  2016-06-29 04:37:46,581 [main] org.springframework.context.support.PropertySourcesPlaceholderConfigurer: Could not load properties from URL [file:/var/wawa/properties/workday-mule-presclub-bonusbase.properties]: \var\wawa\properties\workday-mule-presclub-bonusbase.properties (The system cannot find the path specified)
INFO  2016-06-29 04:37:46,610 [main] org.mule.config.spring.processors.NoDevkitInjectorProcessor: JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
WARN  2016-06-29 04:37:48,217 [main] org.mule.module.ognl.expression.OgnlExpressionEvaluator: OGNL module is deprecated and will be removed in Mule 4.0. Use MEL expressions instead.
INFO  2016-06-29 04:37:48,805 [main] org.mule.lifecycle.AbstractLifecycleManager: Initialising connector: connector.file.mule.default
INFO  2016-06-29 04:37:49,022 [main] org.mule.lifecycle.AbstractLifecycleManager: Initialising model: _muleSystemModel
INFO  2016-06-29 04:37:49,042 [main] org.mule.construct.FlowConstructLifecycleManager: Initialising flow: sap-to-databaseFlow
INFO  2016-06-29 04:37:49,042 [main] org.mule.exception.DefaultMessagingExceptionStrategy: Initialising exception listener: org.mule.exception.DefaultMessagingExceptionStrategy@24c8d8be
INFO  2016-06-29 04:37:49,066 [main] org.mule.processor.SedaStageLifecycleManager: Initialising service: sap-to-databaseFlow.stage1
INFO  2016-06-29 04:37:49,080 [main] org.mule.construct.FlowConstructLifecycleManager: Initialising flow: storpositionFlow
INFO  2016-06-29 04:37:49,080 [main] org.mule.exception.DefaultMessagingExceptionStrategy: Initialising exception listener: org.mule.exception.DefaultMessagingExceptionStrategy@28e0e464
INFO  2016-06-29 04:37:49,114 [main] org.mule.processor.SedaStageLifecycleManager: Initialising service: storpositionFlow.stage1
INFO  2016-06-29 04:37:49,858 [main] org.mule.module.apikit.Configuration: Building resource URI cache...
INFO  2016-06-29 04:37:49,858 [main] org.mule.construct.FlowConstructLifecycleManager: Initialising flow: bonus_base_president_club-main
INFO  2016-06-29 04:37:49,858 [main] org.mule.module.apikit.MappingExceptionListener: Initialising exception listener: MappingExceptionListener{statusCode=404, exceptions=[class org.mule.module.apikit.exception.NotFoundException]}
INFO  2016-06-29 04:37:49,858 [main] org.mule.module.apikit.MappingExceptionListener: Initialising exception listener: MappingExceptionListener{statusCode=405, exceptions=[class org.mule.module.apikit.exception.MethodNotAllowedException]}
INFO  2016-06-29 04:37:49,858 [main] org.mule.module.apikit.MappingExceptionListener: Initialising exception listener: MappingExceptionListener{statusCode=415, exceptions=[class org.mule.module.apikit.exception.UnsupportedMediaTypeException]}
INFO  2016-06-29 04:37:49,858 [main] org.mule.module.apikit.MappingExceptionListener: Initialising exception listener: MappingExceptionListener{statusCode=406, exceptions=[class org.mule.module.apikit.exception.NotAcceptableException]}
INFO  2016-06-29 04:37:49,858 [main] org.mule.module.apikit.MappingExceptionListener: Initialising exception listener: MappingExceptionListener{statusCode=400, exceptions=[class org.mule.module.apikit.exception.BadRequestException]}
INFO  2016-06-29 04:37:49,859 [main] org.mule.processor.SedaStageLifecycleManager: Initialising service: bonus_base_president_club-main.stage1
INFO  2016-06-29 04:37:49,859 [main] org.mule.construct.FlowConstructLifecycleManager: Initialising flow: post:/BonusBasePresidentClub:bonus_base_president_club-config
INFO  2016-06-29 04:37:49,869 [main] org.mule.exception.DefaultMessagingExceptionStrategy: Initialising exception listener: org.mule.exception.DefaultMessagingExceptionStrategy@113ee1ce
INFO  2016-06-29 04:37:49,879 [main] org.mule.processor.SedaStageLifecycleManager: Initialising service: post:/BonusBasePresidentClub:bonus_base_president_club-config.stage1
INFO  2016-06-29 04:37:49,879 [main] org.mule.construct.FlowConstructLifecycleManager: Initialising flow: request_bonus_payment
INFO  2016-06-29 04:37:49,879 [main] org.mule.exception.DefaultMessagingExceptionStrategy: Initialising exception listener: org.mule.exception.DefaultMessagingExceptionStrategy@34d480b9
INFO  2016-06-29 04:37:49,889 [main] org.mule.processor.SedaStageLifecycleManager: Initialising service: request_bonus_payment.stage1
INFO  2016-06-29 04:37:49,889 [main] org.mule.construct.FlowConstructLifecycleManager: Initialising flow: Submit_to_payroll
INFO  2016-06-29 04:37:49,889 [main] org.mule.exception.DefaultMessagingExceptionStrategy: Initialising exception listener: org.mule.exception.DefaultMessagingExceptionStrategy@b0f2d91
INFO  2016-06-29 04:37:49,899 [main] org.mule.processor.SedaStageLifecycleManager: Initialising service: Submit_to_payroll.stage1
INFO  2016-06-29 04:37:49,899 [main] org.mule.construct.FlowConstructLifecycleManager: Initialising flow: active-period-Flow
INFO  2016-06-29 04:37:49,899 [main] org.mule.exception.DefaultMessagingExceptionStrategy: Initialising exception listener: org.mule.exception.DefaultMessagingExceptionStrategy@794eeaf8
INFO  2016-06-29 04:37:49,909 [main] org.mule.processor.SedaStageLifecycleManager: Initialising service: active-period-Flow.stage1
INFO  2016-06-29 04:37:49,954 [main] org.mule.util.journal.TransactionJournal: Using files for tx logs C:\Users\zafarj1\Documents\Workspace_workday\.mule\.\.mule\workday-mule-presclub-bonusbase\queue-tx-log\tx1.log and C:\Users\zafarj1\Documents\Workspace_workday\.mule\.\.mule\workday-mule-presclub-bonusbase\queue-tx-log\tx2.log
INFO  2016-06-29 04:37:49,967 [main] org.mule.util.journal.TransactionJournal: Using files for tx logs C:\Users\zafarj1\Documents\Workspace_workday\.mule\.\.mule\workday-mule-presclub-bonusbase\queue-xa-tx-log\tx1.log and C:\Users\zafarj1\Documents\Workspace_workday\.mule\.\.mule\workday-mule-presclub-bonusbase\queue-xa-tx-log\tx2.log
INFO  2016-06-29 04:37:50,143 [main] org.mule.config.spring.SpringXmlConfigurationBuilder: Configured Mule using "org.mule.config.spring.SpringXmlConfigurationBuilder" with configuration resource(s): "[ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\sap-to-database.xml'}, ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\mule-config.xml'}, ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\location-store.xml'}, ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\bonus_base_president_club.xml'}, ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\bonus-base-to-workday.xml'}, ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\bonus-base-presclub-common.xml'}, ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\active-period-flow.xml'}]"
INFO  2016-06-29 04:37:50,143 [main] org.mule.config.builders.AutoConfigurationBuilder: Configured Mule using "org.mule.config.builders.AutoConfigurationBuilder" with configuration resource(s): "[ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\sap-to-database.xml'}, ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\mule-config.xml'}, ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\location-store.xml'}, ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\bonus_base_president_club.xml'}, ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\bonus-base-to-workday.xml'}, ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\bonus-base-presclub-common.xml'}, ConfigResource{resourceName='C:\Users\zafarj1\Documents\Workspace_workday\.mule\apps\workday-mule-presclub-bonusbase\active-period-flow.xml'}]"
INFO  2016-06-29 04:37:50,143 [main] org.mule.module.launcher.application.DefaultMuleApplication: 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Starting app 'workday-mule-presclub-bonusbase'           +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO  2016-06-29 04:37:50,153 [main] org.mule.util.queue.QueueXaResourceManager: Starting ResourceManager
INFO  2016-06-29 04:37:50,153 [main] org.mule.util.queue.QueueXaResourceManager: Started ResourceManager
INFO  2016-06-29 04:37:50,205 [main] org.mule.module.http.internal.listener.DefaultHttpListenerConfig: Listening for requests on http://0.0.0.0:9504
INFO  2016-06-29 04:37:50,215 [main] org.mule.transport.file.FileConnector: Connected: FileConnector
{
  name=connector.file.mule.default
  lifecycle=initialise
  this=485caa8f
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[file]
  serviceOverrides=<none>
}

INFO  2016-06-29 04:37:50,215 [main] org.mule.transport.file.FileConnector: Starting: FileConnector
{
  name=connector.file.mule.default
  lifecycle=initialise
  this=485caa8f
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[file]
  serviceOverrides=<none>
}

INFO  2016-06-29 04:37:50,215 [main] org.mule.lifecycle.AbstractLifecycleManager: Starting connector: connector.file.mule.default
INFO  2016-06-29 04:37:50,225 [main] org.mule.modules.workday.generated.agents.DefaultSplashScreenAgent: 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ DevKit Extensions (0) used in this application 
                             +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO  2016-06-29 04:37:50,225 [main] org.mule.lifecycle.AbstractLifecycleManager: Starting model: _muleSystemModel
INFO  2016-06-29 04:37:50,225 [main] org.mule.construct.FlowConstructLifecycleManager: Starting flow: sap-to-databaseFlow
INFO  2016-06-29 04:37:50,225 [main] org.mule.construct.FlowConstructLifecycleManager: Stopping flow: sap-to-databaseFlow
INFO  2016-06-29 04:37:50,225 [main] org.mule.construct.Flow: Flow sap-to-databaseFlow has not been started (initial state = 'stopped')
INFO  2016-06-29 04:37:50,225 [main] org.mule.construct.FlowConstructLifecycleManager: Starting flow: storpositionFlow
INFO  2016-06-29 04:37:50,225 [main] org.mule.processor.SedaStageLifecycleManager: Starting service: storpositionFlow.stage1
INFO  2016-06-29 04:37:50,235 [main] org.mule.construct.FlowConstructLifecycleManager: Starting flow: bonus_base_president_club-main
INFO  2016-06-29 04:37:50,235 [main] org.mule.processor.SedaStageLifecycleManager: Starting service: bonus_base_president_club-main.stage1
INFO  2016-06-29 04:37:50,255 [main] org.mule.module.apikit.Configuration: 
********************************************************************************
* APIKit Console URL: http://127.0.0.1:9504/api/console                        *
********************************************************************************
INFO  2016-06-29 04:37:50,255 [main] org.mule.construct.FlowConstructLifecycleManager: Starting flow: post:/BonusBasePresidentClub:bonus_base_president_club-config
INFO  2016-06-29 04:37:50,255 [main] org.mule.processor.SedaStageLifecycleManager: Starting service: post:/BonusBasePresidentClub:bonus_base_president_club-config.stage1
INFO  2016-06-29 04:37:50,265 [main] org.mule.construct.FlowConstructLifecycleManager: Starting flow: request_bonus_payment
INFO  2016-06-29 04:37:50,265 [main] org.mule.processor.SedaStageLifecycleManager: Starting service: request_bonus_payment.stage1
INFO  2016-06-29 04:37:50,275 [main] org.mule.construct.FlowConstructLifecycleManager: Starting flow: Submit_to_payroll
INFO  2016-06-29 04:37:50,275 [main] org.mule.construct.FlowConstructLifecycleManager: Stopping flow: Submit_to_payroll
INFO  2016-06-29 04:37:50,275 [main] org.mule.construct.Flow: Flow Submit_to_payroll has not been started (initial state = 'stopped')
INFO  2016-06-29 04:37:50,275 [main] org.mule.construct.FlowConstructLifecycleManager: Starting flow: active-period-Flow
INFO  2016-06-29 04:37:50,275 [main] org.mule.processor.SedaStageLifecycleManager: Starting service: active-period-Flow.stage1
INFO  2016-06-29 04:37:50,295 [main] org.mule.transport.file.FileConnector: Registering listener: active-period-Flow on endpointUri: file:///C:/Users/zafarj1/Desktop/ActivePeriod/
INFO  2016-06-29 04:37:50,335 [main] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'null'. Object is: FileMessageReceiver
INFO  2016-06-29 04:37:50,355 [main] org.mule.transport.file.FileMessageReceiver: Connecting clusterizable message receiver
INFO  2016-06-29 04:37:50,365 [main] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'null'. Object is: FileMessageReceiver
INFO  2016-06-29 04:37:50,365 [main] org.mule.transport.file.FileMessageReceiver: Starting clusterizable message receiver
INFO  2016-06-29 04:37:50,407 [main] org.mule.module.management.agent.WrapperManagerAgent: This JVM hasn't been launched by the wrapper, the agent will not run.
INFO  2016-06-29 04:37:54,976 [main] org.mule.module.management.agent.AbstractJmxAgent: Attempting to register service with name: Mule.workday-mule-presclub-bonusbase:type=Endpoint,service="active-period-Flow",connector=connector.file.mule.default,name="endpoint..C.Users.zafarj1.Desktop.ActivePeriod"
INFO  2016-06-29 04:37:54,976 [main] org.mule.module.management.agent.AbstractJmxAgent: Registered Endpoint Service with name: Mule.workday-mule-presclub-bonusbase:type=Endpoint,service="active-period-Flow",connector=connector.file.mule.default,name="endpoint..C.Users.zafarj1.Desktop.ActivePeriod"
INFO  2016-06-29 04:37:54,976 [main] org.mule.module.management.agent.AbstractJmxAgent: Registered Connector Service with name Mule.workday-mule-presclub-bonusbase:type=Connector,name="connector.file.mule.default.1"
INFO  2016-06-29 04:37:54,976 [main] org.mule.DefaultMuleContext: 
**********************************************************************
* Application: workday-mule-presclub-bonusbase                       *
* OS encoding: \, Mule encoding: UTF-8                               *
*                                                                    *
* Agents Running:                                                    *
*   Batch module default engine                                      *
*   JMX Agent                                                        *
*   DevKit Extension Information                                     *
*   Wrapper Manager                                                  *
**********************************************************************
INFO  2016-06-29 04:37:54,976 [main] org.mule.module.launcher.MuleDeploymentService: 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'workday-mule-presclub-bonusbase'            +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO  2016-06-29 04:37:54,986 [main] org.mule.module.launcher.DeploymentDirectoryWatcher: 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Mule is up and kicking (every 5000ms)                    +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO  2016-06-29 04:37:55,006 [main] org.mule.module.launcher.StartupSummaryDeploymentListener: 
**********************************************************************
*              - - + DOMAIN + - -               * - - + STATUS + - - *
**********************************************************************
* default                                       * DEPLOYED           *
**********************************************************************

*******************************************************************************************************
*            - - + APPLICATION + - -            *       - - + DOMAIN + - -       * - - + STATUS + - - *
*******************************************************************************************************
* workday-mule-presclub-bonusbase               * default                        * DEPLOYED           *
*******************************************************************************************************

INFO  2016-06-29 04:38:00,294 [[workday-mule-presclub-bonusbase].bonus_base_president_club-httpListenerConfig.worker.01] org.mule.api.processor.LoggerMessageProcessor: message received from HTTP
INFO  2016-06-29 04:38:02,101 [[workday-mule-presclub-bonusbase].bonus_base_president_club-httpListenerConfig.worker.01] org.mule.api.processor.LoggerMessageProcessor: <?xml version='1.0' encoding='UTF-8'?>
<ns0:Request_Bonus_Payment_Request xmlns:ns0="urn:com.workday/bsvc">
  <ns0:Request_Bonus_Payment_Data>
    <ns0:Employee_Reference>
      <Employee_ID>96</Employee_ID>
      <Employee_ID>118</Employee_ID>
    </ns0:Employee_Reference>
    <ns0:Effective_Date>
      <Effective_Date>2016-06-12T00:00:00</Effective_Date>
      <Effective_Date>2016-06-12T00:00:00</Effective_Date>
    </ns0:Effective_Date>
    <ns0:Bonus_Payment_Data>
      <ns0:Bonus_Plan_Reference>
        <Compensation_Plan_ID>BONUS_PLAN_STORE_OPERATIONS_BONUS_-_GENERAL_MANAGER</Compensation_Plan_ID>
        <Compensation_Plan_ID>BONUS_PLAN_STORE_OPERATIONS_BONUS_-_GENERAL_MANAGER</Compensation_Plan_ID>
      </ns0:Bonus_Plan_Reference>
      <ns0:Amount>
        <Amount>3146.7700</Amount>
        <Amount>1939.7200</Amount>
      </ns0:Amount>
      <ns0:Currency_Reference>
        <Currency_ID>USD</Currency_ID>
        <Currency_ID>USD</Currency_ID>
      </ns0:Currency_Reference>
      <ns0:Comment>
        <Comment>SBB-3-2016</Comment>
        <Comment>SBB-3-2016</Comment>
      </ns0:Comment>
    </ns0:Bonus_Payment_Data>
    <ns0:Ignore_Plan_Assignment>true</ns0:Ignore_Plan_Assignment>
  </ns0:Request_Bonus_Payment_Data>
</ns0:Request_Bonus_Payment_Request>
Retrieving document at 'jar:file:/C:/Users/zafarj1/Documents/Workspace_workday/.mule/tmp/workday-mule-presclub-bonusbase/plugins/workday-connector-8.0.0/lib/workday-connector-8.0.0.jar!/wsdl/Compensation.wsdl'.
ERROR 2016-06-29 04:38:08,802 [[workday-mule-presclub-bonusbase].bonus_base_president_club-httpListenerConfig.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : Validation error occurred. . Message payload is of type: ElementNSImpl
Type                  : org.mule.module.ws.consumer.SoapFaultException
Code                  : MULE_ERROR--2
JavaDoc               : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/module/ws/consumer/SoapFaultException.html
Payload               : [detail: null]
********************************************************************************
Exception stack is:
1. Validation error occurred. . Message payload is of type: ElementNSImpl (org.mule.module.ws.consumer.SoapFaultException)
  org.mule.module.ws.consumer.WSConsumer$1:196 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/module/ws/consumer/SoapFaultException.html)
********************************************************************************
Root Exception stack trace:
org.mule.module.ws.consumer.SoapFaultException: Validation error occurred. . Message payload is of type: ElementNSImpl
at org.mule.module.ws.consumer.WSConsumer$1.processNext(WSConsumer.java:196)
at org.mule.processor.AbstractRequestResponseMessageProcessor.processBlocking(AbstractRequestResponseMessageProcessor.java:56)
at org.mule.processor.AbstractRequestResponseMessageProcessor.process(AbstractRequestResponseMessageProcessor.java:47)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:85)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:56)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.module.ws.consumer.WSConsumer.process(WSConsumer.java:107)
at org.mule.devkit.3.8.2.internal.ws.model.InvokeSoapMessageProcessor$1.process(InvokeSoapMessageProcessor.java:89)
at org.mule.devkit.3.8.2.internal.ws.connection.DefaultProcessTemplate.execute(DefaultProcessTemplate.java:28)
at org.mule.devkit.3.8.2.internal.ws.model.InvokeSoapMessageProcessor
**********************************************************************
* default                                       * DEPLOYED           *
**********************************************************************

*******************************************************************************************************
*            - - + APPLICATION + - -            *       - - + DOMAIN + - -       * - - + STATUS + - - *
*******************************************************************************************************
* workday-mule-presclub-bonusbase               * default                        * DEPLOYED           *
*******************************************************************************************************

INFO  2016-06-29 04:38:00,294 [[workday-mule-presclub-bonusbase].bonus_base_president_club-httpListenerConfig.worker.01] org.mule.api.processor.LoggerMessageProcessor: message received from HTTP
INFO  2016-06-29 04:38:02,101 [[workday-mule-presclub-bonusbase].bonus_base_president_club-httpListenerConfig.worker.01] org.mule.api.processor.LoggerMessageProcessor: <?xml version='1.0' encoding='UTF-8'?>
<ns0:Request_Bonus_Payment_Request xmlns:ns0="urn:com.workday/bsvc">
  <ns0:Request_Bonus_Payment_Data>
    <ns0:Employee_Reference>
      <Employee_ID>96</Employee_ID>
      <Employee_ID>118</Employee_ID>
    </ns0:Employee_Reference>
    <ns0:Effective_Date>
      <Effective_Date>2016-06-12T00:00:00</Effective_Date>
      <Effective_Date>2016-06-12T00:00:00</Effective_Date>
    </ns0:Effective_Date>
    <ns0:Bonus_Payment_Data>
      <ns0:Bonus_Plan_Reference>
        <Compensation_Plan_ID>BONUS_PLAN_STORE_OPERATIONS_BONUS_-_GENERAL_MANAGER</Compensation_Plan_ID>
        <Compensation_Plan_ID>BONUS_PLAN_STORE_OPERATIONS_BONUS_-_GENERAL_MANAGER</Compensation_Plan_ID>
      </ns0:Bonus_Plan_Reference>
      <ns0:Amount>
        <Amount>3146.7700</Amount>
        <Amount>1939.7200</Amount>
      </ns0:Amount>
      <ns0:Currency_Reference>
        <Currency_ID>USD</Currency_ID>
        <Currency_ID>USD</Currency_ID>
      </ns0:Currency_Reference>
      <ns0:Comment>
        <Comment>SBB-3-2016</Comment>
        <Comment>SBB-3-2016</Comment>
      </ns0:Comment>
    </ns0:Bonus_Payment_Data>
    <ns0:Ignore_Plan_Assignment>true</ns0:Ignore_Plan_Assignment>
  </ns0:Request_Bonus_Payment_Data>
</ns0:Request_Bonus_Payment_Request>
Retrieving document at 'jar:file:/C:/Users/zafarj1/Documents/Workspace_workday/.mule/tmp/workday-mule-presclub-bonusbase/plugins/workday-connector-8.0.0/lib/workday-connector-8.0.0.jar!/wsdl/Compensation.wsdl'.
ERROR 2016-06-29 04:38:08,802 [[workday-mule-presclub-bonusbase].bonus_base_president_club-httpListenerConfig.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : Validation error occurred. . Message payload is of type: ElementNSImpl

我需要从这个日志中获取这些单独的xmls。

<?xml version='1.0' encoding='UTF-8'?>
<ns0:Request_Bonus_Payment_Request xmlns:ns0="urn:com.workday/bsvc">
  <ns0:Request_Bonus_Payment_Data>
    <ns0:Employee_Reference>
      <Employee_ID>96</Employee_ID>
      <Employee_ID>118</Employee_ID>
    </ns0:Employee_Reference>
    <ns0:Effective_Date>
      <Effective_Date>2016-06-12T00:00:00</Effective_Date>
      <Effective_Date>2016-06-12T00:00:00</Effective_Date>
    </ns0:Effective_Date>
    <ns0:Bonus_Payment_Data>
      <ns0:Bonus_Plan_Reference>
        <Compensation_Plan_ID>BONUS_PLAN_STORE_OPERATIONS_BONUS_-_GENERAL_MANAGER</Compensation_Plan_ID>
        <Compensation_Plan_ID>BONUS_PLAN_STORE_OPERATIONS_BONUS_-_GENERAL_MANAGER</Compensation_Plan_ID>
      </ns0:Bonus_Plan_Reference>
      <ns0:Amount>
        <Amount>3146.7700</Amount>
        <Amount>1939.7200</Amount>
      </ns0:Amount>
      <ns0:Currency_Reference>
        <Currency_ID>USD</Currency_ID>
        <Currency_ID>USD</Currency_ID>
      </ns0:Currency_Reference>
      <ns0:Comment>
        <Comment>SBB-3-2016</Comment>
        <Comment>SBB-3-2016</Comment>
      </ns0:Comment>
    </ns0:Bonus_Payment_Data>
    <ns0:Ignore_Plan_Assignment>true</ns0:Ignore_Plan_Assignment>
  </ns0:Request_Bonus_Payment_Data>
</ns0:Request_Bonus_Payment_Request>

2 个答案:

答案 0 :(得分:1)

这样......

public class Test {

    public static final String START_TAG = "<ns0:Request_Bonus_Payment_Request xmlns:ns0=\"urn:com.workday/bsvc\">";

    public static final String END_TAG = "</ns0:Request_Bonus_Payment_Request>";

    public static void main(String[] args) throws Exception {
        List<String> xmls = new ArrayList<String>();

        FileReader fr = new FileReader(new File("example.txt"));
        BufferedReader br = new BufferedReader(fr);
        String temp = null;

        while ((temp=br.readLine()) !=null) {
            if (temp.contains(START_TAG)) {
                StringBuffer xml = new StringBuffer();

                while (!temp.contains(END_TAG)) {
                    xml.append(temp);
                    temp = br.readLine();
                }
                xml.append(temp);
                xmls.add(xml.toString());
            }
        }

        System.out.println("XMLs are "+xmls);

    } 

List包含所有xmls。

请注意,我在内存中保存所有xmls。如果您的文件太大和/或堆内存很小,您可能会遇到OutOfMemory

答案 1 :(得分:-1)

org.codehaus.stax2.XMLStreamReader2 might help you.

用法:

  1. 将输入文件传递给XMLStreamReader2

    ((XMLInputFactory2)XMLInputFactory.newInstance())。createXMLStreamReader(xmlFile);

  2. 通过hasNext()方法

  3. 遍历读者
  4. 利用xmlStreamReader.getEventType() == XMLEvent.START_ELEMENT查找xml的开始标记

  5. 最后使用javax.xml.transform.TransformerFactory写入新文件

相关问题