I have an application context defined using XML config files with the Spring 2.5 XSD, and would like to use XML entities to provide an extension point for customizing a client's installation.
I started with an XML config file defined in the customary fashion:
Now, I would like to define some entities that will be resolved using a filesystem resource. A couple of Google searches suggest adding the following inline DTD snippet:Code:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:sec="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"> <!-- Define beans here... --> </beans>
The problem I'm running into is that the Spring 2.5 XSD referenced in my document root seems to be disregarded in favor of the more restrictive DTD, and the SAX parser no longer accepts my config file as valid XML. I get exceptions such as:Code:<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "springframework.org/dtd/spring-beans-2.0.dtd" [ <!ENTITY % entities SYSTEM "my/path/entities.ent" > %entities; ]>
org.xml.sax.SAXParseException: Attribute "xmlns" must be declared for element type "beans".
I need the more flexible XSD-based validation because I'm using elements from the Spring Security namespace that are not allowed by the simple DTD. Any suggestions on how to get DTD-based XML entity declarations to co-exist with the Spring 2.5 XSD?


Reply With Quote
