1

In Eclipse struts.xml content assist is not working with even included DTD in XML. but seems like am missing something here. I have all required jars in lib and build path as well.

struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
.....
Roman C
  • 49,761
  • 33
  • 66
  • 176
san544
  • 72
  • 10

2 Answers2

0

You can use XML file associations with DTD.

When an XML file is associated with a DTD, it is bound by any structural rules contained in the DTD. To be considered a valid XML file, a document must be accompanied by a DTD, and conform to all of the declarations in the DTD.

You can use XML schema instead of DTD to make an association with XML document but no XML schema provided.

There are two different ways to associate XML files with DTDs or XML schemas.

  • Direct association - The XML file contains either the name of a DTD in its doctype declaration (for example, , where dtdfile.dtd is the name of the DTD file) or it contains the path of an XML schema in the schemaLocation attribute of the XML file root element (for example, , where schema.xsd is the name of the XML schema.
  • XML Catalog entry - You can register DTD and XML schema files in the XML Catalog and associate them with a Key that represents them. You can then refer to a DTD or XML schema file Key from an XML file instead of referring directly to the DTD or XML schema file. An XML Catalog entry contains two parts - the Key (which represents the DTD or XML schema) and a URI (which contains information about the DTD or XML schema location).

Editing the XML Catalog Settings

The XML Catalog can be accessed via the Eclipse preferences:

  1. Select Window -> Preferences to launch the Preferences dialog.
  2. In the navigation tree expand the Web and XML group and select XML Catalog.

The picture below shows how to change settings

enter image description here


References:

Roman C
  • 49,761
  • 33
  • 66
  • 176
0

I found the solution for my content assist dtd issue,

I have extracted struts-2.0-dtd from struts2-core-2.0.1.jar and created a folder as dtds in WEB-INF and placed above extracted dtd in dtds folder.In struts.xml i changed dtd location as

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
    "/WEB-INF/dtds/struts-2.0.dtd">

It is working now.. am able to see the content assist for my struts.xml

san544
  • 72
  • 10