RE: How can I register a DTD in a war

2002-02-20 Thread Jan Søgaard

Hi Benoit

Remember that the resources under /WEB-INF/ is not directly accessible
for the end user.
If you place your DTD in a directory TOMCAT_HOME/webapps/myApplication/ 
You will have directly access to it, from other applications, accessing
the DTD through tomcat.

e.g..

I have a dtd placed in TOMCAT_HOME/webapps/myapp/my.dtd
the receiving XML have the following header:

?xml version=1.0 encoding=ISO-8859-1?
!DOCTYPE message SYSTEM http://127.0.0.1:8090/myapp/my.dtd;

And my Servlet is able to validate the document according to this DTD.

So, in short, I don't think you need to register your dtd, just placed
it, in a directory outside the WEB-INF.
Then every application can access it, through the URL, not the fully
qualified path.

If this is not, what you questioned, please explain your problem, and I
will try to help

Jan


-Original Message-
From: Benoit Segaert [mailto:[EMAIL PROTECTED]]
Sent: 20. februar 2002 10:39
To: [EMAIL PROTECTED]
Subject: How can I register a DTD in a war


I want to validate a XML with a DTD in a War application.
I have my DTD available in the war file.

I use a XML file like the following:

?xml version=1.0 encoding=ISO-8859-1 ?
!DOCTYPE Application SYSTEM

file:///C:/java/jakarta-tomcat-4.0.1/webapps/myapplication/WEB-INF/Ldap
Framework.dtd

Application
...

But I want to register my DTD in Tomcat for the using of the following
XML header

?xml version=1.0 encoding=ISO-8859-1 ?
!DOCTYPE Application PUBLIC
  -//Uniway Belgium//DTD Application Configuration 1.0//EN
 http://www.uniway.be/application/dtds/application_1_0.dtd;
Application
...

How can I explain to Tomcat the mapping between this header and the real

place of the DTD in the War of Jar?

I don't know if it is the good mailing list but I can see that Tomcat
provides
this feature.

Benoit


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: How can I register a DTD in a war

2002-02-20 Thread Benoit Segaert

Thanks Jan,

But I would like to avoid the server name http://127.0.0.1: or any
access to a specific server.

When I use Struts in my application, I have the following config file
?xml version=1.0 encoding=ISO-8859-1 ?

!DOCTYPE struts-config PUBLIC
  -//Apache Software Foundation//DTD Struts Configuration 1.0//EN
  http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;
struts-config

If I see the Tomcat log I can see:

register('-//Apache Software Foundation//DTD Struts Configuration 1.0//EN',
'jar:file:C:/java/jakarta-tomcat-4.0.1/webapps/strutsjndi/WEB-INF/lib/struts.jar!/org

/apache/struts/resources/struts-config_1_0.dtd'

You can see the struts.jar contains the dtd but in the xml file the
reference is the
following:
http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;

I want to reproduce this configuration.
Can you help me?

Benoit


Jan Søgaard wrote:

 Hi Benoit

 Remember that the resources under /WEB-INF/ is not directly accessible
 for the end user.
 If you place your DTD in a directory TOMCAT_HOME/webapps/myApplication/
 You will have directly access to it, from other applications, accessing
 the DTD through tomcat.

 e.g..

 I have a dtd placed in TOMCAT_HOME/webapps/myapp/my.dtd
 the receiving XML have the following header:

 ?xml version=1.0 encoding=ISO-8859-1?
 !DOCTYPE message SYSTEM http://127.0.0.1:8090/myapp/my.dtd;

 And my Servlet is able to validate the document according to this DTD.

 So, in short, I don't think you need to register your dtd, just placed
 it, in a directory outside the WEB-INF.
 Then every application can access it, through the URL, not the fully
 qualified path.

 If this is not, what you questioned, please explain your problem, and I
 will try to help

 Jan

 -Original Message-
 From: Benoit Segaert [mailto:[EMAIL PROTECTED]]
 Sent: 20. februar 2002 10:39
 To: [EMAIL PROTECTED]
 Subject: How can I register a DTD in a war

 I want to validate a XML with a DTD in a War application.
 I have my DTD available in the war file.

 I use a XML file like the following:

 ?xml version=1.0 encoding=ISO-8859-1 ?
 !DOCTYPE Application SYSTEM

 file:///C:/java/jakarta-tomcat-4.0.1/webapps/myapplication/WEB-INF/Ldap
 Framework.dtd

 Application
 ...

 But I want to register my DTD in Tomcat for the using of the following
 XML header

 ?xml version=1.0 encoding=ISO-8859-1 ?
 !DOCTYPE Application PUBLIC
   -//Uniway Belgium//DTD Application Configuration 1.0//EN
  http://www.uniway.be/application/dtds/application_1_0.dtd;
 Application
 ...

 How can I explain to Tomcat the mapping between this header and the real

 place of the DTD in the War of Jar?

 I don't know if it is the good mailing list but I can see that Tomcat
 provides
 this feature.

 Benoit

 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]

 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: How can I register a DTD in a war

2002-02-20 Thread Craig R. McClanahan



On Wed, 20 Feb 2002, Benoit Segaert wrote:

 Date: Wed, 20 Feb 2002 11:35:31 +0100
 From: Benoit Segaert [EMAIL PROTECTED]
 Reply-To: Tomcat Users List [EMAIL PROTECTED]
 To: Tomcat Users List [EMAIL PROTECTED]
 Subject: Re: How can I register a DTD in a war

 Thanks Jan,

 But I would like to avoid the server name http://127.0.0.1: or any
 access to a specific server.

 When I use Struts in my application, I have the following config file
 ?xml version=1.0 encoding=ISO-8859-1 ?

 !DOCTYPE struts-config PUBLIC
   -//Apache Software Foundation//DTD Struts Configuration 1.0//EN
   http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;
 struts-config

 If I see the Tomcat log I can see:

 register('-//Apache Software Foundation//DTD Struts Configuration 1.0//EN',
 'jar:file:C:/java/jakarta-tomcat-4.0.1/webapps/strutsjndi/WEB-INF/lib/struts.jar!/org

 /apache/struts/resources/struts-config_1_0.dtd'

 You can see the struts.jar contains the dtd but in the xml file the
 reference is the
 following:
 http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;

 I want to reproduce this configuration.
 Can you help me?


You could look at how Struts does this (via the Digester package from
Jakarta Commons):

  http://jakarta.apache.org/commons/digester.html

Basically, Digester does a SAX parse of the XML document.  In the SAX
APIs, you can define your own EntityHandler, where the resolveEntity()
method will be called by the parser when the DOCTYPE is encountered.  I
just keep an internal registration table that says, whenever you see the
following public identifier, use *this* URL for the system identifier
instead of the one in the document.

Details are in the Digester source code, which is accessible via the link
above.

By the way, Tomcat uses the same trick to reference an internal copy of
the DTD for your web.xml and TLD files - that's why you can run Tomcat on
a machine disconnected from the Internet.

 Benoit


Craig


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]