o2xdl-core samples  3.01
Functions
a_triangle.o2xSobj File Reference

CTriangle.a_triangle: Simple o2x:object for contentList test. More...

Functions

 XML_code ()
 o2x:object code. More...
 

Detailed Description

This is a small o2x:object.

data
data defines base and height of a triangle.
methods
CTriangle.area: the final method, calculates the triangle Area
CTriangle.getFigure: getter for polygon name (late binding).
Returns
any context: A number, the area value

Function Documentation

◆ XML_code()

XML_code ( )

Simple implementation: data by value (o2x:body), method by value (o2x:inline).

Note
: the method CPolygon.getFigure (public, late binding) is the same also in CRectangle.a_rectangle.


-<o2x:object name="CTriangle.a_triangle" xmlns:o2x="http://www.o2xdl.org/3.0/o2xdl" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<o2x:dataValues>
-<o2x:body>
-<CTriangle>
<figure>Triangle</figure>
<base>18</base>
<height>10</height>
</CTriangle>
</o2x:body>
</o2x:dataValues>
-<o2x:method context="default" key="CTriangle.area">
-<o2x:inline>
<xsl:output omit-xml-declaration="yes"/>
-<xsl:template match="o2x:object[@key='CTriangle.area']">
<xsl:value-of select="(CTriangle/base * CTriangle/height) div 2"/>
</xsl:template>
</o2x:inline>
</o2x:method>
-<o2x:method visibility="public" key="CTriangle.getFigure">
-<o2x:inline>
-<!--
 late binding: CPolygon.getFigure = group id 
-->
-<xsl:template match="CTriangle" mode="CPolygon.getFigure">
<xsl:value-of select="figure"/>
</xsl:template>
</o2x:inline>
</o2x:method>
</o2x:object>