Posted 20 years ago by byperman - Sint-Niklaas, Belgium
Avatar
Hi,

I tried to extend the xml language description included with the C#-sample, to be able to recognize short tags.
<States>
        <!-- Text -->
        <State Key="DefaultState">
            <!-- Patterns Groups -->
            <PatternGroups>
                <!-- Entities -->
                <RegexPatternGroup Token="EntityToken" Style="EntityStyle" PatternValue="& {WordMacro}+ ;?" />
                <!-- Identifier -->
                <RegexPatternGroup Token="IdentifierToken" PatternValue="{AlphaMacro}({WordMacro})*" />
                <!-- Whitespace -->
                <RegexPatternGroup Token="WhitespaceToken" PatternValue="{WhitespaceMacro}+" IsWhitespace="True" />
            </PatternGroups>
            <!-- Child States -->
            <ChildStates>
                <ChildState Key="EndTagState" />
                <ChildState Key="CommentState" />
                <ChildState Key="CDATAState" />
                <ChildState Key="DeclarationState" />
                <ChildState Key="ProcessingInstructionState" />
                <ChildState Key="StartTagState" />
                <ChildState Key="ShortEndTagState" />
            </ChildStates>
        </State>
        
        <State Key="ShortEndTagState" Token="ShortEndTagDefaultToken" Style="TagNameStyle">
            <Scopes>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" Token="ShortEndTagStartToken" Style="TagDelimiterStyle" PatternValue="<" />
                    <ExplicitPatternGroup Type="EndScope" Token="ShortEndTagEndToken" Style="TagDelimiterStyle" PatternValue="/>" />
                </Scope>
            </Scopes>
            <ChildStates>
                <ChildState Key="StartTagAttributeState" />
            </ChildStates>
        </State>
        
        <!-- Start Tags -->
        <State Key="StartTagState" Token="StartTagDefaultToken" Style="TagNameStyle">
            <!-- Scopes -->
            <Scopes>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" Token="StartTagStartToken" Style="TagDelimiterStyle" PatternValue="<" />
                    <RegexPatternGroup Type="EndScope" Token="StartTagEndToken" Style="TagDelimiterStyle" PatternValue="[^/]>" />    
                </Scope>
            </Scopes>
            <!-- Child States -->
            <ChildStates>
                <ChildState Key="StartTagAttributeState" />
            </ChildStates>
        </State>

(...)
Unfortunately, this doesn't seem to work.

What am i doing wrong?
Thanks in advance.

Comments (1)

Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
That's tricky to do and probably will use more processing time. But to do it you'd probably have to first put the child state for short tags before the one for normal ones in the child states list.

Then in the start scope for short tags, you'll need to do a lookahead that has any number of non-">" characters followed by a "/>". That might do the trick but again, it will slow things down since the lookahead will be performed on every tag.

We are eventually going to work on an XML tag-specific semantic parser to help identify those from block tags but right now there are some other projects that are ahead of that.


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.