Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 106101

Summary: XML editor does not support ANT scripts
Product: [WebTools] WTP Source Editing Reporter: Michael Giroux <michael.giroux>
Component: wst.xmlAssignee: David Williams <david_williams>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P2 CC: analogue, d_a_carver, for.work.things, marc.adams
Version: 0.7   
Target Milestone: 1.5.3 M153   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Michael Giroux CLA 2005-08-04 17:19:01 EDT
I have an ANT script named componentgenerator.xml.  I opened the file 
with XML editor, and there was no color coding, and the design view does not 
show any elements.  The design view reports that "the document is empty."

Digging into this a little further, I created a new file and name it
somethng.xml.  Then enter the following three lines in source view.

<?xml version="1.0" encoding="UTF-8"?>
<project name="ComponentGenerator" default="buildall" basedir=".">
</project>

I switched to design view and the elements are displayed.

I close the file, and then right click the file in project explorer and 
notice that file is associated w/ ANT editor.

I open with XML editor, and design view shows that the document is empty, 
and source view does not have color coding.

It appears that once a file is associated w/ ANT editor, the XML editor no 
longer recognizes it.
Comment 1 Marc Adams CLA 2006-03-30 19:55:58 EST
It appears that the ant editor recognizes the build file markup and associated
itself with that file. I created an XML file named NewFile.xml and added the
project element referenced in the original bug report. It opened the file in
the ant editor as the bug states. When I opened it with the XML editor, I got a
dialog saying that the content type of the file isn't associated with the XML
editor but it could be defined in the content type preferences. 

I would think this is a "works as designed" as the Ant editor is standard to
the eclipse platform - I can't think of an instance where you would have the
WTP XML editor but not the ant editor.

If there is a disagreement, and the consensus is that the XML editor should be
associated with build files, then I would be glad to take a look at it.
Comment 2 Michael Giroux CLA 2006-03-31 09:16:35 EST
The problem is this -- not all xml documents that contain a <project> root element are build files.  For example, I have an xml document that is describing a construction project:
<project name="Giroux" >
<description> BUILD A HOUSE </description>
<tasks>
  <task> get permit </task>
</tasks>
</project>

This file works as expected.

Now if you add a default="something" to the project root, 
  <project name="Giroux" default="something">
the ANT editor decides this is an ANT script with invalid content, and it is no longer possible to open with the XML editor.

I have even tried to qualify the element with an xmlns to prevent ANT editor from taking control:
  <project name="Giroux" default="something" xmlns="my.com">

It seems to me that given the flexability of XML, it is possible that some application will be able to define an xml document that happens to look like an ANT script.  All that is needed is a root named 'project' with a 'default' attribute.  This seems too aggressive to me.

I hope others will agree that it should always be possible to open a file with the XML editor regardless of whether the ANT editor has been associated or not.
Comment 3 David Williams CLA 2006-03-31 09:30:54 EST
Yes, we all agree and have debated this issue many times. Part of the problem is that the "ant lanuage" is really not recognizable in a very predictable way. That is, an ant file can contain almost anything. 

But, part of the problem is with the XML Editor. We need to provide our own (custom) FileDocumentProvider, which, I belive lies in our hands. 

After that, there may still be less that satisfactory behavior for some cases, that could be tweaked, but that FileDocumentProvider is needed first. 
Comment 4 David Carver CLA 2007-03-13 16:19:24 EDT
This seems to work in 1.5.3.  Can't duplicate error.
Comment 5 Michael Giroux CLA 2007-03-13 16:29:49 EDT
Verified.
I'm running WTP 1.5.3.  This bug appears to have been resolved.
Comment 6 Amy Wu CLA 2007-03-15 17:14:01 EDT
*** Bug 130977 has been marked as a duplicate of this bug. ***
Comment 7 Amy Wu CLA 2007-03-15 17:20:08 EDT
Reporter verified this is working in 1.5.3, so closing. (I'm resolving as invalid just because I'm not sure if we actually put in any code to fix this.  ANT may have fixed it on their end)
Comment 8 Amy Wu CLA 2007-03-15 17:20:32 EDT
closing.