Main Subelements examples #

Conditional blocks #

The Snom Minibrowser supports also conditional code block that can be executed after a condition evaluation. Conditional blocks are implemented trough the tags If, Elif and Else

Demo

Conditionals example 1 #

Simple use of tags:

<?xml version="1.0" encoding="UTF-8"?>
<SnomIPPhoneText>
    <If condition="$(set:phone_type)==snomD375">
        <Title>Snom D375</Title>
    </If>
    <Elif condition="$(set:phone_type)==snomD765">
        <Title>Snom D765</Title>
    </Elif>
    <Else>
        <Title>Unknown Snom phone</Title>
    </Else>
    <Text>Snom phone sample text</Text>
</SnomIPPhoneText>

Result

Conditionals1

Conditionals example 2 #

Show different text on different Snom phone model:

<?xml version="1.0" encoding="UTF-8"?>
<SnomIPPhoneText xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../minibrowser_test.xsd">
    <If condition="$(set:phone_type)==snomD375">
        <Title>Snom D375</Title>
        <Text>Your phone is a Snom D375</Text>
    </If>
    <Elif condition="$(set:phone_type)==snomD765">
        <Title>Snom D765</Title>
        <Text>Your phone is a Snom D765</Text>
    </Elif>
    <Else>
        <Title>Unknown Snom phone</Title>
        <Text>Snom phone not recognised</Text>
    </Else>
</SnomIPPhoneText>

Result

Conditionals2

Conditionals example 3 #

Test on some operators:

<?xml version="1.0" encoding="UTF-8"?>
<SnomIPPhoneMenu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../minibrowser_test.xsd">
    <Menu name="Menu1">
<!-- TRUE -->   <If condition="a==a"><MenuItem name="TRUE>>a==a" /></If>
        <Else><MenuItem name="FALSE>>a==a" /></Else>
<!-- FALSE -->  <If condition="a==A"><MenuItem name="TRUE>>a==A" /></If>
        <Else><MenuItem name="FALSE>>a==A" /></Else>
<!-- FALSE -->  <If condition="!a==a"><MenuItem name="TRUE>>!a==a" /></If>
        <Else><MenuItem name="FALSE>>!a==a" /></Else>
<!-- FALSE -->  <If condition=" a==a"><MenuItem name="TRUE>> a==a" /></If>
        <Else><MenuItem name="FALSE>> a==a" /></Else>
<!-- TRUE -->   <If condition=" 10>=10"> <MenuItem name="TRUE>> 10>=10" /></If>
        <Else><MenuItem name="FALSE>> 10>=10" /></Else>
<!-- TRUE -->   <If condition="10>= 10"><MenuItem name="TRUE>>10>= 10" /></If>
        <Else><MenuItem name="FALSE>>10>= 10" /></Else>
    </Menu>
</SnomIPPhoneMenu>

Result

Conditionals3

Repeat #

It is recommended to use unique token. If one token contain another token this will create unexpected result.

Warning

  • Good tocken: token="/__NAME__/__URL__/"
  • Bad tocken: token="/_name_/_file_name_/"

Demo

Repeat example 1 #

Example code using values attribute

<?xml version="1.0" encoding="UTF-8"?>
<SnomIPPhoneMenu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../minibrowser_test.xsd">
    <Repeat token="/__NAME__/__URL__/" values="|foo|http://foo.com|bar|http://bar.com|">
        <MenuItem name="__NAME__">
            <Url>__URL__</Url>
        </MenuItem>
    </Repeat>
</SnomIPPhoneMenu>

Result

Repeat1

Repeat example 2 #

Example Code using var_ifc attribute

<?xml version="1.0" encoding="UTF-8"?>
<SnomIPPhoneMenu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../minibrowser_test.xsd">
    <Title>var_ifc test</Title>
    <Repeat token="|__state__|__name__|__file_name__|" var_ifc="lang.pui.*">
        <if condition="__state__==active">
            <MenuItem name="$(x_o:$(condition:__state__==active)) __name__(__file_name__)" sel="true"/>
        </if>
        <else>
            <MenuItem name="$(x_o:$(condition:__state__==active)) __name__(__file_name__)" sel="false"/>
        </else>
    </Repeat>
</SnomIPPhoneMenu>

Result

Repeat2

Fetch #

Fetch example, first page #

<?xml version="1.0" encoding="UTF-8"?>
<SnomIPPhoneText>
    <Title>1st page</Title>
    <Text>This text shown only for 4 second</Text>
    <fetch mil="4000">http://docs.snom.io/xml_minibrowser/examples/xml/Fetch2.xml</fetch>
</SnomIPPhoneText>

Fetch example, second page #

<?xml version="1.0" encoding="UTF-8"?>
<SnomIPPhoneText>
    <Title>2nd page</Title>
    <Text>Bye bye!</Text>
    <Fetch mil="4000">snom://mb_exit</Fetch>
</SnomIPPhoneText>

Result

Fetch

Led #

Led example: led on #

<?xml version="1.0" encoding="UTF-8"?>
<SnomIPPhoneText>
    <Title>LED Control Feature</Title>
    <Text>This sample page demonstrates the Minibrowser LED control feature.</Text>
    <Led number="1">On</Led>
    <Led number="2">blink</Led>
    <Led number="3">blinkfast</Led>
    <Led number="4">blinkslow</Led>
    <Led number="5" color="green">on</Led>
    <SoftKeyItem>
        <Name>F1</Name>
        <Label>Off</Label>
        <URL>http://docs.snom.io/xml_minibrowser/examples/xml/Led-off.xml</URL>
    </SoftKeyItem>
    <SoftKeyItem>
        <Name>F2</Name>
        <Label>Exit</Label>
        <URL>snom://mb_exit</URL>
    </SoftKeyItem> 
</SnomIPPhoneText>

Led example: led off #

<?xml version="1.0" encoding="UTF-8"?>
<SnomIPPhoneText>
    <Title>LED Control Feature</Title>
    <Text>This sample page demonstrates the Minibrowser LED control feature.</Text>
    <Led number="1">Off</Led>
    <Led number="2">Off</Led>
    <Led number="3">Off</Led>
    <Led number="4">Off</Led>
    <Led number="5" color="green">Off</Led>
    <SoftKeyItem>
        <Name>F1</Name>
        <Label>On</Label>
        <URL>http://docs.snom.io/xml_minibrowser/examples/xml/Led.xml</URL>
    </SoftKeyItem>    
    <SoftKeyItem>
        <Name>F2</Name>
        <Label>Exit</Label>
        <URL>snom://mb_exit</URL>
    </SoftKeyItem>    
</SnomIPPhoneText>