Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » "Map" containing present elements?(Does it exist?)
"Map" containing present elements? [message #723057] Wed, 07 September 2011 14:17 Go to next message
MarcoGT  is currently offline MarcoGT Friend
Messages: 77
Registered: May 2011
Member
Hi,

inside AbstractModelQueryCompletionProposalComputer class the method addAttributeValueProposal has a map containing all the inserted attributes.

At the moment I am working on addEntityProposals(ContentAssist, ITextRegion, CompletionProposalInvocationContext)

Let's suppose I have something similar:

<family>
 <mother>Lisa</mother>
 <father>Bob</father>


Now I call content assist and for example I get proposal for <daughter>...ok...is there a way to know that <mother> and <father> have been already inserted?

Thanks
Marco
Re: "Map" containing present elements? [message #723534 is a reply to message #723057] Thu, 08 September 2011 18:36 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

No, you'll have to get the list of child nodes from the parent. The ordering can matter, so a Map will not give you enough information.

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: "Map" containing present elements? [message #724442 is a reply to message #723057] Mon, 12 September 2011 11:29 Go to previous messageGo to next message
MarcoGT  is currently offline MarcoGT Friend
Messages: 77
Registered: May 2011
Member
Ok, thank you.

I have something similar:

<family>
 <mother>Lisa</mother>
 <father></father>
</family>


Let's suppose cursor is between "father" tag and content assist is called.

At the moment I am working on addEntityProposals method.
I have access to ContentAssistRequest

ContentAssistRequest.getParent() gives me back "father"

I should use ContentAssistRequest.getParent().getParent() and I get "family", then using getChildNodes() I get a NodeList containing all the children nodes (mother and father in my case)...but how do I get their content?

If I print out every child node I get:
#text
mother
#text
father

Why?

Re: "Map" containing present elements? [message #724457 is a reply to message #724442] Mon, 12 September 2011 12:04 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

If the cursor is between the father start and end tags, father is supposed to be the parent of what you insert.

Getting their content requires using the DOM API from org.w3c.dom.Node and its subinterfaces; #toString() has no such requirement.

Those are Text nodes in the DOM representing white space not contained under the "mother" and "father" Elements. There should be one trailing "father" as well.


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: "Map" containing present elements? [message #724797 is a reply to message #724457] Tue, 13 September 2011 07:50 Go to previous messageGo to next message
MarcoGT  is currently offline MarcoGT Friend
Messages: 77
Registered: May 2011
Member
Ok, I got, thanks.

Another question:

if I have
<Book title="aaa" author="bbb" price="12" year="2011" />


I can use an XPath expression to see if some conditions are verified, for example:
local-name(.) = 'Book' and @title

If the result of XPath expression execution is true...do something, otherwise do something else.
In this case I built an expression directly on a Node, and that's ok.

In the case of NodeList, how can I do the same task?
I would like to see if NodeList has some nodes, for example, but using an XPath expression.

Thanks
Re: "Map" containing present elements? [message #724804 is a reply to message #724457] Tue, 13 September 2011 08:31 Go to previous message
MarcoGT  is currently offline MarcoGT Friend
Messages: 77
Registered: May 2011
Member
Nitin Dahyabhai wrote on Mon, 12 September 2011 08:04
If the cursor is between the father start and end tags, father is supposed to be the parent of what you insert.

Getting their content requires using the DOM API from org.w3c.dom.Node and its subinterfaces; #toString() has no such requirement.

Those are Text nodes in the DOM representing white space not contained under the "mother" and "father" Elements. There should be one trailing "father" as well.


Yes, ok, but I can not understand why in my NodeList I also get, as children elements, #text elements...

I mean...I get why I have in the NodeList...but is it possible to have only tag name inside NodeList?

For example only "father" and "mother"...nothing else, I do not want #text or #comment

[Updated on: Tue, 13 September 2011 08:57]

Report message to a moderator

Previous Topic:Modern Source Editor Tutorial
Next Topic:Eclipse
Goto Forum:
  


Current Time: Tue Apr 23 11:05:03 GMT 2024

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

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

Back to the top