Replace Patterns
Replace patterns are typically to be used with template compositions.
While template compositions are for defining all common aspects of certain elements, the purpose of replace patterns is to be able to 'inject' unique information into each instance of a certain template. Replace patterns are a linear list of key and value pairs, where the key is the pattern ID and the value is what each pattern ID occurrence gets replaced with in the template declaration before applied on the instance.
Each occurrence of a pattern ID must be delimited by the designated pattern ID delimiter: three underscores in a row.
In the example below we apply the replacePatternExample template on a couple of composer component instances by setting their template attribute to 'replacePatternExample'. Unique fill styles and captions are specified for each instance using replace patterns.
SMXML
<!DOCTYPE composer SYSTEM "http://dtd.samplemath.com/smxml.dtd">
<composer>
<style>
<fill style="fillOrange" type="solid">
<color>0xffcc00</color>
</fill>
<fill style="fillRed" type="solid">
<color>0xff0000</color>
</fill>
<fill style="fillBlue" type="solid">
<color>0x550099</color>
</fill>
<textformat style="sampleTextFormat">
<align>center</align>
<autosize>0</autosize>
<color>0xffffff</color>
<font>Impact, Helvetica, Arial</font>
<size>16</size>
</textformat>
</style>
<template>
<composer template="replacePatternExample" >
<box width="100%" height="100%" fill="___examplePatternB___" rounded="8"/>
<textblock y="40%" width="100%" height="30%" textformat="sampleTextFormat"><![CDATA[___examplePatternA___]]></textblock>
</composer>
</template>
<box id="background" width="100%" height="100%" alpha=".1" rounded="24"/>
<composer template="replacePatternExample" x="120" y="30" width="100" height="100">
<replace>
<pattern id="examplePatternA"><![CDATA[apples]]></pattern>
<pattern id="examplePatternB"><![CDATA[fillRed]]></pattern>
</replace>
</composer>
<composer template="replacePatternExample" x="280" y="40" width="160" height="80">
<replace>
<pattern id="examplePatternA"><![CDATA[mangos]]></pattern>
<pattern id="examplePatternB"><![CDATA[fillOrange]]></pattern>
</replace>
</composer>
<composer template="replacePatternExample" x="490" y="20" width="80" height="120">
<replace>
<pattern id="examplePatternA"><![CDATA[grapes]]></pattern>
<pattern id="examplePatternB"><![CDATA[fillBlue]]></pattern>
</replace>
</composer>
</composer>
<composer>
<style>
<fill style="fillOrange" type="solid">
<color>0xffcc00</color>
</fill>
<fill style="fillRed" type="solid">
<color>0xff0000</color>
</fill>
<fill style="fillBlue" type="solid">
<color>0x550099</color>
</fill>
<textformat style="sampleTextFormat">
<align>center</align>
<autosize>0</autosize>
<color>0xffffff</color>
<font>Impact, Helvetica, Arial</font>
<size>16</size>
</textformat>
</style>
<template>
<composer template="replacePatternExample" >
<box width="100%" height="100%" fill="___examplePatternB___" rounded="8"/>
<textblock y="40%" width="100%" height="30%" textformat="sampleTextFormat"><![CDATA[___examplePatternA___]]></textblock>
</composer>
</template>
<box id="background" width="100%" height="100%" alpha=".1" rounded="24"/>
<composer template="replacePatternExample" x="120" y="30" width="100" height="100">
<replace>
<pattern id="examplePatternA"><![CDATA[apples]]></pattern>
<pattern id="examplePatternB"><![CDATA[fillRed]]></pattern>
</replace>
</composer>
<composer template="replacePatternExample" x="280" y="40" width="160" height="80">
<replace>
<pattern id="examplePatternA"><![CDATA[mangos]]></pattern>
<pattern id="examplePatternB"><![CDATA[fillOrange]]></pattern>
</replace>
</composer>
<composer template="replacePatternExample" x="490" y="20" width="80" height="120">
<replace>
<pattern id="examplePatternA"><![CDATA[grapes]]></pattern>
<pattern id="examplePatternB"><![CDATA[fillBlue]]></pattern>
</replace>
</composer>
</composer>
There is one comment on this page. [Display comment]