- This topic has 19 replies, 5 voices, and was last updated 18 years, 6 months ago by Riyad Kalla.
-
AuthorPosts
-
mikewseMember[Windows 2000, Java 1.4.2_07, Eclipse 3.1M4, MyEclipse 3.8.4]
I am getting error markers in the XML editor validation when I am not expecting it. I have the following standard Log4J file “log4j.xml” in one of my ME projects:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="console" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %-5p %c %x - %m%n"/> </layout> </appender> <root> <!-- all|debug|info|warn|error|fatal|off|null --> <priority value ="warn" /> <appender-ref ref="console" /> </root> </log4j:configuration>
I have setup the DTD in MyEclipse “XML Catalog” Preferences as
key: log4j.dtd
key type: System ID
URI: defslog4j/lib/log4j.dtd (path to a file in the workspace)When I open the file, the XML editor shows a red cross on the same line as the DOCTYPE, saying
File not found: "C:\<path to the directory where my log4j.xml is located>\log4j.dtd (The system cannot find the file specified)".
Note that it is trying to find the DTD file in the same directory as the XML file, despite the fact that I have told it to look in another place through the XML Catalog entry.
What is even more odd is that XML completion (based on the DTD) is working, so it seems one part of ME finds the DTD file, but another part doesn’t.
Riyad KallaMemberNote that it is trying to find the DTD file in the same directory as the XML file
Becase you are telling it to with the following line:
<!DOCTYPE log4j:configuration SYSTEM “log4j.dtd”>
despite the fact that I have told it to look in another place through the XML Catalog entry.
This is where your URI comes into play, it is used to lookup a matching URI (like a hastable lookup) in the XML catalog, notice how your URI is “defslog4j/lib/log4j.dtd”, and no where in your DOCTYPE do you mention that URI? So the XML editor says “Ok XML Catalog, give me back an entry for the key “defslog4j/lib/log4j.dtd” and the Catalog returns null, so the editor looks at the location of the dtd specified, “log4j.dtd” (in the current dir) and tries to load it”
I would suggest using as an example the default web.xml file from a new web project. Check out how the entry looks for the web_2_4.xsd file, and then check the XML catalog for the web_2_4.xsd entry and see how the URIs match/etc.
mikewseMember@support-rkalla wrote:
Note that it is trying to find the DTD file in the same directory as the XML file
Becase you are telling it to with the following line:
<!DOCTYPE log4j:configuration SYSTEM “log4j.dtd”>
I agree that this is the expected behaviour if ME’s XML Catalog cannot find any setting specifying another location for the DTD file. But the whole point of my post is ME’s way of locating SYSTEM uri:s in the XML Catalog. See below.
First, so you know, I’ll use this “ME translated” terminology:
public doctype declaration: DOCTYPE <name> PUBLIC "<doctype-key>" "<doctype-uri>" system doctype declaration: DOCTYPE <name> SYSTEM "<doctype-uri>" ME's XML Catalog: <catalog-key> + <catalog-key-type> -> <catalog-uri>
So, for example, using this terminology to explain your lookup of PUBLIC DTDs (which works fine) one would say that your XML Editor tries to match the <doctype-key> among your collection of <catalog-key> in the catalog. If a match is found, the XML Editor uses the corresponding <catalog-uri> for locating the DTD instead of using the file’s own <doctype-uri>.
This is where your URI comes into play, it is used to lookup a matching URI (like a hastable lookup) in the XML catalog, notice how your URI is “defslog4j/lib/log4j.dtd”, and no where in your DOCTYPE do you mention that URI?
What you are saying here is that you are trying to match my <doctype-uri> against the catalog’s <catalog-uri>. This sounds very strange as the whole point of the catalog is to provide an alternative uri instead of the one in the XML file.
Please be aware that SYSTEM DOCTYPEs do not have a <doctype-key> field. Therefore, as you provide a “SYSTEM ID” user entry alternative in the catalog, I expected you to try to match <doctype-uri> against <catalog-key> in the catalog, and for a match use the corresponding <catalog-uri> instead of <doctype-uri>.
If you want to provide the XML catalog functionality for SYSTEM DOCTYPEs there are not really any alternatives, right?And, as I stated in my original post, it seems like the code completion part of the XML editor actually locates the DTD the way I describe (as I get all the correct tags in the completion menu). But I still get the error message about the DTD not being found.
I should also explain why we do not want to enter machine specific paths in the XML file’s <doctype-uri>. It is because we are many people working on the same project and we may put the DTD file in different places within our individual development environments.
The file is only needed during development (for code completion etc) and thus we want the development environment to handle its location, without having to hard-code the location into the shared source code.
Scott AndersonParticipantI have setup the DTD in MyEclipse “XML Catalog” Preferences as
key: log4j.dtd
key type: System ID
URI: defslog4j/lib/log4j.dtd (path to a file in the workspace)When I open the file, the XML editor shows a red cross on the same line as the DOCTYPE, saying
Code:
File not found: “C:\<path to the directory where my log4j.xml is located>\log4j.dtd (The system cannot find the file specified)”.The issue is that with the URI you specified the file can’t be located. The URI is not workspace specific, but an absolute path to the resource so it should be:
file:/c:/<path-to-your-workspace>/defslog4j/lib/log4j.dtd
And the Key Type should be Public ID, and specified as PUBLIC in your XML file.
mikewseMember@support-scott wrote:
I have setup the DTD in MyEclipse “XML Catalog” Preferences as
key: log4j.dtd
key type: System ID
URI: defslog4j/lib/log4j.dtd (path to a file in the workspace)When I open the file, the XML editor shows a red cross on the same line as the DOCTYPE, saying
Code:
File not found: “C:\<path to the directory where my log4j.xml is located>\log4j.dtd (The system cannot find the file specified)”.The issue is that with the URI you specified the file can’t be located. The URI is not workspace specific,
That is not correct, the URI is actually workspace specific. In my post I specified what I entered in the User Entry dialog box (defslog4j/lib/log4j.dtd), but that path was actually put there by using the Browse button, browsing the workspace. And if I select the new entry and check its details, the URI is “platform:/resource/defslog4j/lib/log4j.dtd”
And the Key Type should be Public ID, and specified as PUBLIC in your XML file.
No, that is not correct. Log4J (this is an apache software, you know that right?) doesn’t have a public id so the DOCTYPE declaration shouldn’t be PUBLIC. This is not up to any of us to change if we want the file to be Log4J compatible.
Search the net and you will see that log4j.xml files *always* have the heading I indicated in my post.I have now also verified that ME *does* find my DTD according to the way I specified from the beginning. This is what I do:
1) I start out with no user entries in the catalog.
2) When I open my XML file I get a Progress message:
"loading C:\<path to my XML file's folder>\log4j.dtd"
As stated earlier there is no dtd file here and this is what the “red cross” in the editor also says. XML completion isn’t giving me anything from the DTD as expected.
3) I close the editor and enter a user entry like the one I described in my first post.
4) When I open the XML file again I get a Progress message:
"loading C:\<path to my Eclipse workspace>\defslog4\lib\log4j.dtd"
This is the place where my DTD actually resides, and XML completion is now giving me everything in the DTD. Though, I still have the red cross complaining about not finding the DTD.
Riyad KallaMemberOk Mike,
Here is a workaround for the current problem (we have filed the issues encountered during this investigation and will look at fixing them soon, likely after 3.9 since our 3.9 plate is fuller than full).1) Change your log4j.dtd to a PUBLIC type and not a SYSTEM type, like this:
URI: file:/C:\Java\eclipse-3.0.1\workspace\TestLog4JDTD\log4j.dtd
Key Type: Public ID
Key: log4j.dtd2) And change your URI to the absolutely path to the DTD file (see above snippet) (**NOTE I have filed the problem of the browse button giving relative paths).
3) In your XML file, change the DOCTYPE to look like this:
<!DOCTYPE log4j:configuration PUBLIC “log4j.dtd” “random_uri”>
And then save/revalidate the file. Note that “random_uri” can be whatever you want, even empty, but it does need to be there.
ALSO note this is the current workaround for the bug(s) in ME, I know this isn’t how it should work (or what you might want to do) and we will look into fixing that. We appologize for the inconvenience but appreciate your extremely detailed help in figuring out what is going on here.
mikewseMember(**NOTE I have filed the problem of the browse button giving relative paths).
I actually think it is a good thing that a workspace relative path is possible to enter here, as the catalog settings will be valid after moving the workspace to another folder (for files inside the workspace of course).
I think both absolute and relative paths should be possible.We appologize for the inconvenience but appreciate your extremely detailed help in figuring out what is going on here.
I’m glad that you’ve found the problem I was decribing. Yes, it did take some time to put together my posts. I actually mentioned this problem once before (http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-4900.html) but couldn’t put in enough effort at the time to get you on the hook 😉
ealfarotxMemberNeither tomcat 5.28 or WL 8.1 SP3 like the “random_uri” and throw exceptions so I have opted to just place the log4j.dtd in the same dir as the log4j.xml with no changes needed to the xml as SYSTEM “log4j.dtd” finds the dtd in the same dir and everyone is happy.
<!DOCTYPE log4j:configuration PUBLIC “log4j.dtd” “random_uri”>
mikewseMemberThis bug has still not been fixed (Windows/4.0.3) so maybe it’s about time to have a look at it again?
In short, as I pointed out earlier, the problem is when defining an XML Catalog entry for a System ID (“log4j.dtd” in my scenario) to point it to the desired path.
The XML editor loads the DTD file from the correct place, and also offers content-assist based on it, but still displays a red cross at the DOCTYPE complaining about not finding the DTD. Clearly a mismatch among different modules in the MyEclipse codebase.From my previous post:
@mikewse wrote:
I have now also verified that ME *does* find my DTD according to the way I specified from the beginning. This is what I do:
1) I start out with no user entries in the catalog.
2) When I open my XML file I get a Progress message:
"loading C:\<path to my XML file's folder>\log4j.dtd"
As stated earlier there is no dtd file here and this is what the “red cross” in the editor also says. XML completion isn’t giving me anything from the DTD as expected.
3) I close the editor and enter a user entry like the one I described in my first post.
4) When I open the XML file again I get a Progress message:
"loading C:\<path to my Eclipse workspace>\defslog4\lib\log4j.dtd"
This is the place where my DTD actually resides, and XML completion is now giving me everything in the DTD. Though, I still have the red cross complaining about not finding the DTD.
Riyad KallaMemberMike,
I did a poor job of diagnosing this problem the first time through, after going back through it again with your steps and examples we were able to nail down the issue quite quickly, let me thank you for the detailed submissions.We are going to try and target this bug to get fixed in 4.1, we appologize for the long delay on this.
mikewseMember@support-rkalla wrote:
We are going to try and target this bug to get fixed in 4.1, we appologize for the long delay on this.
It seems this bug was not fixed in 4.1. Do you have a new date?
Riyad KallaMemberI just looked it up and it was targetted for 4.1.1. I pinged the developers on this asking if it can make it into 4.1.1 as everything we do is priority based and sometimes really annoying bugs for a single user get lost under the trample of high priority requests or bugs from a large group of people.
Sorry for the delay, Mike.
mikewseMemberNo worries, Riyad. Of course you must do the right prioritizations.
Though, I would be happy to not having those red crosses in Eclipse staring at me every day 😉
What is the easiest way for me to check when the bug will be fixed so I don’t have to nag you here in the forum on every release? Do you have a public link to the bug in your tracking system?
Riyad KallaMemberWhat is the easiest way for me to check when the bug will be fixed so I don’t have to nag you here in the forum on every release? Do you have a public link to the bug in your tracking system?
Not a public system because we track other business issues in it as well, so nagging me is the right thing to do for now.
dlreadMemberIt looks like this issue is still not fixed in 4.1.1.
I’m very fond of MyEclipse but it is annoying to have error indicators on valid XML source.
Do you have any work-arounds that don’t involve changing the XML source?
Any chance of a 4.1.2 release to address this problem?
-
AuthorPosts