Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

How to provide Intellisense for custom attributes
xomega
#1 Posted : Friday, November 9, 2012 6:40:52 PM(UTC)
xomega



If you have extended the Xomega model via additional configurations, or by enhancing the Xomega schema or even creating your own schema, the Xomega Editor allows you to easily add Intellisense support to your model elements, which provide automatic suggestions and auto-complete functionality when entering the model data.

The custom Intellisense behavior is driven by a dedicated XSL style sheet intellisense.xsl, which comes with the Xomega.Net and is located with other style sheets in the XSL folder of the Xomega installation. Remember, that this style sheet is using the XSLT 1.0, since it is run by the internal XSLT engine built in .Net, and therefore is fairly limited as compared to the XSL scripts used by the generators, which use XSLT 2.0.

The following steps outline the process for adding intellisense support to your custom attributes. Note, that this process requires that you install the Full Edition of Xomega.Net and obtain the source code for the Xomega intellisense style sheet.
  1. Define a simple type in your Xomega schema extension, and set it to be used by one or more custom attributes you define that need to have Intellisense support.
  2. Request the source code for intellisense.xsl from Xomega, and place it to the XSL sub-folder of the Xomega.Net installation folder.
  3. Open the intellisense.xsl file and update the template that matches the root element to handle your type as follows.
  4. Add an xsl:if block to test the type namespace $attrTypeNs and the type $attrType for your custom namespace and type name respectively.
  5. When the value of the $command parameter is 'get-decl', construct a list of member elements with name, description and glyph attributes and pass it to the decl:AddMembers() function using the xsl:value-of element. You can also use the $context parameter for the current context node, the $xpath
    parameter for the full xpath to the attribute, and the $value parameter for the current value of the attribute.
  6. When the value of the $command parameter is 'goto-defn', find the xml element that corresponds to the definition of the entity referred to by the current attribute, and pass it to the decl:GoTo() function using the xsl:value-of element. You can use the $value parameter for the current attribute value, as well as the $context and $xpath parameters as described above.
  7. When the value of the $command parameter is 'get-desc', select the value of the description of the entity referred to by the current attribute using the xsl:value-of element. You can use the $value parameter for the current attribute value, as well as the $context and $xpath parameters as described above.
  8. Test the intellisense in your model to make sure that it works as expected.

The following snippet illustrates how intellisense is added to all the attributes of the xdoClass type defined in the 'http://www.xomega.net/framework' namespace.
Code:
<xsl:if test="$attrTypeNs='http://www.xomega.net/framework' and $attrType='xdoClass'">
  <xsl:choose>
    <xsl:when test="$command='get-decl'">
      <xsl:variable name="members">
        <xsl:for-each select="//xfk:data-object">
          <xsl:sort select="@class"/>
          <member name="{@class}" description="{xfk:summary}" glyph="VSObject_Class"/>
        </xsl:for-each>
      </xsl:variable>
      <xsl:value-of select="decl:AddMembers(msxsl:node-set($members)/member)"/>
    </xsl:when>
    <xsl:when test="$command='goto-defn'">
      <xsl:value-of select="decl:GoTo(//xfk:data-object[@class=$value])"/>
    </xsl:when>
    <xsl:when test="$command='get-desc'">
      <xsl:value-of select="//xfk:data-object[@class=$value]/xfk:summary"/>
    </xsl:when>
  </xsl:choose>
</xsl:if>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Copyright © 2009-2022 Xomega.Net. All rights reserved.