Announcement Announcement Module
Collapse
No announcement yet.
XSD namespace problem with xml configuration file? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • XSD namespace problem with xml configuration file?

    Hello,

    I have some problem writing the xml configuration file for my spring batch test application.
    This is the xml file:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" 
    		xmlns:batch="http://www.springframework.org/schema/batch"	
    		xmlns:aop="http://www.springframework.org/schema/aop"
    		xmlns:tx="http://www.springframework.org/schema/tx"
    		xmlns:p="http://www.springframework.org/schema/p"
    		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    		xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    			http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
    			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
     
    	<import resource="MEMORY-JOBREPOSITORY.xml"/>  
    	<!--<import resource="DB-JOBREPOSITORY.xml"/> -->
    	 
    	<bean id="tasklet1" class="com.springbatch.test.Tasklet1"/>
    	
    	<bean id="tasklet2" class="com.springbatch.test.Tasklet2"/>
    	
    	<bean id="parameter" class="com.springbatch.test.Parameter" />
    	
    	<bean id="promotionListener" class="org.springframework.batch.core.listener.ExecutionContextPromotionListener">
    		<property name="keys" value="keyValue" />
    	</bean>
    	
    	<job id="passingParametersJob" job-repository="jobRepository">
    		<step id="step1" next="step2">
    			<tasklet ref="tasklet1" transaction-manager="jobRepository-transactionManager">
    				<listeners>
    					<listener ref="promotionListener"/>
    				</listeners>
    			</tasklet>
    		</step>  
    		  	
    		<step id="step2">
    			<tasklet ref="tasklet2" transaction-manager="jobRepository-transactionManager" />
    		</step>
    		
    	</job> 
    </beans>
    The problem is that I receive the following message:
    cvc-complex-type.2.4.a: A content starting with element 'job' has been detected. One of the following is expected: '{"http://www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/schema/beans"]}'.
    I don't understand if there is some XSD I am missing in the XML header or not.

    Anyway, if I write the <job> section as it follows, the error is not going to be shown:
    Code:
    <batch:job id="passingParametersJob" job-repository="jobRepository">
    	<batch:step id="step1" next="step2">
    		<batch:tasklet ref="tasklet1" transaction-manager="jobRepository-transactionManager">
    			<batch:listeners>
    				<batch:listener ref="promotionListener"/>
    			</batch:listeners>
    		</batch:tasklet>
    	</batch:step>  
    	  	
    	<batch:step id="step2">
    		<batch:tasklet ref="tasklet2" transaction-manager="jobRepository-transactionManager" />
    	</batch:step>
    		
    </batch:job>
    What to do in order to be not obliged to use the batch: namespace before tags in the job section?

  • #2
    I suggest a read up on xml and xsd and how they work together...

    Code:
    <beans xmlns="http://www.springframework.org/schema/beans" 
    		xmlns:batch="http://www.springframework.org/schema/batch"
    Currently your beans namespace is the root namespace (red) and not batch, so to be able to use job you have to prefix it with batch:. Now you can switch to the batch namespace however then you have to write beans:bean because you can only have a single root namespace.

    Code:
    <batch xmlns="http://www.springframework.org/schema/batch" 
    		xmlns:beans="http://www.springframework.org/schema/beans"
    To switch the namespace, make sure to include the beans namespace somewhere and prefix bean, property and import with beans: .

    Comment


    • #3
      Best tutorial about XSD my friend: http://www.w3schools.com/schema/default.asp

      Comment


      • #4
        Originally posted by Marten Deinum View Post
        To switch the namespace, make sure to include the beans namespace somewhere and prefix bean, property and import with beans: .
        Thanks for replying.
        So, as far as I understand, since I can only have only one root namespace, the problem is not resolvable, because if I change root namespace I will have the same problem with the beans namespace where I would have to use "beans:" before beans tags.


        Bythe way: thanks traduz, I will see that.

        Comment


        • #5
          Now answering your question, use like this:
          Code:
          <job id="sBatchRenewJob" xmlns="http://www.springframework.org/schema/batch">
          My root namespace
          Code:
          xmlns="http://www.springframework.org/schema/beans"
          and work without a problem.

          Comment


          • #6
            Thanks a lot!
            Understood!

            It works to me too.

            Comment

            Working...
            X