This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 124155 - XPath construction in the XML editor
Summary: XPath construction in the XML editor
Status: NEW
Alias: None
Product: xml
Classification: Unclassified
Component: Text-Edit (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker with 1 vote (vote)
Assignee: Samaresh Panda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-17 19:09 UTC by fkieviet
Modified: 2009-01-09 20:02 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fkieviet 2007-12-17 19:09:57 UTC
Proposed feature: in the XML editor, enable the user to automatically construct an XPath expression to an element or
attribute. This could work by adding an item to the right click menu on the editor. When selecting this item, it will
generate an XPath expression and place it on the clipboard.
Comment 1 tk_fhd_aui 2009-01-07 13:54:33 UTC
Do you have an implementation suggestion for it?
I also thought about it but there is an indefinite number of possible XPathes which would match on the same element/
attribute.
Example:
<root>
 <element1 />
 <element2 /> <!--- this is assumed to be the selected one -->
 <element2 />
</root>

Some possibilities:
/root/*[2]
/root/element2[1]
//element2[1]
Comment 2 fkieviet 2009-01-09 19:48:32 UTC
Indeed, there are multiple expressions leading to the same result. I think the most restrictive expression would be
best. In your example, it would be /root/element2[1]. If schema information can be used: if the multiplicity of element2
is 1, the [1] can be dropped. If no schema info can be used, the absence of a duplicate element2 can be used to drop the
[1] index.

I don't expect the expression generator to be perfect, but it'll likely be good enough in 90% of the cases.
Comment 3 Samaresh Panda 2009-01-09 20:02:28 UTC
Not sure who is spanda. Assigned to myself.