Skip to main content



      Home
Home » Language IDEs » ServerTools (WTP) » "Map" containing present elements?(Does it exist?)
"Map" containing present elements? [message #723057] Wed, 07 September 2011 10:17 Go to next message
Eclipse UserFriend
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 14:36 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: "Map" containing present elements? [message #724442 is a reply to message #723057] Mon, 12 September 2011 07:29 Go to previous messageGo to next message
Eclipse UserFriend
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 08:04 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: "Map" containing present elements? [message #724797 is a reply to message #724457] Tue, 13 September 2011 03:50 Go to previous messageGo to next message
Eclipse UserFriend
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 04:31 Go to previous message
Eclipse UserFriend
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 04:57] by Moderator

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


Current Time: Sat Jul 12 07:41:44 EDT 2025

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

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

Back to the top