Where to put DTD files and schemas

I have a pretty typical JavaEE application compiled using EJB3, seam components, spring beans and JSF, which are packaged into several jar and war files inside an ear file. Naturally, for JavaEE we have many XML files as part of the application. Some of these XML files are checked using DTD (seam), and some are checked using a schema.

Like most files taken from examples and from other projects, all DTDs and schemes refer to the project site where the DTD or default scheme is located. This raises a problem: for some reason, the JBoss site skips the DTD seam today (check http://www.jboss.com/products/seam/components-1.1.dtd , http://www.jboss.com/products/ seam / components-1.2.dtd , http://www.jboss.com/products/seam/components-2.0.dtd ). Because the JBoss server validates the XML in the bootstrap using this location, application deployment failed.

My question is this: given this case, where should I put the DTD files and definitions? I see three options:

  • Use the default location as before. Since this means that now I am adding the stability of JBoss, Sun, spring and any other provider to my system, if I need to redeploy the application, I do not want to do this.
  • Copy all the DTD files and schemas to my server by pointing the URLS to the server under my control.
  • Copy all the DTD files and schemas to the application or application server and use them locally.

I prefer to use option number 3, because it provides full control over files without network dependencies. In the test that we performed, it even significantly reduced server load time - perhaps the XML parser does not cache definitions. Is there something I missed taking this path?

+4
source share
2 answers

No, this is the right thing. The first should be used only to mess around or play with the code, but not for something serious, and the second does not have an advantage over the third and is more difficult at the same time.

0
source

The real question is: do I really need to validate xml files? In most cases, validation is not performed in production code - it is too slow in most cases.

If you really want to check, go to option number 3.

0
source

All Articles