Dennis Ich
Dennis Ich

Reputation: 3785

Validating spring config xml Files in Java

i want to validate some files looking like this:

<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd />

...
<bean>...</bean>
...
</beans>

Some of them have more xmlns and locations and some less. Someone knows if there is any api where u just give in such files and it will validate it in java?

greetings

Upvotes: 0

Views: 1108

Answers (2)

Haris Krajina
Haris Krajina

Reputation: 15296

There you go.

http://download.oracle.com/javase/1,5,0/docs/api/javax/xml/validation/package-summary.html

You can wrap it and make parser that will first extract schemas, then use them for validation.

Upvotes: 0

DwB
DwB

Reputation: 38328

Spring will validate spring configuration files. You can write a junit that loads your configuration to test if the configuration files are formatted correctly.

Upvotes: 1

Related Questions