Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6213971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:47:38+00:00 2026-05-24T06:47:38+00:00

When I reference to a DTD file in my code, I don’t know how

  • 0

When I reference to a DTD file in my code, I don’t know how to reference to it within my project’s folder. e.g : If my project’s name is Moo, I’d want to refernce the DTD at /Moo/WEB-INF/courses.dtd.

TransformerFactory transfac = TransformerFactory.newInstance();
Transformer trans = null;  

try { trans = transfac.newTransformer();   }
catch (TransformerConfigurationException e) { }

trans.setOutputProperty(OutputKeys.INDENT, "yes");  
trans.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "/Moo/WEB-INF/courses.dtd");

But it doesn’t find it. How can I reference it?

I was offered a solution using getRealPath problem is since my project will be read as a .war file this is not good. What should I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:47:39+00:00Added an answer on May 24, 2026 at 6:47 am

    First of all, do not include “Moo”. For servlet root is one level up from WEB-INF.
    Not sure that OutputKeys.DOCTYPE_SYSTEM wants relative path. Absolute path is:

    String path = getServletContext().getRealPath("/WEB-INF/courses.dtd");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can an XML file reference two DTDs? Can a DTD reference elements from another
Creating an XPathDocument with referenced DTD sometimes throws a web exception. Why?
I reference another eclipse project from the current project I am working on. Everything
For reference, the code is for the motorola 68008. Say I have code such
I've made a new project with one page and a reference to AjaxControlToolkit.dll The
I am trying to reference a JavaScript file, containing a table sort function, in
I am having the following code to Save message to Exchange WEBDAV Drafts folder.
I was trying to store the Google Analytics code in a single file that
I am processing an XML file (which does not contain any dtd or ent
While using xmlstarlet on web pages, I most of time faced entity reference error.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.