Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » DOM of editing file(Is it accessible?)
DOM of editing file [message #710853] Fri, 05 August 2011 13:31 Go to next message
MarcoGT  is currently offline MarcoGT Friend
Messages: 77
Registered: May 2011
Member
Hi all,

I am extending XML Editor of Eclipse.

Is it possible to access to DOM of the XML file opened inside the editor?
How?

Thanks
Marco
Re: DOM of editing file [message #710996 is a reply to message #710853] Fri, 05 August 2011 16:59 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4434
Registered: July 2009
Senior Member

On 8/5/2011 9:31 AM, MarcoGT wrote:
> Hi all,
>
> I am extending XML Editor of Eclipse.
>
> Is it possible to access to DOM of the XML file opened inside the editor?
> How?

That depends on what you mean by extending the XML Editor. What do you
mean?

--
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: DOM of editing file [message #711000 is a reply to message #710996] Fri, 05 August 2011 17:12 Go to previous messageGo to next message
MarcoGT  is currently offline MarcoGT Friend
Messages: 77
Registered: May 2011
Member
I am extending the content assist as I said in other posts.
I am working on org.eclipse.wst.xml.ui plugin and everything works fine.

I would like, if possible, get the DOM of the XML file opened inside the editor.

Thanks
Marco

[Updated on: Fri, 05 August 2011 17:19]

Report message to a moderator

Re: DOM of editing file [message #711027 is a reply to message #711000] Fri, 05 August 2011 17:36 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4434
Registered: July 2009
Senior Member

On 8/5/2011 1:12 PM, MarcoGT wrote:
> I am extended the content assist as I said in other posts.
> I am working on org.eclipse.wst.xml.ui plugin and everything works fine.

So where from, exactly, are you trying to get the DOM, from the editor
class, or somewhere else?

Also, if you're changing org.eclipse.wst.xml.ui itself, the license may
place additional requirements on you, i.e.
http://www.eclipse.org/legal/eplfaq.php#MODDIST .

--
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: DOM of editing file [message #711030 is a reply to message #711027] Fri, 05 August 2011 17:47 Go to previous messageGo to next message
MarcoGT  is currently offline MarcoGT Friend
Messages: 77
Registered: May 2011
Member
At the moment I am working on AbstractXMLModelQueryCompletionProposalComputer.

And, about license, I do not distribute the code to any others people, I will keep it only for me.

Quote:

19) If I modify a Program licensed under the EPL, but never distribute it to anyone else, do I have to make my modifications available to others?
No. If you do not distribute the modified Program, you do not have to make your modifications available to others.


Thanks
Marco

[Updated on: Fri, 05 August 2011 17:50]

Report message to a moderator

Re: DOM of editing file [message #711167 is a reply to message #711030] Fri, 05 August 2011 21:07 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4434
Registered: July 2009
Senior Member

Assuming you're in one of the methods with a ContentAssistRequest object passed in as an argument, the node and parent node in that object are part of the DOM model already. Otherwise it's really a question of what objects you have on-hand to work from.

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: DOM of editing file [message #711448 is a reply to message #711167] Sat, 06 August 2011 06:22 Go to previous messageGo to next message
MarcoGT  is currently offline MarcoGT Friend
Messages: 77
Registered: May 2011
Member
At the moment I am working in addAttributeValueProposal to add proposal for attribute values.
Here so I have access to DOM in particular I have the current node, right?

But is there a way to have the DOM of the whole document?

Thanks
Marco
Re: DOM of editing file [message #713106 is a reply to message #711448] Mon, 08 August 2011 05:15 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4434
Registered: July 2009
Senior Member

You seem to be using DOM in a generic sense while I'm using it to refer to the org.w3c.dom.* interfaces which we mostly implement, and those have clear means for getting the object that represents the entire document. Or do I misunderstand?

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: DOM of editing file [message #713114 is a reply to message #713106] Mon, 08 August 2011 05:23 Go to previous messageGo to next message
MarcoGT  is currently offline MarcoGT Friend
Messages: 77
Registered: May 2011
Member
No no, like you, I mean to referring to org.w3c.dom Smile

I saw that for example, in addAttributeValueProposal an object org.w3c.dom.Node, is it right?
So at ervery call to the content assist I have an object containing that particular node, is it right?

Thanks a lot
Marco
Re: DOM of editing file [message #713814 is a reply to message #710853] Tue, 09 August 2011 06:18 Go to previous messageGo to next message
MarcoGT  is currently offline MarcoGT Friend
Messages: 77
Registered: May 2011
Member
Is it possible to build an XPath query on the current node?
I am trying to do that but probably I did errors somewhere; I am in "addAttributeValueProposals" and I have the "node" variable (org.w3c.node) which contains the current node.

If I do

XPath xpath = XPathFactory.newInstance().newXPath();
XPathExpression xPathTest = null;
NodeList o = null;

try {
    xPathTest = xpath.compile("//@*");
    o = (NodeList) xPathTest.evaluate(node, XPathConstants.NODESET);
} catch (XPathExpressionException e1) {
  e1.printStackTrace();
}
			
System.out.println(o.getLength() + " length");	


I obtain the number of ALL attributes inside the node and not inside the current node, where I am wrong?
Re: DOM of editing file [message #713833 is a reply to message #713814] Tue, 09 August 2011 07:03 Go to previous message
MarcoGT  is currently offline MarcoGT Friend
Messages: 77
Registered: May 2011
Member
Ok, the error was inside the XPath expression:

from
xPathTest = xpath.compile("//@*");


to
xPathTest = xpath.compile("./@*");


Now it works.
Previous Topic:Problem in generated server.xml preventing web-app from reading files
Next Topic:associate a project with server
Goto Forum:
  


Current Time: Fri Apr 19 14:21:22 GMT 2024

Powered by FUDForum. Page generated in 0.02690 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top