Creating your own xsd

From Null-pointer

Jump to: navigation, search

To allow your own namespaced XSD. In this case I want to have the annotation:

<memcached:annotation-driven cache-manager="memcachedManager" proxy-target-class="true"  />
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xmlns:memcached="http://www.null-pointer.co.uk/schema/memcached"
	   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
	   http://www.null-pointer.co.uk/schema/memcached http://www.null-pointer.co.uk/schema/memcached/memcached-spring-1.0.xsd">
 
	<memcached:annotation-driven cache-manager="memcachedManager" proxy-target-class="true"  />
 
	<bean id="memcachedManager" class="null-pointer.memcacheFactory" destroy-method="close">
		<property name="failSilently" value="true"/>
	</bean>
</beans>

You need:

  • an xsd file
  • spring.handlers
  • spring.schemas

Contents

Your xsd file

Use the following file for the basis of you xsd.

spring.handlers

/META-INF/spring.handlers
http\://www.null-pointer.co.uk/schema/memcached=null-pointer.memcached.config.AnnotationDrivenMemcachedNamespaceHandler

spring.schemas

/META-INF/spring.schemas
http\://www.null-pointer.co.uk/schema/memcached/memcached-spring-1.0.xsd=null-pointer/memcached/memcached-spring-1.0.xsd

References

Personal tools