Posted 20 years ago by Jan van de Pol
Avatar
I have overridden GetTokenOutliningAction in order to enable expanding and collapsing for XML nodes. My method looks as follows:

protected override void GetTokenOutliningAction(TokenStream tokenStream, ref string outliningKey, ref OutliningNodeAction tokenAction) {
// Get the token
Token token = tokenStream.Peek();
string languageTokenKey = token.Language.Key + "_" + token.Key;

// See if the token starts or ends an outlining node
switch (languageTokenKey) {
case "XML_StartTagEndToken":
outliningKey = "XML_Block";
tokenAction = OutliningNodeAction.Start;
break;
case "XML_EndTagStartToken":
outliningKey = "XML_Block";
tokenAction = OutliningNodeAction.End;
break;
}
}

I use the provided XML language definition. The collapse will result in something like:
<MyNode...MyNode>. I'm trying to get something like:
<MyNode myAttribut='MyValue'>...</MyNode>

Anyone knowing how to achieve this?

Comments (1)

Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Right now I'm not sure if you can reliably do XML tag outlining using SemanticDefaultParser. We need to create a different parser implementation than the SemanticDefaultParser that will be specifically for XML. SemanticDefaultParser is really only for "coding" language outlining.

Now we did implement SCRIPT tag collapsing for HTML using it but that really only works because there is a language transition. Without getting too much into technical details, language transition outlining nodes are handled slightly differently than regular nodes. Language transitions will only collapse the inner content (like what you want) but normal nodes will collapse the delimiters as well (like C# {...}).

The point is that language transitions are the only way right now to get that collapsing the way you want but you can't do language transitions in XML because that wouldn't make sense. So we essentially need to write a semantic parser that works for XML outlining which you can use instead of inheriting from SemanticDefaultParser.

As another note, a "true" XML outlining parser will need to account for single tags like <notblocktag/>. It also should match tag names appropriately.

[ 06-01-2004: Message edited by: Actipro Software Support ]


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.