o2xdl-core samples  3.01
Functions
minimal_object05.o2xSobj File Reference

Simple o2x:object - 5: test visibility and binding. More...

Functions

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

Detailed Description

Test of methods visibility and bindig.

data
Data is defined by reference, i.e. using a local file defined by URIref attribute in <o2x:dataValues> tag.
methods
In this o2x:object are 2 methods:
  • OBJ.050511.M01, visibility final, only calls OBJ.050511.M02.
  • OBJ.050511.M02, visibility protected that does the job.
    This last method, to maximize reuse, allows late and modal binding.
Returns
An HTML fragment: the ship address formatted to print.

Function Documentation

◆ XML_code()

XML_code ( )

Implementation: data on local file, methods inline.

CORE constraint
Visibility: Only the final visibility is significative. Any not-final visibility is an hint and can be omitted without consequences.
Binding: A method's template can implement:
  • The final binding, mandatory for every final method, match="o2x:object[@key = 'a_unique_value']..." is required to select the correct object.
  • The modal binding: match="allowed-data-element" mode="a_unique_value"
  • The hearly binding is implemented with a 'named template': name = "a_unique_value"
  • The late binding match="allowed-data-element" mode="group_id"

A 'non-final' template can implement two binding: modal + hearly or late + hearly: that can make it more useful.
To activate a method:

  • A final method usually is activated by 'Realyze()'. In case of o2x:contentList see twopoly_complex08.o2xSobj and xpoly_complex09.o2xSobj.
  • The call of a method with modal binding is simple: <xsl:apply-templates [select="allowed-data-element"] mode="a_unique_value"
  • Calling a method with hearly binding is equivalent to call a named function: <xsl:call-template name = "a_unique_value" />
  • Calling a method with late binding is data-driven: <xsl:apply-templates select="a-data-element" mode="group_id"


-<o2x:object name="minimal_object05" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:o2x="http://www.o2xdl.org/3.0/o2xdl">
<o2x:dataValues URIref="file:////C:/o2xdl-20/samples/minimal_object02_data.xml"/>
-<o2x:method key="OBJ.050511.M01" visibility="final">
-<o2x:inline>
-<!--
 final binding, it now selects the root data element 
-->
-<xsl:template match="o2x:object[@key = 'OBJ.050511.M01']/shipTo">
-<!--
 calls the protected method (hearly binding)  
-->
<xsl:call-template name="OBJ.050511.M02"/>
<br/>
-----------
<br/>
-<!--
 calls the protected method (modal binding)  
-->
<xsl:apply-templates select="." mode="OBJ.050511.M02"/>
</xsl:template>
</o2x:inline>
</o2x:method>
-<o2x:method key="OBJ.050511.M02" visibility="protected">
-<o2x:inline>
-<!--
 standard reusable (not final) method template 
-->
-<!--
 implements both modal and hearly binding  
-->
-<xsl:template match="shipTo" mode="OBJ.050511.M02" name="OBJ.050511.M02">
-<b>
<xsl:value-of select="name"/>
</b>
<br/>
<xsl:value-of select="street"/>
<br/>
<xsl:value-of select="city"/>
,
<xsl:value-of select="state"/>
<xsl:value-of select="zip"/>
<br/>
<xsl:value-of select="@country"/>
</xsl:template>
</o2x:inline>
</o2x:method>
</o2x:object>