[jdom-interest] DocType Modification

Kevin Baynes kbaynes at seagullsw.com
Tue Jun 12 12:25:21 PDT 2001


Ted-

Now, I see a difference: I am not creating the files with JDOM. I am opening
existing files and modifying them.

I am starting with XML files already in my web app that have some basic
configuration information in them. Then I create JDOM Documents from the
files, do something, and output them back to the server. So, I never create
a document in the way you show below using the JDOM DocType object.

My xml file actually says:
<!DOCTYPE users SYSTEM "users.dtd">

After using JDOM to open and modify the contents, JDOM writes the doctype
as:
<!DOCTYPE users SYSTEM
"file:/C:/jakarta-tomcat-4.0-b1/webapps/kalispell/data/users.dtd">

How do I preserve the original doctype so that my web app stays portable?

Once the XML file has that full path doctype, if I move the web app, my
servlets get a JDOM error because JDOM can't find the DTD as specified in
the XML file.

:-)

-Kevin

> -----Original Message-----
> From: Ted Erickson [mailto:ted at longhairtech.com]
> Sent: Tuesday, June 12, 2001 8:52 AM
> To: 'Kevin Baynes'
> Subject: RE: [jdom-interest] DocType Modification
>
>
> Weird.
>
> This is the scenario I use to create and write out XML:
>   Element root = <method creates element>
>   DocType docType = new DocType(root.getName(), "../CBA.dtd");
>   Document doc = new Document(root, docType);
>   File fp = <method creates or overwrites file>;
>   FileOutputStream out = new FileOutputStream(fp);
>   XMLOutputter outputter = new XMLOutputter();
>
>   outputter.output(doc, out);
>   out.flush();
>   out.close();
>
> The only suggestion I can make is check XMLOutputter.printDocType(DocType
> docType, Writer out).
> The method writes out the docType.getSystemID() which is set by either:
>    DocType(String elementName, String systemID)
>    DocType.setSystemID(String systemID)
>
> Sorry I do not have the solution, all I can provide is possible clues.
>
> Good luck,
>
> Ted
> -----Original Message-----
> From: Kevin Baynes [mailto:kbaynes at seagullsw.com]
> Sent: Tuesday, June 12, 2001 12:33 PM
> To: ted at longhairtech.com
> Cc: Jdom-Interest
> Subject: RE: [jdom-interest] DocType Modification
>
>
> Ted-
>
> Thanks for the response. :-)  Still not there yet, though.
>
> I tried:
>
> <!DOCTYPE groups SYSTEM "./groups.dtd">
> and
> <!DOCTYPE groups SYSTEM "../data/groups.dtd">
>
> and (respectively) got back:
>
> <!DOCTYPE groups SYSTEM
> "file:/C:/jakarta-tomcat-4.0-b1/webapps/kalispell/data/./groups.dtd">
> and
> <!DOCTYPE groups SYSTEM
> "file:/C:/jakarta-tomcat-4.0-b1/webapps/kalispell/data/../data/gro
ups.dtd">

-Kevin

> -----Original Message-----
> From: Ted Erickson [mailto:ted at longhairtech.com]
> Sent: Tuesday, June 12, 2001 8:20 AM
> To: 'Kevin Baynes'
> Subject: RE: [jdom-interest] DocType Modification
>
>
> Use a relative path.  What we do is use:
> <!DOCTYPE GENERIC SYSTEM "../CBA.dtd">
>
> In your case I would suggest:
> <!DOCTYPE users SYSTEM "/users.dtd">
>
> And yes, we are using Tomcat in production.
>
> Ted Erickson
>
> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]On Behalf Of Kevin Baynes
> Sent: Tuesday, June 12, 2001 12:10 PM
> To: Jdom-Interest
> Subject: [jdom-interest] DocType Modification
>
>
> I have an XML document with the following doctype declaration:
>
> <!DOCTYPE users SYSTEM "users.dtd">
>
> After using JDOM to open and modify the contents, JDOM writes the doctype
> as:
>
> <!DOCTYPE users SYSTEM
> "file:/C:/jakarta-tomcat-4.0-b1/webapps/kalispell/data/users.dtd">
>
> Why does this happen?
> Is my usage incorrect?
> Is there a way to prevent this?
>
> thanks!
>
> --------------------
> Kevin Baynes
> Software Engineer
> kbaynes at seagullsw.com
> 703-393-2191
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yourad
dr at yourhos
t.com




More information about the jdom-interest mailing list