XPath plugin idea: xpath-based structure view

Hey Sascha, I think it would be cool to be able to use xpath to define the
structure view for a given file type (based on schema or dtd). So I could say
for the root node, "this should say //site@name" and its children should be the
nodes found by xpath expression "element" and their text should be "(.@name):
(.@url)" and children should be result of xpath expression "inputs" and then
"outputs" and then "exits"

So instead of current structure view which looks like:

- site (name=Account)
- arrival (destid=home)
- element (file="blah/blah.xml", url="home", blah="Home")

It could be more like:
- Account
- Home (/home)

Do you understand what I mean? For most XML files I edit, structure view is
useless. This could make it cool again. What do you think of this?

1 comment

Keith, I totally agree that the Structure View for XML files really isn't of much use
normally. What you suggest is actually a transformation of your XML file to a "Structure
View DTD", i.e. a format that defines the appearance of a node and its children. Something
that would be typically accomplished by an XSLT transformation.

Unfortunately, using XSLT isn't really feasible because of the fact that it would have to
process the entire file each time a node has to be updated. As you already suggested, this
could be solved by something similar to the custom debugger type renderers: It needs the
ability to define if a renderer should be applied to an element, what the renderer should
display and (optionally) what the children of a node are.

The only real problem I see right now is that it doesn't seem possible to actually plug
that into the XML structure view. It's possible to extend it, but I don't see a way to get
rid of the nodes that it creates by default. I also don't see a way to completely replace
it for existing file types.

Though I like the idea, this is probably only reasonably possible when there are better
hooks for this. If there is another way though, I'd be curious to hear about it as it
seems to be a useful feature.

Sascha

0

Please sign in to leave a comment.