%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www_old/music/scanned/
Upload File :
Create Path :
Current File : //var/www_old/music/scanned/transformTo.xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  <xsl:template match="/" >
    <PanelConfiguration>
      <Panel UID="{InternalDataSet/Panel/UID}" Type="{InternalDataSet/Panel/Type}">
        <Name><xsl:value-of select="/InternalDataSet/Panel/Name" /></Name>
        <ConfigInfo>
          <Version><xsl:value-of select="/InternalDataSet/ConfigInfo/Version" /></Version>
          <GUID><xsl:value-of select="/InternalDataSet/ConfigInfo/GUID" /></GUID>
          <CompatibilityID><xsl:value-of select="/InternalDataSet/ConfigInfo/CompatibilityID" /></CompatibilityID>
          <ChangeCounter><xsl:value-of select="/InternalDataSet/ConfigInfo/ChangeCounter" /></ChangeCounter>
          <Timestamp><xsl:value-of select="/InternalDataSet/ConfigInfo/Timestamp" /></Timestamp>
        </ConfigInfo>
        <RuntimePersistence>
          <xsl:apply-templates select="InternalDataSet/Storage" />
        </RuntimePersistence>
        <Application UID="10" Type="MBEMEAApplication">
          <Name>MBEMEAApp</Name>
          <ApplicationManager UID="11" Type="ccApplicationManager">
            <Name>ApplicationManager</Name>
            <PartitionManager UID="12" Type="ccPartitionManager">
              <Name>PartitionManager</Name>
              <Partitions>
                <xsl:apply-templates select="InternalDataSet/Partition" />
              </Partitions>
              <ExternalSignallingGroups>
                <xsl:apply-templates select="InternalDataSet/SignalingGroup" />
              </ExternalSignallingGroups>
            </PartitionManager>
            <PartitionMemberManager UID="14" Type="ccPartitionMemberManager">
              <Name>PartitionMemberManager</Name>
              <PartitionMembers>
                <DetectorGroups>
                  <xsl:apply-templates select="InternalDataSet/DetectorGroup" />
                </DetectorGroups>
                <AccessPoints>
                  <xsl:apply-templates select="InternalDataSet/AccessPoint" />
                </AccessPoints>
              </PartitionMembers>
              <PMCollections UID="15" Type="ccPMCollectionManager">
                <Name>PMCollections</Name>
                <xsl:apply-templates select="InternalDataSet/PMCollectionDependency" />
                <xsl:apply-templates select="InternalDataSet/PMCollectionEntryRoute" />
                <xsl:apply-templates select="InternalDataSet/PMCollectionExitRoute" />
              </PMCollections>
            </PartitionMemberManager>
            <VirtualDevices UID="16" Type="ccMBEMEAVirtualDeviceManager">
              <Name>VirtualDevices</Name>
              <VirtualPIRs>
                <xsl:apply-templates select="InternalDataSet/VirtualBusPIR" />
                <xsl:apply-templates select="InternalDataSet/VirtualHardwiredPIR" />
              </VirtualPIRs>
              <VirtualInputs>
                <xsl:apply-templates select="InternalDataSet/VirtualInput" />
              </VirtualInputs>
              <VirtualOutputs>
                <xsl:apply-templates select="InternalDataSet/VirtualOutput" />
              </VirtualOutputs>
              <VirtualCameras>
                <xsl:apply-templates select="InternalDataSet/VirtualCamera" />
              </VirtualCameras>
              <VirtualCarbonMonoxides>
                <xsl:apply-templates select="InternalDataSet/VirtualCarbonMonoxide" />
              </VirtualCarbonMonoxides>
              <VirtualDoors>
                <xsl:apply-templates select="InternalDataSet/VirtualBusDoor" />
                <xsl:apply-templates select="InternalDataSet/VirtualHardwiredDoor" />
              </VirtualDoors>
              <VirtualDSDevices>
                <xsl:apply-templates select="InternalDataSet/VirtualDSDevice" />
              </VirtualDSDevices>
              <VirtualFlashers>
                <xsl:apply-templates select="InternalDataSet/VirtualFlasher" />
              </VirtualFlashers>
              <VirtualKeys>
                <xsl:apply-templates select="InternalDataSet/VirtualKey" />
              </VirtualKeys>
              <VirtualKeySwitchs>
                <xsl:apply-templates select="InternalDataSet/VirtualKeySwitch" />
              </VirtualKeySwitchs>              
              <VirtualLeds>
                <xsl:apply-templates select="InternalDataSet/VirtualLed" />
              </VirtualLeds>
              <VirtualPeripherals>
                <xsl:apply-templates select="InternalDataSet/VirtualPeripheral" />
              </VirtualPeripherals>
              <VirtualRelays>
                <xsl:apply-templates select="InternalDataSet/VirtualRelay" />
              </VirtualRelays>
              <VirtualRfPeripherals>
                <xsl:apply-templates select="InternalDataSet/VirtualWirelessPeripheral" />
              </VirtualRfPeripherals>
              <VirtualRfMasters>
                <xsl:apply-templates select="InternalDataSet/VirtualWirelessMaster" />
              </VirtualRfMasters>
              <VirtualRfReceivers>
                <xsl:apply-templates select="InternalDataSet/VirtualWirelessReceiver" />
              </VirtualRfReceivers>
              <VirtualSmartUIs>
                <xsl:apply-templates select="InternalDataSet/VirtualSmartUI" />
              </VirtualSmartUIs>
              <VirtualSmokeDetectors>
                <xsl:apply-templates select="InternalDataSet/VirtualSmokeDetector" />
              </VirtualSmokeDetectors>
              <VirtualSounders>
                <xsl:apply-templates select="InternalDataSet/VirtualSounder" />
              </VirtualSounders>
              <VirtualTemperatures>
                <xsl:apply-templates select="InternalDataSet/VirtualTemperature" />
              </VirtualTemperatures>
              <VirtualUserInterfaces>
                <xsl:apply-templates select="InternalDataSet/VirtualReader" />
                <xsl:apply-templates select="InternalDataSet/VirtualKeyboard" />
                <xsl:apply-templates select="InternalDataSet/VirtualKeyboardReader" />
              </VirtualUserInterfaces>
              <VirtualWindows>
                <xsl:apply-templates select="InternalDataSet/VirtualWindow" />
              </VirtualWindows>
            </VirtualDevices>
            <ScheduleManager UID="17" Type="ccScheduleManager">
              <Name>ScheduleManager</Name>
              <Holidays>
                <xsl:apply-templates select="InternalDataSet/Holiday" />
              </Holidays>
              <TimeSchedules>
                <xsl:apply-templates select="InternalDataSet/TimeSchedule" />
              </TimeSchedules>
              <Schedules>
                <xsl:call-template name="InsertSchedules" />
              </Schedules>
            </ScheduleManager>
            <ScheduledItemManager UID="18" Type="ccScheduledItemManager">
              <xsl:call-template name="InsertScheduledItems" />
            </ScheduledItemManager>
            <UserGroupManager UID="19" Type="ccUserGroupManager">
              <xsl:apply-templates select="InternalDataSet/UserGroup" />
            </UserGroupManager>
            <UserManager UID="20" Type="ccUserManager">
              <CodeLength>
                <xsl:value-of select="/InternalDataSet/GeneralSettings/UserCodeLength" />
              </CodeLength>
              <DuressPosition>
                <xsl:value-of select="/InternalDataSet/GeneralSettings/UserCodeDuressPosition" />
              </DuressPosition>
              <DuressOffset>
                <xsl:value-of select="/InternalDataSet/GeneralSettings/UserCodeDuressOffset" />
              </DuressOffset>
              <Users>
                <xsl:apply-templates select="InternalDataSet/User" />
              </Users>
            </UserManager>
            <EventLogs>
              <EventLog Name="EventLog" UID="4026531840" Type="ccMBEMEAEventLog" Size="10000" Circular="true" Storage="sfOnRequest1,sfOnRequest2,sfOnRequest3,sfOnRequest4">
                <Event Ev="ccEVAPPPartitionOmit" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPPartitionSetState" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPPartitionClear" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPPartitionAlarm" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPPartitionFault" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPPartitionTimer" UID="0" SubEv="estEntry" />
                <Event Ev="ccEVAPPPartitionTimer" UID="0" SubEv="estExit" />
                <Event Ev="ccEVAPPPartitionTimer" UID="0" SubEv="estFullAlarm" />
                <Event Ev="ccEVAPPPartitionTimer" UID="0" SubEv="estLocalAlarm" />
                <Event Ev="ccEVAPPPartitionTimer" UID="0" SubEv="estPartSetDelay" />
                <Event Ev="ccEVAPPPartitionTimer" UID="0" SubEv="estUnsetPrevention" />
                <Event Ev="ccEVAPPPartitionTimer" UID="0" SubEv="estUnsetPreventionAlarm" />
                <Event Ev="ccEVAPPPMCollectionDependency" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPPMCollectionEntryRoute" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPPMCollectionExitRoute" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPPartitionMemberState" SubEv="estRelease" UID="0" />
                <Event Ev="ccEVAPPPartitionMemberState" SubEv="estNormal" UID="0" />
                <Event Ev="ccEVAPPPartitionMemberOmit" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPDetectorGroupAlarm" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPAccessPoint" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPVirtualPeripheral" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPMacro" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPRAMConnection" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVAPPSWLicense" UID="0" SubEv="estAllSubTypes" />
                <Event Ev="ccEVHWPanelDateTime" UID="0" SubEv="estAllSubTypes" />
              </EventLog>
            </EventLogs>
            <EventConsumerManager>
            </EventConsumerManager>
          </ApplicationManager>
          <Macros UID="21" Type="ccMBEMEAMacroControl">
            <TriggerPool UID="22" Type="ccMBEMEATriggerManager">
              <xsl:apply-templates select="InternalDataSet/Trigger" />
            </TriggerPool>
            <ConditionPool UID="23" Type="ccConditionManager">
              <xsl:apply-templates select="InternalDataSet/Condition" />
            </ConditionPool>
            <SignalPool UID="24" Type="ccSignalManager">
              <ImpulseTime>5</ImpulseTime>
              <xsl:apply-templates select="InternalDataSet/Signal" />
            </SignalPool>
            <CommandPool UID="25" Type="ccCommandManager">
              <xsl:apply-templates select="InternalDataSet/Command" />
            </CommandPool>
            <ActionPool UID="26" Type="ccActionManager">
              <xsl:apply-templates select="InternalDataSet/Action" />
            </ActionPool>
            <MacroPool UID="27" Type="ccMacroManager">
              <xsl:apply-templates select="InternalDataSet/Macro" />
            </MacroPool>
          </Macros>
          <UserInterfaceManager UID="31" Type="ccUserInterfaceManager">
            <xsl:apply-templates select="InternalDataSet/UITouchCenter" />
            <xsl:call-template name="InsertKeypads" />
          </UserInterfaceManager>
          <RemoteApplicationManager>
            <Connections>
              <xsl:apply-templates select="InternalDataSet/RemoteApplication" />
            </Connections>
          </RemoteApplicationManager>
          <AlarmReportingManager UID="32" Type="ccMBEMEAAlarmReporting">
            <AlarmDevices>
              <xsl:apply-templates select="InternalDataSet/AlarmDevice" />
            </AlarmDevices>
          </AlarmReportingManager>
        </Application>
        <HardwareManager UID="41" Type="ccIHardwareManager">
          <Name>Hardwaremanager</Name>
          <LogicalDevices>
            <LogicalInputs>
              <xsl:apply-templates select="InternalDataSet/LogicalInput" />
            </LogicalInputs>
            <LogicalOutputs>
              <xsl:apply-templates select="InternalDataSet/LogicalOutput" />
            </LogicalOutputs>
            <LogicalPirs>
              <xsl:apply-templates select="InternalDataSet/LogicalPIR" />
            </LogicalPirs>
            <LogicalAccessPoints>
              <xsl:apply-templates select="InternalDataSet/LogicalAccessPoint" />
            </LogicalAccessPoints>
            <LogicalCameras>
              <xsl:apply-templates select="InternalDataSet/LogicalCamera" />
            </LogicalCameras>
            <LogicalCarbonMonoxides>
              <xsl:apply-templates select="InternalDataSet/LogicalCarbonMonoxide" />
            </LogicalCarbonMonoxides>
            <LogicalDisplays>                       
              <xsl:apply-templates select="InternalDataSet/LogicalDisplay" />
            </LogicalDisplays>
            <LogicalDoors>
              <xsl:apply-templates select="InternalDataSet/LogicalDoor" />
            </LogicalDoors>
            <LogicalDSAlarmReportings>
              <xsl:apply-templates select="InternalDataSet/LogicalDSAlarmReporting" />
            </LogicalDSAlarmReportings>
            <LogicalEmails>
              <xsl:apply-templates select="InternalDataSet/LogicalEmail" />
            </LogicalEmails>
            <LogicalEventBroadcasters>
              <xsl:apply-templates select="InternalDataSet/LogicalEventBroadcaster" />
            </LogicalEventBroadcasters>
            <LogicalInstallationServices>
              <xsl:apply-templates select="InternalDataSet/LogicalInstallService" />
            </LogicalInstallationServices>
            <LogicalKeyboards>
              <xsl:apply-templates select="InternalDataSet/LogicalKeyboard" />
            </LogicalKeyboards>            
            <LogicalKeyboardReaders>
              <xsl:apply-templates select="InternalDataSet/LogicalKeyboardReader" />
            </LogicalKeyboardReaders>
            <LogicalKeypads>
              <xsl:apply-templates select="InternalDataSet/LogicalKeypad" />
            </LogicalKeypads>            
            <LogicalKeys>
              <xsl:apply-templates select="InternalDataSet/LogicalKey" />
            </LogicalKeys>                        
            <LogicalLeds>
              <xsl:apply-templates select="InternalDataSet/LogicalLed" />          
            </LogicalLeds>
            <LogicalPeripherals>
              <xsl:apply-templates select="InternalDataSet/LogicalPeripheral" />
            </LogicalPeripherals>
            <LogicalReaders>
              <xsl:apply-templates select="InternalDataSet/LogicalReader" />
            </LogicalReaders>
            <LogicalRFPeripherals>
              <xsl:apply-templates select="InternalDataSet/LogicalWirelessPeripheral" />
            </LogicalRFPeripherals>
            <LogicalRFMasters>
              <xsl:apply-templates select="InternalDataSet/LogicalWirelessMaster" />
            </LogicalRFMasters>
            <LogicalSmartUIs>
              <xsl:apply-templates select="InternalDataSet/LogicalSmartUI" />
            </LogicalSmartUIs>
            <LogicalSmokeDetectors>
              <xsl:apply-templates select="InternalDataSet/LogicalSmokeDetector" />
            </LogicalSmokeDetectors>
            <LogicalSounders>
              <xsl:apply-templates select="InternalDataSet/LogicalSounder" />
              <SounderTemplates>
                <xsl:apply-templates select="InternalDataSet/SounderTemplate" />
              </SounderTemplates>
            </LogicalSounders>
            <LogicalSMSs>
              <xsl:apply-templates select="InternalDataSet/LogicalSMS" />
            </LogicalSMSs>
            <LogicalTemperatures>
              <xsl:apply-templates select="InternalDataSet/LogicalTemperature" />
            </LogicalTemperatures>
          </LogicalDevices>
          <GPIO>
            <GPIOInputs>
              <xsl:apply-templates select="InternalDataSet/HWGPIOInput" />
            </GPIOInputs>
            <GPIOOutputs>
              <xsl:apply-templates select="InternalDataSet/HWGPIOOutput" />
            </GPIOOutputs>
            <SPIInputs>
              <xsl:apply-templates select="InternalDataSet/HWSPIInput" />
            </SPIInputs>
            <SPIOutputs>
              <xsl:apply-templates select="InternalDataSet/HWSPIOutput" />
            </SPIOutputs>
            <AnalogInputs>
              <xsl:apply-templates select="InternalDataSet/HWAnalogInput" />
            </AnalogInputs>
          </GPIO>
          <Drivers>
            <IB2>
              <!-- not supported yet -->
            </IB2>
          </Drivers>
          <BusController>
            <!--inserts all controllers connected directly to the panel (all iternal buses) -->
            <xsl:call-template name="InsertBusControllers" />
          </BusController>
          <SupportController>
            <xsl:call-template name="InsertSupportControllers" />
          </SupportController>
        </HardwareManager>
      </Panel>
    </PanelConfiguration>
  </xsl:template>
 
  <xsl:template match="InternalDataSet/Storage">
    <Storage eSaveFrequency="{SaveFrequency}" Seconds="{Seconds}" Mode="{Mode}" FileStream="{FileStream}" DecoratorStream="{DecoratorStream}" Filename="{FileName}" />    
  </xsl:template>

  <xsl:template match="InternalDataSet/VirtualBusPIR">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>
    <VirtualPIR UID="{UID}" Type="ccVirtualBusPIR">      
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalPIRUID" /></HWUID>        
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>
    </VirtualPIR>
  </xsl:template>

  <xsl:template match="InternalDataSet/VirtualHardwiredPIR">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>
    <VirtualPIR UID="{UID}" Type="ccVirtualHardwiredPIR">      
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID>0</HWUID>
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>
      <Inputs>
        <Input>
          <Position>pipAlarm</Position>
          <HWUID><xsl:value-of select="AlarmInputUID" /></HWUID>
        </Input>
        <Input>
          <Position>pipTamper</Position>
          <HWUID><xsl:value-of select="TamperInputUID" /></HWUID>
        </Input>
        <Input>
          <Position>pipFault</Position>
          <HWUID><xsl:value-of select="FaultInputUID" /></HWUID>
        </Input>
      </Inputs>
      <Outputs>
        <Output>
          <Position>popWalkTest</Position>
          <HWUID><xsl:value-of select="WalkTestOutputUID" /></HWUID>
        </Output>
        <Output>
          <Position>popSet</Position>
          <HWUID><xsl:value-of select="SetOutputUID" /></HWUID>
        </Output>
      </Outputs>
    </VirtualPIR>
  </xsl:template>


  <xsl:template match="InternalDataSet/VirtualInput">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualInput UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">      
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalInputUID" /></HWUID>
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>
    </VirtualInput>
  </xsl:template>

  <xsl:template match="InternalDataSet/VirtualOutput">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualOutput UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalOutputUID" /></HWUID>
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>    
      <Signal><xsl:value-of select="SignalUID" /></Signal>
    </VirtualOutput>
  </xsl:template>

  <xsl:template match="InternalDataSet/VirtualBusDoor">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualDoor UID="{UID}" Type="ccVirtualBusDoor">         
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>
      <HWUID><xsl:value-of select="LogicalDoorUID" /></HWUID>
      <OpenSignalSounder><xsl:value-of select="OpenSignalSounder" /></OpenSignalSounder>
      <OpenSignalTime><xsl:value-of select="OpenSignalTime" /></OpenSignalTime>
      <OpenAlarmTime><xsl:value-of select="OpenAlarmTime" /></OpenAlarmTime>
      <SecondaryOwner><xsl:value-of select="/InternalDataSet/VirtualDoor[UID=$DeviceUID]/SecondaryOwner" /></SecondaryOwner>
      <Tamper><xsl:value-of select="/InternalDataSet/VirtualDoor[UID=$DeviceUID]/Tamper" /></Tamper>
      <LockingError><xsl:value-of select="/InternalDataSet/VirtualDoor[UID=$DeviceUID]/LockingError" /></LockingError>
    </VirtualDoor>
  </xsl:template>

  <xsl:template match="InternalDataSet/VirtualHardwiredDoor">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualDoor UID="{UID}" Type="ccVirtualHardwiredDoor">           
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>
      <OpenSignalSounder><xsl:value-of select="OpenSignalSounder" /></OpenSignalSounder>
      <OpenSignalTime><xsl:value-of select="OpenSignalTime" /></OpenSignalTime>
      <OpenAlarmTime><xsl:value-of select="OpenAlarmTime" /></OpenAlarmTime>
      <SecondaryOwner><xsl:value-of select="/InternalDataSet/VirtualDoor[UID=$DeviceUID]/SecondaryOwner" /></SecondaryOwner>     
      <Tamper><xsl:value-of select="/InternalDataSet/VirtualDoor[UID=$DeviceUID]/Tamper" /></Tamper>
      <Inputs>
        <Input>
          <Position>dipStateContact</Position>
          <HWUID><xsl:value-of select="StateContactUID" /></HWUID>
        </Input>
        <Input>
          <Position>dipLatchContact</Position>
          <HWUID><xsl:value-of select="LatchContactUID" /></HWUID>
        </Input>
        <Input>
          <Position>dipBoltContact</Position>
          <HWUID><xsl:value-of select="BoltContactUID" /></HWUID>
        </Input>
      </Inputs>
      <Outputs>
        <Output>
          <Position>dopOpenerRelais</Position>
          <HWUID><xsl:value-of select="OpenerRelayUID" /></HWUID>
        </Output>
        <Output>
          <Position>dopPrealarmRelais</Position>
          <HWUID><xsl:value-of select="PrealarmRelayUID" /></HWUID>
        </Output>
        <Output>
          <Position>dopLockRelais</Position>
          <HWUID><xsl:value-of select="LockRelayUID" /></HWUID>
        </Output>
        <Output>
          <Position>dopEscapeRelais</Position>
          <HWUID><xsl:value-of select="EscapeRelayUID" /></HWUID>
        </Output>
      </Outputs>
   </VirtualDoor>    
  </xsl:template>
  
  <xsl:template match="InternalDataSet/VirtualPeripheral">    
    <xsl:variable name="PeripheralUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualPeripheral UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$PeripheralUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$PeripheralUID]/Name" /></Name>
      <xsl:choose>
        <xsl:when test="UsedByPanel='true'">
          <!-- panel is linked with virtualperipheral directly (no logical peripheral) -->
          <HWUID><xsl:value-of select="/InternalDataSet/Panel/UID" /></HWUID>
        </xsl:when>     
        <xsl:otherwise>
          <HWUID><xsl:value-of select="LogicalPeripheralUID" /></HWUID>  
        </xsl:otherwise> 
      </xsl:choose>      
      <Owners>
        <xsl:for-each select="/InternalDataSet/VirtualPeripheralPartitionMemberFaultType[VirtualPeripheralUID=$PeripheralUID]">
          <xsl:variable name="PMUID"><xsl:value-of select="PartitionMemberUID" /></xsl:variable>                
          <Owner>
            <UID><xsl:value-of select="$PMUID" /></UID>
            <xsl:if test="SendAllFaultTypes!='true'">
              <FaultTypes>
                <xsl:for-each select="*[starts-with(name(),'ft')]">	
                  <xsl:variable name="tagValue" select="." />
                  <xsl:if test="$tagValue='true'">
                    <FaultType><xsl:value-of select="name()" /></FaultType>			                                        
                  </xsl:if>
                </xsl:for-each>
               </FaultTypes>            
             </xsl:if>
          </Owner>              
        </xsl:for-each>            
      </Owners>   
      <FaultTypes>
        <xsl:for-each select="*[starts-with(name(),'fe')]">        
          <xsl:variable name="effectName" select="concat('ft',substring(name(), 3))" />
          <xsl:variable name="effectValue" select="." />
          <xsl:if test="$effectValue!='feInvalid'">
			<FaultType>
			  <Type><xsl:value-of select="$effectName" /></Type>
			  <Effect><xsl:value-of select="$effectValue" /></Effect>
			</FaultType>         
          </xsl:if>
        </xsl:for-each>                  
      </FaultTypes>                           
    </VirtualPeripheral>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/VirtualSmartUI">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualSmartUI UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalSmartUI_UID" /></HWUID>    
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>          
    </VirtualSmartUI>  
  </xsl:template>

  <xsl:template match="InternalDataSet/VirtualSmokeDetector">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualSmokeDetector UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalSmokeDetectorUID" /></HWUID>    
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>
      <LowSenseEffect><xsl:value-of select="LowSenseEffect" /></LowSenseEffect>
      <WrongHeadEffect><xsl:value-of select="WrongHeadEffect" /></WrongHeadEffect>
    </VirtualSmokeDetector>
  </xsl:template>

  <xsl:template match="InternalDataSet/VirtualWirelessPeripheral">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualRfPeripheral UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalWirelessPeripheralUID" /></HWUID>    
      <Owners>
        <xsl:for-each select="/InternalDataSet/VirtualPeripheralPartitionMemberFaultType[VirtualRFPeripheralUID=$DeviceUID]">
          <xsl:variable name="PMUID"><xsl:value-of select="PartitionMemberUID" /></xsl:variable>                
          <Owner>
            <UID><xsl:value-of select="$PMUID" /></UID>
            <xsl:if test="SendAllFaultTypes!='true'">
              <FaultTypes>
                <xsl:for-each select="*[starts-with(name(),'ft')]">	
                  <xsl:variable name="tagValue" select="." />
                  <xsl:if test="$tagValue='true'">
                    <FaultType><xsl:value-of select="name()" /></FaultType>			                                        
                  </xsl:if>
                </xsl:for-each>
               </FaultTypes>            
             </xsl:if>
          </Owner>              
        </xsl:for-each>            
      </Owners>   
      <FaultTypes>
        <xsl:for-each select="*[starts-with(name(),'fe')]">        
          <xsl:variable name="effectName" select="concat('ft',substring(name(), 3))" />
          <xsl:variable name="effectValue" select="." />
          <xsl:if test="$effectValue!='feInvalid'">
			<FaultType>
			  <Type><xsl:value-of select="$effectName" /></Type>
			  <Effect><xsl:value-of select="$effectValue" /></Effect>
			</FaultType>         
          </xsl:if>
        </xsl:for-each>                  
      </FaultTypes>       
    </VirtualRfPeripheral>
  </xsl:template>  

  <xsl:template match="InternalDataSet/VirtualWirelessMaster">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualRfMaster UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalWirelessMasterUID" /></HWUID>    
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>      
    </VirtualRfMaster>
  </xsl:template>  
  
  <xsl:template match="InternalDataSet/VirtualWirelessReceiver">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualRfReceiver UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalRfReceiverUID" /></HWUID>    
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>      
    </VirtualRfReceiver>
  </xsl:template>  
  
  <xsl:template match="InternalDataSet/VirtualCamera">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualCamera UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalCameraUID" /></HWUID>    
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>      
    </VirtualCamera>
  </xsl:template>      
  
  <xsl:template match="InternalDataSet/VirtualCarbonMonoxide">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualCarbonMonoxide UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalCarbonMonoxideUID" /></HWUID>    
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>      
    </VirtualCarbonMonoxide>    
  </xsl:template>

  <xsl:template match="InternalDataSet/VirtualKey">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualKey UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalKeyUID" /></HWUID>
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>      
    </VirtualKey>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/VirtualKeySwitch">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualKeySwitch UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalInputUID" /></HWUID>
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>      
    </VirtualKeySwitch>
  </xsl:template>

  <xsl:template match="InternalDataSet/VirtualLed">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualLed UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalOutputUID" /></HWUID>
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>      
    </VirtualLed>
  </xsl:template>

  <xsl:template match="InternalDataSet/VirtualRelay">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualRelay UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalOutputUID" /></HWUID>
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>      
    </VirtualRelay>
  </xsl:template>

  <xsl:template match="InternalDataSet/VirtualWindow">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>        
    <VirtualWindow UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>
      <Inputs>
        <Input>
          <Position>pipAlarm</Position>
          <HWUID><xsl:value-of select="AlarmInputUID" /></HWUID>
        </Input>
        <Input>
          <Position>pipTamper</Position>
          <HWUID><xsl:value-of select="TamperInputUID" /></HWUID>
        </Input>
      </Inputs>
    </VirtualWindow>    
  </xsl:template>
  
  <xsl:template match="InternalDataSet/VirtualSounder">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>
    <VirtualSounder UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">      
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalSirenUID" /></HWUID>      
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>      
    </VirtualSounder>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/VirtualFlasher">
    <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>
    <VirtualFlasher UID="{UID}" Type="{/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalOutputUID" /></HWUID>    
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$DeviceUID]/Owner" /></Owner>	  
    </VirtualFlasher>
  </xsl:template>  

  <xsl:template match="InternalDataSet/VirtualReader">       
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <VirtualUserInterface UID="{$UID}" Type="ccVirtualReader">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$UID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalReaderUID" /></HWUID>
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$UID]/Owner" /></Owner>		  
    </VirtualUserInterface>    
  </xsl:template>
           
  <xsl:template match="InternalDataSet/VirtualKeyboard">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <VirtualUserInterface UID="{$UID}" Type="ccVirtualKeyboard">      
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$UID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalKeyboardUID" /></HWUID>
	  <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$UID]/Owner" /></Owner>		      
    </VirtualUserInterface>    
  </xsl:template>
  
  <xsl:template match="InternalDataSet/VirtualKeyboardReader">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <VirtualUserInterface UID="{$UID}" Type="ccVirtualKeyboardReader">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$UID]/Name" /></Name>      
      <HWUID><xsl:value-of select="LogicalKeyboardReaderUID" /></HWUID>      
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$UID]/Owner" /></Owner>		
    </VirtualUserInterface>      
  </xsl:template>
  
  <xsl:template match="InternalDataSet/VirtualDSDevice">
    <xsl:variable name="UID" select="UID" />
    <VirtualDSDevice UID="{$UID}" Type="ccVirtualDSDevice">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$UID]/Name" /></Name>      
      <HWUID><xsl:value-of select="LogicalDSAlarmReportingUID" /></HWUID>      
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$UID]/Owner" /></Owner>		
    </VirtualDSDevice>            
  </xsl:template>
  
  <xsl:template match="InternalDataSet/VirtualTemperature" >
    <xsl:variable name="UID" select="UID" />
    <VirtualTemperature UID="{$UID}" Type="ccVirtualTemperature">
      <Name><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$UID]/Name" /></Name>      
      <HWUID><xsl:value-of select="LogicalTemperatureUID" /></HWUID>          
      <Owner><xsl:value-of select="/InternalDataSet/VirtualDevice[UID=$UID]/Owner" /></Owner>		
    </VirtualTemperature>  
  </xsl:template>
  
  <xsl:template match="InternalDataSet/Partition">
    <Partition UID="{UID}" Type="{Type}">
      <xsl:variable name="PartitionUID"><xsl:value-of select="UID" /></xsl:variable>            
      <Name><xsl:value-of select="Name" /></Name>    
      <PartitionType><xsl:value-of select="PartitionType" /></PartitionType>
      <Omit><xsl:value-of select="Omit" /></Omit>
      <DoorLockingWait><xsl:value-of select="DoorLockingWait" /></DoorLockingWait>
      <xsl:if test="AlarmIndicationDelayTime>0">
      <AlarmIndicationDelay>
        <Time><xsl:value-of select="AlarmIndicationDelayTime" /></Time>
      </AlarmIndicationDelay>
      </xsl:if>
      <xsl:if test="/InternalDataSet/PMCollection[Owner=$PartitionUID and Type='ccPMCollectionEntryRoute']">
      <Entry>
        <Time><xsl:value-of select="EntryTime" /></Time>
        <PreWarnTime><xsl:value-of select="EntryPreWarnTime" /></PreWarnTime>
        <SounderType><xsl:value-of select="EntrySounderType" /></SounderType>        
        <SounderStyle><xsl:value-of select="EntrySounderStyle" /></SounderStyle>
        <PreWarnSounderStyle><xsl:value-of select="EntryPreWarnSounderStyle" /></PreWarnSounderStyle>
        <AlarmSounderStyle><xsl:value-of select="EntryAlarmSounderStyle" /></AlarmSounderStyle>
      </Entry>
      </xsl:if>
      <xsl:if test="/InternalDataSet/PMCollection[Owner=$PartitionUID and Type='ccPMCollectionExitRoute']">
      <Exit>
        <Time><xsl:value-of select="ExitTime" /></Time>
        <PreWarnTime><xsl:value-of select="ExitPreWarnTime" /></PreWarnTime>
        <SounderType><xsl:value-of select="ExitSounderType" /></SounderType>
        <SounderStyle><xsl:value-of select="ExitSounderStyle" /></SounderStyle>        
        <PreWarnSounderStyle><xsl:value-of select="ExitPreWarnSounderStyle" /></PreWarnSounderStyle>
      </Exit>
      </xsl:if>
      <xsl:if test="FullAlarmTime">
      <FullAlarm>
        <Time><xsl:value-of select="FullAlarmTime" /></Time>
      </FullAlarm>      
      </xsl:if>
      <xsl:if test="LocalAlarmTime">
      <LocalAlarm>
        <Time><xsl:value-of select="LocalAlarmTime" /></Time>
        <SounderType><xsl:value-of select="LocalAlarmSounderType" /></SounderType>
        <SounderStyle><xsl:value-of select="LocalAlarmSounderStyle" /></SounderStyle>
      </LocalAlarm>
      </xsl:if>
      <xsl:if test="FullSetConfirmTime">
      <FullSetConfirm>
        <Time><xsl:value-of select="FullSetConfirmTime" /></Time>
        <SounderType><xsl:value-of select="FullSetConfirmSounderType" /></SounderType>
        <SounderStyle><xsl:value-of select="FullSetConfirmSounderStyle" /></SounderStyle>              
      </FullSetConfirm>
      </xsl:if>
      <xsl:if test="PartSetDelayTime">
      <PartSetDelay>     
        <Time><xsl:value-of select="PartSetDelayTime" /></Time>
        <SounderType><xsl:value-of select="PartSetDelaySounderType" /></SounderType>
        <SounderStyle><xsl:value-of select="PartSetDelaySounderStyle" /></SounderStyle>
      </PartSetDelay>      
      </xsl:if>
      <xsl:if test="UnsetPreventionTime">
      <UnsetPrevention>
        <Time><xsl:value-of select="UnsetPreventionTime" /></Time>
        <AlarmTime><xsl:value-of select="UnsetPreventionAlarmTime" /></AlarmTime>                        
        <AlarmTypes>
          <xsl:for-each select="/InternalDataSet/UnsetPreventionAlarmType[PartitionUID=$PartitionUID]">
            <AlarmType><xsl:value-of select="AlarmType" /></AlarmType>          
          </xsl:for-each>
        </AlarmTypes>
      </UnsetPrevention>            
      </xsl:if>
      <xsl:if test="AlarmReportingWaitTime">
      <AlarmReportingWait>
        <Time><xsl:value-of select="AlarmReportingWaitTime" /></Time>
        <AlarmTypes>
          <xsl:if test="AlarmReportingIntruder='true'"><AlarmType>atIntruder</AlarmType></xsl:if>
          <xsl:if test="AlarmReportingTamper='true'"><AlarmType>atTamper</AlarmType></xsl:if>
          <xsl:if test="AlarmReportingPanic='true'"><AlarmType>atPanic</AlarmType></xsl:if>
          <xsl:if test="AlarmReportingFire='true'"><AlarmType>atFire</AlarmType></xsl:if>
          <xsl:if test="AlarmReportingTechnical='true'"><AlarmType>atTechnical</AlarmType></xsl:if>          
        </AlarmTypes>      
      </AlarmReportingWait>      
      </xsl:if>
      <xsl:if test="ExternalSignallingWaitTime">
      <ExternalSignallingWait>
        <Time><xsl:value-of select="ExternalSignallingWaitTime" /></Time>
        <AlarmTypes>
          <xsl:if test="ExternalSignallingIntruder='true'"><AlarmType>atIntruder</AlarmType></xsl:if>
          <xsl:if test="ExternalSignallingTamper='true'"><AlarmType>atTamper</AlarmType></xsl:if>
          <xsl:if test="ExternalSignallingPanic='true'"><AlarmType>atPanic</AlarmType></xsl:if>
          <xsl:if test="ExternalSignallingFire='true'"><AlarmType>atFire</AlarmType></xsl:if>
          <xsl:if test="ExternalSignallingTechnical='true'"><AlarmType>atTechnical</AlarmType></xsl:if>          
        </AlarmTypes>      
      </ExternalSignallingWait>
      </xsl:if>
      <xsl:if test="ClearWaitTime">
      <ClearWait>
        <Time><xsl:value-of select="ClearWaitTime" /></Time>
      </ClearWait>
      </xsl:if>
      <Sounders>
        <xsl:for-each select="/InternalDataSet/Partition_LocalSounder[PartitionUID=$PartitionUID]">
          <UID><xsl:value-of select="LocalSounderUID" /></UID>        
        </xsl:for-each>      
      </Sounders>                       
      <ExternalSounderStyles>
        <xsl:for-each select="/InternalDataSet/ExternalSounderStyle[PartitionUID=$PartitionUID]">        
        <xsl:if test="FireAlarmSounderStyle">
        <ExternalSounderStyle>
          <AlarmType>atFire</AlarmType>
          <SounderStyle><xsl:value-of select="FireAlarmSounderStyle" /></SounderStyle>
          <SounderTemplate><xsl:value-of select="FireAlarmSounderTemplateUID" /></SounderTemplate>        	
        </ExternalSounderStyle>         
        </xsl:if>
        <xsl:if test="PanicAlarmSounderStyle">             
        <ExternalSounderStyle>
          <AlarmType>atPanic</AlarmType>
          <SounderStyle><xsl:value-of select="PanicAlarmSounderStyle" /></SounderStyle>
          <SounderTemplate><xsl:value-of select="PanicAlarmSounderTemplateUID" /></SounderTemplate>        	
        </ExternalSounderStyle>             
        </xsl:if>
        <xsl:if test="IntruderAlarmSounderStyle">            
        <ExternalSounderStyle>
          <AlarmType>atIntruder</AlarmType>
          <SounderStyle><xsl:value-of select="IntruderAlarmSounderStyle" /></SounderStyle>
          <SounderTemplate><xsl:value-of select="IntruderAlarmSounderTemplateUID" /></SounderTemplate>        	
        </ExternalSounderStyle>             
        </xsl:if>
        <xsl:if test="TamperAlarmSounderStyle">         
        <ExternalSounderStyle>
          <AlarmType>atTamper</AlarmType>
          <SounderStyle><xsl:value-of select="TamperAlarmSounderStyle" /></SounderStyle>
          <SounderTemplate><xsl:value-of select="TamperAlarmSounderTemplateUID" /></SounderTemplate>        	
        </ExternalSounderStyle>    
        </xsl:if>                                  
        <xsl:if test="TechnicalAlarmSounderStyle">         
        <ExternalSounderStyle>
          <AlarmType>atTechnical</AlarmType>
          <SounderStyle><xsl:value-of select="TechnicalAlarmSounderStyle" /></SounderStyle>
          <SounderTemplate><xsl:value-of select="TechnicalAlarmSounderTemplateUID" /></SounderTemplate>        	
        </ExternalSounderStyle>    
        </xsl:if>                                          
        </xsl:for-each>            
      </ExternalSounderStyles>            
      <ExternalSignallingGroups>
        <xsl:for-each select="/InternalDataSet/Partition_SignalingGroup[PartitionUID=$PartitionUID]">
          <UID><xsl:value-of select="SignalingGroupUID" /></UID>
        </xsl:for-each>                                    
      </ExternalSignallingGroups>  
      <xsl:if test="count(/InternalDataSet/StoredFaultType[PartitionUID=$PartitionUID])>0">          
        <FaultTypes>
          <Stored>
            <xsl:for-each select="/InternalDataSet/StoredFaultType[PartitionUID=$PartitionUID]">
              <FaultType><xsl:value-of select="FaultType" /></FaultType>
            </xsl:for-each>
          </Stored>
        </FaultTypes>   
      </xsl:if>
      <!-- partition dependencies 1:N (possible to display in treeview)
      <xsl:if test="count(/InternalDataSet/Partition[ParentPartitionUID=$PartitionUID])>0">
        <DependencyChild>
          <xsl:for-each select="/InternalDataSet/Partition[ParentPartitionUID=$PartitionUID]">
            <UID><xsl:value-of select="UID" /></UID>
          </xsl:for-each>                                      
        </DependencyChild>
      </xsl:if>            
      <xsl:if test="ParentPartitionUID>0">
        <DependencyParent>
          <UID><xsl:value-of select="ParentPartitionUID" /></UID>             
        </DependencyParent>           
      </xsl:if>         
      -->
      <!-- partition dependencies N:M (possible to display in assignment editor -->
      <DependencyChildren>
      	<xsl:for-each select="/InternalDataSet/PartitionDependency[ParentPartitionUID=$PartitionUID]">
      	  <UID><xsl:value-of select="ChildPartitionUID" /></UID>
      	</xsl:for-each>
      </DependencyChildren>
      <DependencyParents>
		<xsl:for-each select="/InternalDataSet/PartitionDependency[ChildPartitionUID=$PartitionUID]">
		  <UID><xsl:value-of select="ParentPartitionUID" /></UID>
		</xsl:for-each>
      </DependencyParents>
      <Fault>
        <Time><xsl:value-of select="FaultTime" /></Time>
        <SounderType><xsl:value-of select="FaultSounderType" /></SounderType>
        <SounderStyle><xsl:value-of select="FaultSounderStyle" /></SounderStyle>
        <Sounding>
          <!-- finds SoundingFaultType for with the same PartitionUID and iterates all its columns with prefix "ft" -->
          <xsl:for-each select="/InternalDataSet/SoundingFaultTypes[PartitionUID=$PartitionUID]/*[starts-with(name(),'ft')]">
            <xsl:if test=".='true'">
              <FaultType><xsl:value-of select="name()" /></FaultType>            
            </xsl:if>                        
          </xsl:for-each>                         
        </Sounding>
        <Stored>
          <!-- finds StoredFaultType for with the same PartitionUID and iterates all its columns with prefix "ft" -->
          <xsl:for-each select="/InternalDataSet/StoredFaultTypes[PartitionUID=$PartitionUID]/*[starts-with(name(),'ft')]">
            <xsl:if test=".='true'">
              <FaultType><xsl:value-of select="name()" /></FaultType>            
            </xsl:if>                        
          </xsl:for-each>        
        </Stored>      
      </Fault>      
    </Partition>          
  </xsl:template>
  
  
  <xsl:template match="InternalDataSet/SignalingGroup">  
    <ExternalSignallingGroup UID="{UID}">
      <Name><xsl:value-of select="Name" /></Name>
      <Exclusive><xsl:value-of select="Exclusive" /></Exclusive>
      <AlarmPriority><xsl:value-of select="AlarmPriority" /></AlarmPriority>
      <Overwrite><xsl:value-of select="Overwrite" /></Overwrite>            
      <xsl:variable name="GroupUID"><xsl:value-of select="UID" /></xsl:variable>
      <Sounders>
        <xsl:for-each select="/InternalDataSet/SignalingGroup_Sounder[SignalingGroupUID=$GroupUID]">
          <UID><xsl:value-of select="SounderUID" /></UID>
        </xsl:for-each>
      </Sounders>
      <Flashers>
        <xsl:for-each select="/InternalDataSet/SignalingGroup_Flasher[SignalingGroupUID=$GroupUID]">
          <UID><xsl:value-of select="FlasherUID" /></UID>
        </xsl:for-each>
      </Flashers>
    </ExternalSignallingGroup>            
  </xsl:template>
  
  <xsl:template match="InternalDataSet/DetectorGroup">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>    
    <DetectorGroup UID="{UID}" Type="{/InternalDataSet/PartitionMember[UID=$UID]/Type}">
      <xsl:for-each select="/InternalDataSet/PartitionMember[UID=$UID]">
        <Name><xsl:value-of select="Name" /></Name>
        <Owner><xsl:value-of select="Owner" /></Owner>
        <ReadySetType><xsl:value-of select="ReadySetType" /></ReadySetType>
        <AlarmSetType><xsl:value-of select="AlarmSetType" /></AlarmSetType>
        <Omit><xsl:value-of select="Omit" /></Omit>
        <AlertingType><xsl:value-of select="AlertingType" /></AlertingType>
        <AlertingTypeFullSet><xsl:value-of select="AlertingTypeFullSet" /></AlertingTypeFullSet>
        <AlarmDeleteType><xsl:value-of select="AlarmDeleteType" /></AlarmDeleteType>
        <FaultReadySetType><xsl:value-of select="FaultReadySetType" /></FaultReadySetType>
        <FaultAlarmSetType><xsl:value-of select="FaultAlarmSetType" /></FaultAlarmSetType>
        <FaultDeleteType><xsl:value-of select="FaultDeleteType" /></FaultDeleteType>
        <AlarmRepeatCount><xsl:value-of select="AlarmRepeatCount" /></AlarmRepeatCount>
        <UnsetPrevention><xsl:value-of select="UnsetPrevention" /></UnsetPrevention>                                        
        <ClearAlarmReleased><xsl:value-of select="ClearAlarmReleased" /></ClearAlarmReleased>
      </xsl:for-each>      
      <PartSetDelayPostTrigger><xsl:value-of select="PartSetDelayPostTrigger" /></PartSetDelayPostTrigger>
      <AutomaticClear><xsl:value-of select="AutomaticClear" /></AutomaticClear>
      <ReleaseDelay><xsl:value-of select="ReleaseDelay" /></ReleaseDelay>
      <NormalDelay><xsl:value-of select="NormalDelay" /></NormalDelay>
      <ReleaseDelayTime><xsl:value-of select="ReleaseDelayTime" /></ReleaseDelayTime>
      <NormalDelayTime><xsl:value-of select="NormalDelayTime" /></NormalDelayTime>      
      <VerifiedAlarmTime><xsl:value-of select="VerifiedAlarmTime" /></VerifiedAlarmTime>
      <VerifiedPreWarnTime><xsl:value-of select="VerifiedPreWarnTime" /></VerifiedPreWarnTime>
      <SounderStyle><xsl:value-of select="SounderStyle" /></SounderStyle>
      <SounderTemplate><xsl:value-of select="SounderTemplateUID" /></SounderTemplate>
    </DetectorGroup>
  </xsl:template>

  <xsl:template match="InternalDataSet/AccessPoint">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>    
    <AccessPoint UID="{UID}" Type="{/InternalDataSet/PartitionMember[UID=$UID]/Type}">
      <xsl:for-each select="/InternalDataSet/PartitionMember[UID=$UID]">
        <Name><xsl:value-of select="Name" /></Name>
        <Owner><xsl:value-of select="Owner" /></Owner>
        <ReadySetType><xsl:value-of select="ReadySetType" /></ReadySetType>
        <AlarmSetType><xsl:value-of select="AlarmSetType" /></AlarmSetType>
        <Omit><xsl:value-of select="Omit" /></Omit>
        <AlertingType><xsl:value-of select="AlertingType" /></AlertingType>
        <AlertingTypeFullSet><xsl:value-of select="AlertingTypeFullSet" /></AlertingTypeFullSet>
        <AlarmDeleteType><xsl:value-of select="AlarmDeleteType" /></AlarmDeleteType>
        <FaultReadySetType><xsl:value-of select="FaultReadySetType" /></FaultReadySetType>
        <FaultAlarmSetType><xsl:value-of select="FaultAlarmSetType" /></FaultAlarmSetType>
        <FaultDeleteType><xsl:value-of select="FaultDeleteType" /></FaultDeleteType>
        <AlarmRepeatCount><xsl:value-of select="AlarmRepeatCount" /></AlarmRepeatCount>
        <UnsetPrevention><xsl:value-of select="UnsetPrevention" /></UnsetPrevention>
        <ClearAlarmReleased><xsl:value-of select="ClearAlarmReleased" /></ClearAlarmReleased>
      </xsl:for-each>
      <DoorReleaseTime><xsl:value-of select="DoorReleaseTime" /></DoorReleaseTime>
      <CodeData><xsl:value-of select="CodeData" /></CodeData>                
      <HWUID><xsl:value-of select="LogicalAccessPointUID" /></HWUID>      
      <Alarms>
        <Duress>
          <AlarmSetType><xsl:value-of select="DuressAlarmSetType" /></AlarmSetType>
          <AlertingType><xsl:value-of select="DuressAlertingType" /></AlertingType>
        </Duress>        
        <FailAttempt>
          <AlarmSetType><xsl:value-of select="FailAttemptAlarmSetType" /></AlarmSetType>
          <AlertingType><xsl:value-of select="FailAttemptAlertingType" /></AlertingType>
        </FailAttempt>
        <DoorTamper>
          <AlarmSetType><xsl:value-of select="DoorTamperAlarmSetType" /></AlarmSetType>
          <AlertingType><xsl:value-of select="DoorTamperAlertingType" /></AlertingType>
        </DoorTamper>
        <DoorOpenTime>
          <AlarmSetType><xsl:value-of select="DoorOpenTimeAlarmSetType" /></AlarmSetType>
          <AlertingType><xsl:value-of select="DoorOpenTimeAlertingType" /></AlertingType>
        </DoorOpenTime>      
      </Alarms>
      <OperatingModes>
        <Access><xsl:value-of select="ModeAccess" /></Access>
        <AccessAutomatic><xsl:value-of select="ModeAccessNoSchedule" /></AccessAutomatic>
        <FullSet><xsl:value-of select="ModeSet" /></FullSet>
        <PartSet><xsl:value-of select="ModePartSet" /></PartSet>
        <Unset><xsl:value-of select="ModeUnset" /></Unset>
        <Macro><xsl:value-of select="ModeMacro" /></Macro>            
        <QuickMacro><xsl:value-of select="ModeQuickMacro" /></QuickMacro>        
      </OperatingModes>      
      <!-- here is for-each loop, however usually here will be only one MultiplePersonAccess item -->
      <xsl:for-each select="/InternalDataSet/MultiplePersonAccess[AccessPoint_UID=$UID]">      
        <MultiplePersonAccess>
          <MPALimit><xsl:value-of select="MPALimit" /></MPALimit> 
        </MultiplePersonAccess>            
      </xsl:for-each>                      
      <!-- here is for-each loop, however usually here will be only one FaultTries item -->
      <xsl:for-each select="/InternalDataSet/FailAttempt[AccessPoint_UID=$UID]">
        <FailAttempt>
          <Limit><xsl:value-of select="Limit" /></Limit>
          <DeactivateAccess><xsl:value-of select="DeactivateAccess" /></DeactivateAccess>
          <DeactivateMacros><xsl:value-of select="DeactivateMacros" /></DeactivateMacros>
          <LockoutTime><xsl:value-of select="LockoutTime" /></LockoutTime>     		
        </FailAttempt>      
      </xsl:for-each>                
      <Macros>            
        <xsl:for-each select="/InternalDataSet/APQuickMacro[AccessPointUID=$UID]">
          <QuickMacro>
            <MacroKey><xsl:value-of select="Key" /></MacroKey>
            <UID><xsl:value-of select="MacroUID" /></UID>                    
          </QuickMacro>       
        </xsl:for-each>
        <xsl:for-each select="/InternalDataSet/APMacro[AccessPointUID=$UID]">
          <Macro>
            <MacroCode><xsl:value-of select="Code" /></MacroCode>
            <UID><xsl:value-of select="MacroUID" /></UID>          
          </Macro>      
        </xsl:for-each>      
      </Macros>            
      <Users>
        <xsl:for-each select="/InternalDataSet/AccessPoint_User[AccessPointUID=$UID]">
          <User><xsl:value-of select="UserUID" /></User>
        </xsl:for-each>
      </Users>                         
      <xsl:for-each select="/InternalDataSet/APTurnstile[AccessPointUID=$UID]">
        <Turnstile>
          <Type><xsl:value-of select="Type" /></Type>
          <Output>
            <Position>dopOpenerRelais</Position>
            <HWUID><xsl:value-of select="OpenerRelayOutputUID" /></HWUID>
          </Output>
          <Input>
            <Position>dipLatchContact</Position>
            <HWUID><xsl:value-of select="LatchContactInputUID" /></HWUID>
          </Input>                
        </Turnstile>      
      </xsl:for-each>            
    </AccessPoint>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/PMCollectionDependency">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <PMCollection UID="{$UID}" Type="ccPMCollectionDependency">
      <xsl:for-each select="/InternalDataSet/PMCollection[UID=$UID]">      
        <Name><xsl:value-of select="Name" /></Name>
		<Owner><xsl:value-of select="Owner" /></Owner>
        <Order><xsl:value-of select="Order" /></Order>        
        <ReleaseStorage><xsl:value-of select="ReleaseStorage" /></ReleaseStorage>
        <ReleaseStorageTime><xsl:value-of select="ReleaseStorageTime" /></ReleaseStorageTime>              
      </xsl:for-each>
      <All><xsl:value-of select="All" /></All>
      <Min><xsl:value-of select="Min" /></Min>
      <AlarmPeriod><xsl:value-of select="AlarmPeriod" /></AlarmPeriod>      
      <PMs>
        <xsl:for-each select="/InternalDataSet/PMCollection_PartitionMember[PMCollectionUID=$UID]">      
          <PM>
            <Number><xsl:value-of select="Number" /></Number>
            <UID><xsl:value-of select="PartitionMemberUID" /></UID>
          </PM>
        </xsl:for-each>      
      </PMs>            
    </PMCollection>      
  </xsl:template>  
  
  <xsl:template match="InternalDataSet/PMCollectionEntryRoute">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <PMCollection UID="{$UID}" Type="ccPMCollectionEntryRoute">
      <xsl:for-each select="/InternalDataSet/PMCollection[UID=$UID]">      
        <Name><xsl:value-of select="Name" /></Name>        
        <Owner><xsl:value-of select="Owner" /></Owner>        
        <Order><xsl:value-of select="Order" /></Order>
        <ReleaseStorage><xsl:value-of select="ReleaseStorage" /></ReleaseStorage>
        <ReleaseStorageTime><xsl:value-of select="ReleaseStorageTime" /></ReleaseStorageTime>              
      </xsl:for-each>   
      <PMs>
        <xsl:for-each select="/InternalDataSet/PMCollection_PartitionMember[PMCollectionUID=$UID]">      
          <PM>
            <Number><xsl:value-of select="position()" /></Number>
            <UID><xsl:value-of select="PartitionMemberUID" /></UID>
          </PM>
        </xsl:for-each>      
      </PMs>            
    </PMCollection>  
  </xsl:template>
    
  <xsl:template match="InternalDataSet/PMCollectionExitRoute">  
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <PMCollection UID="{$UID}" Type="ccPMCollectionExitRoute">
      <xsl:for-each select="/InternalDataSet/PMCollection[UID=$UID]">      
        <Name><xsl:value-of select="Name" /></Name>        
        <Owner><xsl:value-of select="Owner" /></Owner>        
        <Order><xsl:value-of select="Order" /></Order>
        <ReleaseStorage><xsl:value-of select="ReleaseStorage" /></ReleaseStorage>
        <ReleaseStorageTime><xsl:value-of select="ReleaseStorageTime" /></ReleaseStorageTime>      
      </xsl:for-each>     
      <PMs>
        <xsl:for-each select="/InternalDataSet/PMCollection_PartitionMember[PMCollectionUID=$UID]">      
          <PM>
            <Number><xsl:value-of select="position()" /></Number>
            <UID><xsl:value-of select="PartitionMemberUID" /></UID>
          </PM>
        </xsl:for-each>      
      </PMs>            
    </PMCollection>    
  </xsl:template>  
  
  <xsl:template match="InternalDataSet/Holiday"> 
    <Holiday UID="{UID}" Type="ccHoliday">
      <xsl:if test="Type!='htFullDay'">      
         <xsl:attribute name="HolidayType"><xsl:value-of select="Type" /></xsl:attribute>
      </xsl:if>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:choose>
        <xsl:when test="Yearly='true'">
          <Date><xsl:value-of select="concat('0000',substring(Day,5,6))" /></Date>              
        </xsl:when>
        <xsl:otherwise>
          <Date><xsl:value-of select="substring(Day,1,10)" /></Date>
        </xsl:otherwise>
      </xsl:choose>
    </Holiday>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/TimeSchedule">  
    <xsl:variable name="TimeScheduleUID" select="UID" />
    <!-- xml tags are created only when timeschedule contains at least one valid time period  -->
    <xsl:if test="count(/InternalDataSet/TimePeriod[TimeScheduleUID=$TimeScheduleUID and Enabled='true'])>0">
      <TimeSchedule UID="{UID}" Type="ccTimeSchedule">
        <Name><xsl:value-of select="Name" /></Name>
        <ExpiredDay><xsl:value-of select="ExpiredDay" /></ExpiredDay>
        <Weekdays>
          <xsl:if test="Monday='true'"><Weekday>dowMonday</Weekday></xsl:if>
          <xsl:if test="Tuesday='true'"><Weekday>dowTuesday</Weekday></xsl:if>
          <xsl:if test="Wednesday='true'"><Weekday>dowWednesday</Weekday></xsl:if>
          <xsl:if test="Thursday='true'"><Weekday>dowThursday</Weekday></xsl:if>
          <xsl:if test="Friday='true'"><Weekday>dowFriday</Weekday></xsl:if>
          <xsl:if test="Saturday='true'"><Weekday>dowSaturday</Weekday></xsl:if>
          <xsl:if test="Sunday='true'"><Weekday>dowSunday</Weekday></xsl:if>
          <xsl:if test="Holiday='true'"><Weekday>dowHoliday</Weekday></xsl:if>
        </Weekdays>
        <TimePeriods>
          <xsl:for-each select="/InternalDataSet/TimePeriod[TimeScheduleUID=$TimeScheduleUID and Enabled='true']">
            <TimePeriod>
              <StartTime>
                <xsl:choose>
                  <xsl:when test="contains(StartTime,'T')"><xsl:value-of select="substring(StartTime,12,8)" /></xsl:when>
                  <xsl:otherwise><xsl:value-of select="StartTime" /></xsl:otherwise>
                </xsl:choose>          
              </StartTime>
              <EndTime>
               <xsl:choose>
                 <xsl:when test="contains(EndTime,'T')"><xsl:value-of select="substring(EndTime,12,8)" /></xsl:when>
                 <xsl:otherwise><xsl:value-of select="EndTime" /></xsl:otherwise>
                </xsl:choose>          
              </EndTime>            
            </TimePeriod>
          </xsl:for-each>
        </TimePeriods>
      </TimeSchedule>
    </xsl:if>
  </xsl:template>
  
  <xsl:template name="InsertSchedules">
    <!-- each usergroup is linked with one schedule (simplified approach of MB panel)
         data for Schedule are read from various tables (Schedule table does not exist)
     -->    
    <xsl:for-each select="/InternalDataSet/UserGroup">
      <xsl:variable name="UserGroupUID" select="UID" />
      <xsl:variable name="ScheduleUID" select="ScheduleUID" />
      <Schedule UID="{$ScheduleUID}">
        <xsl:attribute name="Type"><!-- Type attribute depends on flags "UseCalendar" and "Priority" -->
          <xsl:choose>
            <xsl:when test="UseCalendar='false'">ccSchedule</xsl:when>
            <xsl:when test="UseCalendar='true' and Priority='false'">ccDateSchedule</xsl:when>
            <xsl:when test="UseCalendar='true' and Priority='true'">ccDateSchedulePriority</xsl:when>
          </xsl:choose>
        </xsl:attribute>        
        <Name>Schedule for RTZ <xsl:value-of select="UID" /></Name>
        <TimeSchedules>
          <xsl:for-each select="/InternalDataSet/UserGroup_TimeSchedule[UserGroupUID=$UserGroupUID]">
            <xsl:variable name="TimeScheduleUID" select="TimeScheduleUID" />
            <xsl:if test="count(/InternalDataSet/TimePeriod[TimeScheduleUID=$TimeScheduleUID and Enabled='true'])>0">
              <TimeSchedule><xsl:value-of select="TimeScheduleUID" /></TimeSchedule>
            </xsl:if>
          </xsl:for-each> 
        </TimeSchedules>        
        <!-- DatePeriods tag is not necessary when UseCalendar='false' -->
        <xsl:if test="count(/InternalDataSet/DatePeriod[UserGroupUID=$UserGroupUID])>0">
          <DatePeriods>
            <xsl:for-each select="/InternalDataSet/DatePeriod[UserGroupUID=$UserGroupUID]">
              <DatePeriod>
                <StartDate>
                  <xsl:choose>
                    <xsl:when test="contains(StartDate,'T')"><xsl:value-of select="substring-before(StartDate,'T')" /></xsl:when>
                    <xsl:otherwise><xsl:value-of select="StartDate" /></xsl:otherwise>  
                  </xsl:choose>                       
                </StartDate>
                <EndDate>
                   <xsl:choose>              
                    <xsl:when test="contains(EndDate,'T')"><xsl:value-of select="substring-before(EndDate,'T')" /></xsl:when>
                    <xsl:otherwise><xsl:value-of select="EndDate" /></xsl:otherwise>      
                  </xsl:choose>
                </EndDate>     
                <Yearly><xsl:value-of select="Yearly" /></Yearly>                  
              </DatePeriod>
            </xsl:for-each>
          </DatePeriods>
        </xsl:if>
      </Schedule>    
    </xsl:for-each>    
  </xsl:template>


  <xsl:template name="InsertScheduledItems">   
    <xsl:for-each select="/InternalDataSet/ScheduledItem">
      <xsl:variable name="ScheduledItemUID" select="UID" />
      <xsl:variable name="ScheduledItemType" select="Type" />
      <ScheduledItem UID="{UID}" Type="{Type}">            
        <Name><xsl:value-of select="Name" /></Name>                       
        <xsl:variable name="UserGroupUID" select="/InternalDataSet/UserGroup_ScheduledItem[ScheduledItemUID=$ScheduledItemUID]/UserGroupUID" />
        <xsl:variable name="ScheduleUID" select="/InternalDataSet/UserGroup[UID=$UserGroupUID]/ScheduleUID" />
        <Schedule><xsl:value-of select="$ScheduleUID" /></Schedule>
        <xsl:choose>
          <!-- RTZ part -->
          <xsl:when test="$ScheduledItemType='ccScheduledAccessPointGroup'">
            <AccessPoints>    
            <xsl:for-each select="/InternalDataSet/ScheduledItem_APGroup[ScheduledItemUID=$ScheduledItemUID]">  
              <AccessPoint UID="{AccessPointUID}">
                <Privileges>
                  <xsl:for-each select="*[starts-with(name(),'pid')]">
                    <xsl:variable name="val" select="." />
                    <xsl:if test="$val='true'">
                      <Privilege><xsl:value-of select="name()" /></Privilege>
                    </xsl:if>                                
                  </xsl:for-each>              
                </Privileges>
              </AccessPoint>                                                      
            </xsl:for-each>
            </AccessPoints>
          </xsl:when>
          <!-- AccessControMode part -->
          <xsl:when test="$ScheduledItemType='ccScheduledAccessControlMode'">
            <ControlMode><xsl:value-of select="ControlMode" /></ControlMode>
            <AccessPoints>
            <xsl:for-each select="/InternalDataSet/ScheduledItem_AP[(ScheduledItemUID=$ScheduledItemUID) and (Valid='true')]">
              <AccessPoint><xsl:value-of select="AccessPointUID" /></AccessPoint>
            </xsl:for-each>
            </AccessPoints>
          </xsl:when>
          <xsl:when test="$ScheduledItemType='ccScheduledDoorControlMode'">
            <ControlMode><xsl:value-of select="ControlMode" /></ControlMode>
            <Doors>
              <xsl:for-each select="/InternalDataSet/ScheduledItem_Door[ScheduledItemUID=$ScheduledItemUID]">
                <Door><xsl:value-of select="DoorUID" /></Door>
              </xsl:for-each>
            </Doors>   
          </xsl:when>
          <xsl:when test="$ScheduledItemType='ccScheduledPartition'">
            <UIProxies>
              <xsl:for-each select="/InternalDataSet/ScheduledItem_UIProxy[ScheduledItemUID=$ScheduledItemUID]">
                <UIProxy><xsl:value-of select="UIProxyUID" /></UIProxy>
              </xsl:for-each>
            </UIProxies>
          </xsl:when>
          <xsl:when test="$ScheduledItemType='ccScheduledPartition'">
            <Partitions>
              <xsl:for-each select="/InternalDataSet/ScheduledItem_Partition[ScheduledItemUID=$ScheduledItemUID]">
                <Partition><xsl:value-of select="PartitionUID" /></Partition>
              </xsl:for-each>
            </Partitions>
          </xsl:when>
        </xsl:choose>
      </ScheduledItem>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="InternalDataSet/UserGroup">
    <xsl:variable name="UserGroupUID" select="UID" />
    <UserGroup UID="{UID}" Type="ccUserGroup">
      <Name><xsl:value-of select="Name" /></Name>
      <Privileges>
        <xsl:for-each select="*[starts-with(name(),'pid')]">
          <xsl:variable name="val" select="." />
          <xsl:if test="$val='true'">
            <Privilege><xsl:value-of select="name()" /></Privilege>
          </xsl:if>
        </xsl:for-each>                 
      </Privileges>      
      <ScheduledItems>
        <xsl:for-each select="/InternalDataSet/UserGroup_ScheduledItem[UserGroupUID=$UserGroupUID]">
          <ScheduledItem><xsl:value-of select="ScheduledItemUID" /></ScheduledItem>
        </xsl:for-each>
      </ScheduledItems>      
    </UserGroup>
  </xsl:template>

  <xsl:template match="InternalDataSet/User">
    <xsl:variable name="UserUID" select="UID" />
    <User UID="{UID}" Type="ccUser">
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:if test="Enabled='false'">
        <Enabled>false</Enabled>
      </xsl:if>
      <CodeData><xsl:value-of select="CodeData" /></CodeData>
      <CardData><xsl:value-of select="CardData" /></CardData>
      <RFFobData><xsl:value-of select="RFFobData" /></RFFobData>
      <xsl:if test="UnlimitedValidity='false'">      
        <StartDate>
          <!-- two .net date formats are supported- including time and without time -->
          <xsl:choose>
            <xsl:when test="contains(ValidityStartDate,'T')"><xsl:value-of select="substring-before(ValidityStartDate,'T')" /></xsl:when>
            <xsl:otherwise><xsl:value-of select="ValidityStartDate" /></xsl:otherwise>            
          </xsl:choose>
        </StartDate>
        <EndDate>
          <xsl:choose>
            <xsl:when test="contains(ValidityEndDate,'T')"><xsl:value-of select="substring-before(ValidityEndDate,'T')" /></xsl:when>
            <xsl:otherwise><xsl:value-of select="ValidityEndDate" /></xsl:otherwise>            
          </xsl:choose>
        </EndDate>        
      </xsl:if>
      <EndDate></EndDate>
      <UserGroups>
        <xsl:for-each select="/InternalDataSet/User_UserGroup[UserUID=$UserUID]">
          <UserGroup><xsl:value-of select="UserGroupUID" /></UserGroup>                    
        </xsl:for-each>
      </UserGroups>
    </User>
  </xsl:template>

  <xsl:template match="InternalDataSet/Trigger">
    <Trigger UID="{UID}" Type="{Type}">
      <Name><xsl:value-of select="Name" /></Name>
      <GeneratorUID><xsl:value-of select="GeneratorUID" /></GeneratorUID>
      <EvRelease><xsl:value-of select="EvRelease" /></EvRelease>
      <SubEvRelease><xsl:value-of select="SubEvRelease" /></SubEvRelease>
      <xsl:if test="Type='ccTriggerSimple'">
        <EvNormal><xsl:value-of select="EvNormal" /></EvNormal>
        <SubEvNormal><xsl:value-of select="SubEvNormal" /></SubEvNormal>
      </xsl:if>
      <!-- finds data specific for one trigger type in extra table -->
      <xsl:variable name="UID">
        <xsl:value-of select="UID" />
      </xsl:variable>
      <xsl:for-each select="/InternalDataSet/*[starts-with(name(),'Trigger_') and (UID=$UID)]">
        <!-- and inserts all datacolumns from this extra table except UID -->
        <xsl:for-each select="*">
          <xsl:if test="name()!='UID'">
            <xsl:element name="{name()}"><xsl:value-of select="." /></xsl:element>
          </xsl:if>
        </xsl:for-each>
      </xsl:for-each>
    </Trigger>
  </xsl:template>

  <xsl:template match="InternalDataSet/Condition">
    <Condition UID="{UID}" Type="ccCondition">
      <Name>
        <xsl:value-of select="Name" />
      </Name>
      <xsl:variable name="ConditionUID" select="UID" />
      <xsl:variable name="RootUID" select="ExpressionRootUID" />
      <xsl:for-each select="/InternalDataSet/Expression[(ConditionUID=$ConditionUID) and (ExpressionUID=$RootUID)]">
        <xsl:call-template name="InsertExpression">
          <xsl:with-param name="ConditionUID" select="$ConditionUID" />
          <xsl:with-param name="TagName" select="'ExpressionRoot'" />
        </xsl:call-template>
      </xsl:for-each>
    </Condition>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/Signal">
    <Signal UID="{UID}" Type="{Type}">
      <Ref><xsl:value-of select="SourceUID" /></Ref>
      <xsl:if test="Inverted='true'">
      <Inverted><xsl:value-of select="Inverted" /></Inverted>
      </xsl:if>
      <xsl:if test="SingleEdge='true'">
        <SingleEdge><xsl:value-of select="SingleEdge" /></SingleEdge>
      </xsl:if>
      <xsl:if test="Impulse='true'">
        <Impulse><xsl:value-of select="Impulse" /></Impulse>
      </xsl:if>
    </Signal>  
  </xsl:template>

  <xsl:template name="InsertExpression">
    <xsl:param name="ConditionUID" />
    <xsl:param name="TagName" />
    <xsl:element name="{$TagName}">
      <xsl:attribute name="Type"><xsl:value-of select="Type" /></xsl:attribute>
      <xsl:if test="TriggerUID>0">
        <xsl:attribute name="TriggerRef">
          <xsl:value-of select="TriggerUID" />
        </xsl:attribute>
      </xsl:if>
      <!-- recursive calls for child expressions -->
      <xsl:variable name="ExpressionUID" select="ExpressionUID" />
      <xsl:for-each select="/InternalDataSet/Expression[(ConditionUID=$ConditionUID) and (ParentExpressionUID=$ExpressionUID)]">
        <xsl:call-template name="InsertExpression">
          <xsl:with-param name="ConditionUID" select="$ConditionUID" />
          <xsl:with-param name="TagName" select="'Expression'" />
        </xsl:call-template>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>

  <xsl:template match="InternalDataSet/Command">
    <Command UID="{UID}" Type="{Type}">
      <Name><xsl:value-of select="Name" /></Name>
      <ExecutorUID><xsl:value-of select="ExecutorUID" /></ExecutorUID>
      <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
      <!-- finds data specific for one command type in extra table -->
      <xsl:for-each select="/InternalDataSet/*[starts-with(name(),'Command_') and (UID=$UID)]">
        <!-- and inserts all datacolumns from this extra table except UID -->
        <xsl:for-each select="*">
          <xsl:if test="name()!='UID'">
            <xsl:element name="{name()}"><xsl:value-of select="." /></xsl:element>
          </xsl:if>
        </xsl:for-each>
      </xsl:for-each>
    </Command>
  </xsl:template>

  <xsl:template match="InternalDataSet/Action">
    <xsl:variable name="UID">
      <xsl:value-of select="UID" />
    </xsl:variable>
    <Action UID="{UID}" Type="ccAction">
      <Name><xsl:value-of select="Name" /></Name>
      <ActionList>
        <xsl:for-each select="/InternalDataSet/Action_Command[Action_UID=$UID]">
          <CommandRef><xsl:value-of select="Command_UID" /></CommandRef>
        </xsl:for-each>
      </ActionList>
    </Action>
  </xsl:template>

  <xsl:template match="InternalDataSet/Macro">
    <Macro UID="{UID}" Type="{Type}">
      <Name><xsl:value-of select="Name" /></Name>      
      <ConditionRef><xsl:value-of select="ConditionUID" /></ConditionRef>
      <ActionRef><xsl:value-of select="ActionOnUID" /></ActionRef>
      <xsl:if test="(Type='ccMacroToggle') or (Type='ccMacroDouble')">
        <ActionRef2><xsl:value-of select="ActionOffUID" /></ActionRef2>
      </xsl:if>
    </Macro>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/UITouchCenter">
    <xsl:variable name="ProxyUID" select="UID" />
    <UIProxy UID="{UID}" Type="{/InternalDataSet/UIProxy[UID=$ProxyUID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/UIProxy[UID=$ProxyUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalSmartUI_UID" /></HWUID>
      <Partitions>
        <xsl:for-each select="/InternalDataSet/UITouchCenter_Partition[UIProxyUID=$ProxyUID]">
          <UID><xsl:value-of select="PartitionUID" /></UID>
        </xsl:for-each>
      </Partitions>
      <Language><xsl:value-of select="Language" /></Language>
      <TamperPartition><xsl:value-of select="TamperPartitionUID" /></TamperPartition>
      <PreferedPartition><xsl:value-of select="PreferedPartitionUID" /></PreferedPartition>
      <AmountCodeInput><xsl:value-of select="AmountCodeInput" /></AmountCodeInput>
      <BlockingTime><xsl:value-of select="BlockingTime" /></BlockingTime>
      <OperatingTime><xsl:value-of select="OperatingTime" /></OperatingTime>
      <OperationWithCode><xsl:value-of select="OperationWithCode" /></OperationWithCode>
      <ViewWithCode><xsl:value-of select="ViewWithCode" /></ViewWithCode>
      <ViewOverview><xsl:value-of select="ViewOverview" /></ViewOverview>
      <AlarmLEDByFullSet><xsl:value-of select="AlarmLEDByFullSet" /></AlarmLEDByFullSet>
      <FullSetUnsetAllowed><xsl:value-of select="FullSetUnsetAllowed" /></FullSetUnsetAllowed>
      <PartSetUnsetAllowed><xsl:value-of select="PartSetUnsetAllowed" /></PartSetUnsetAllowed>
    </UIProxy>  
  </xsl:template>  
  
  <xsl:template name="InsertKeypads">
    <!-- keypads without owner are inserted as first -->
    <xsl:for-each select="/InternalDataSet/UIKeypad">
      <xsl:choose>
        <xsl:when test="OwnerKeypadUID">
          <!-- nothing to do -->
        </xsl:when>
        <xsl:otherwise> <!-- checks if xml tag does not exist, probably there is no other way how to that -->        
          <xsl:call-template name="InsertKeypad" />
        </xsl:otherwise>
      </xsl:choose>                
    </xsl:for-each>
    <!-- keypads with owner are inserted as second -->
    <xsl:for-each select="/InternalDataSet/UIKeypad">
      <xsl:if test="OwnerKeypadUID">
        <xsl:call-template name="InsertKeypad" />
      </xsl:if>    
    </xsl:for-each>         
  </xsl:template>  
  
  <xsl:template name="InsertKeypad">
    <xsl:variable name="ProxyUID" select="UID" />
    <UIProxy UID="{UID}" Type="{/InternalDataSet/UIProxy[UID=$ProxyUID]/Type}">    
      <Name><xsl:value-of select="/InternalDataSet/UIProxy[UID=$ProxyUID]/Name" /></Name>
      <HWUID><xsl:value-of select="LogicalKeyboardReaderUID" /></HWUID>
      <LDPeripheral><xsl:value-of select="LogicalPeripheralUID" /></LDPeripheral>
      <HWUIDDisplay><xsl:value-of select="LogicalDisplayUID" /></HWUIDDisplay>
      <Owner><xsl:value-of select="OwnerKeypadUID" /></Owner>      
      <OperatingTime><xsl:value-of select="OperatingTime" /></OperatingTime>
      <Indication><xsl:value-of select="Indication" /></Indication>
      <Operating><xsl:value-of select="Operating" /></Operating>
      <xsl:variable name="KeypadUID" select="UID" />
      <Items>
      <xsl:for-each select="/InternalDataSet/UIKeypadItem[UIKeypadUID=$KeypadUID]">
        <Item>
          <!-- common part -->
          <Number><xsl:value-of select="Number" /></Number>
          <Led><xsl:value-of select="LogicalLedUID" /></Led>
          <Function><xsl:value-of select="Function" /></Function>
          <Indication><xsl:value-of select="Indication" /></Indication>
          <xsl:choose>
            <xsl:when test="Function='kfNode'">
              <!-- no tags needed -->          
            </xsl:when>
            <xsl:when test="Function='kfSignal'">          
              <SignalRed><xsl:value-of select="RedLed_SignalUID" /></SignalRed>
              <SignalYellow><xsl:value-of select="YellowLed_SignalUID" /></SignalYellow>
              <SignalGreen><xsl:value-of select="GreenLed_SignalUID" /></SignalGreen>
            </xsl:when>          
            <xsl:otherwise>
              <Key><xsl:value-of select="LogicalKeyUID" /></Key>
              <Operating><xsl:value-of select="Operating" /></Operating>
              <Operating2><xsl:value-of select="Operating2" /></Operating2>
              <UID><xsl:value-of select="TargetDeviceUID" /></UID>           
            </xsl:otherwise>            
          </xsl:choose>              
        </Item>
      </xsl:for-each>
      </Items>
    </UIProxy>       
  </xsl:template>  
  
 
  <xsl:template match="InternalDataSet/RemoteApplication">    
    <RemoteApplication UID="{UID}" Type="{Type}">
      <Name><xsl:value-of select="Name" /></Name>
      <Port Hardware="Socket" IP="{IPAddress}" Port="{Port}" Type="{SocketType}" TCPUDP="{Protocol}" Blocking="{Blocking}" />
      <Interval><xsl:value-of select="Interval" /></Interval>
      <PassWD><xsl:value-of select="Password" /></PassWD>    
    </RemoteApplication>    
  </xsl:template>

  <xsl:template match="InternalDataSet/AlarmDevice">
    <AlarmDevice UID="{UID}" Type="{Type}">
      <Name><xsl:value-of select="Name" /></Name>
      <VirtualDSDevice><xsl:value-of select="VirtualDSDeviceUID" /></VirtualDSDevice>
      <Partition><xsl:value-of select="PartitionUID" /></Partition>
      <Description><xsl:value-of select="SendDescription" /></Description>
      <xsl:variable name="AlarmDeviceUID" select="UID" />
      <FaultPartitions>
        <xsl:for-each select="/InternalDataSet/AlarmDevice_FaultPartition[AlarmDeviceUID=$AlarmDeviceUID]">
          <UID><xsl:value-of select="PartitionUID" /></UID>
        </xsl:for-each>
      </FaultPartitions>
      <FaultTypes>
        <FaultType>
          <Type>ftCommFailure</Type>
          <Effect><xsl:value-of select="CommFailureEffect" /></Effect>
        </FaultType>
        <FaultType>
          <Type>ftWireFault</Type>
          <Effect><xsl:value-of select="WireFaultEffect" /></Effect>
        </FaultType>
      </FaultTypes>
      <Channels>
        <xsl:for-each select="/InternalDataSet/Channel[AlarmDeviceUID=$AlarmDeviceUID]">
          <xsl:choose>
            <xsl:when test="Type='Alarm'">
              <Channel Number="{Number}" Type="Alarm" Partition="{SignalUID}" AlarmType="{PartitionAlarmType}" Inverted="{Inverted}" SingleEdge="{SingleEdge}" Impulse="{Impulse}" />                   
            </xsl:when>
            <xsl:when test="Type='Signal'">
              <Channel Number="{Number}" Type="Signal" Ref="{SignalUID}" />                   
            </xsl:when>
            <xsl:otherwise>
              <!-- channels with empty type are not included into panel xml -->
            </xsl:otherwise>            
          </xsl:choose>        
        </xsl:for-each>      
      </Channels>
    </AlarmDevice>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/LogicalInput">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalInput UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalInput>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalOutput">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalOutput UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalOutput>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalPIR">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalPir UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalPir>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalSounder">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalSounder UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalSounder>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/SounderTemplate">  
    <SounderTemplate>
      <Number><xsl:value-of select="UID" /></Number>
      <Name><xsl:value-of select="Name" /></Name>
      <LowFrequency><xsl:value-of select="LowFrequency" /></LowFrequency>
      <HighFrequency><xsl:value-of select="HighFrequency" /></HighFrequency>
      <RiseTime><xsl:value-of select="RiseTime" /></RiseTime>
      <FallTime><xsl:value-of select="FallTime" /></FallTime>
      <RestingTimeLowFrequency><xsl:value-of select="RestingTimeLowFrequency" /></RestingTimeLowFrequency>
      <RestingTimeHighFrequency><xsl:value-of select="RestingTimeHighFrequency" /></RestingTimeHighFrequency>                
    </SounderTemplate>     
  </xsl:template>   

  <xsl:template match="InternalDataSet/LogicalEmail">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalEmail UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalEmail>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalSMS">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalSMS UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalSMS>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalReader">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalReader UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalReader>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalKey">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalKey UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalKey>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/LogicalKeyboard">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalKeyboard UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalKeyboard>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalKeyboardReader">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalKeyboardReader UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalKeyboardReader>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalKeypad">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalKeypad UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalKeypad>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/LogicalLed">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalLed UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalLed>
  </xsl:template>  

  <xsl:template match="InternalDataSet/LogicalSmartUI">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalSmartUI UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalSmartUI>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalCamera">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalCamera UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalCamera>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalCarbonMonoxide">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalCarbonMonoxide UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalCarbonMonoxide>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalDisplay">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalDisplay UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalDisplay>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalDoor">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalDoor UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalDoor>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalAccessPoint">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalAccessPoint UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalAccessPoint>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/LogicalDSAlarmReporting">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalDSAlarmReporting UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalDSAlarmReporting>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalEventBroadcaster">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalEventBroadcaster UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalEventBroadcaster>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/LogicalInstallService">   
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalInstallationService UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalInstallationService>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/LogicalPeripheral">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalPeripheral UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalPeripheral>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/LogicalWirelessPeripheral">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalRFPeripheral UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalRFPeripheral>
  </xsl:template>
  
  <xsl:template match="InternalDataSet/LogicalWirelessMaster">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalRFMaster UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalRFMaster>
  </xsl:template>  
  
  <xsl:template match="InternalDataSet/LogicalWirelessReceiver">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalRFReceiver UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalRFReceiver>
  </xsl:template>   

  <xsl:template match="InternalDataSet/LogicalSmokeDetector">
    <xsl:variable name="UID"><xsl:value-of select="UID" /></xsl:variable>
    <LogicalSmokeDetector UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalSmokeDetector>
  </xsl:template>

  <xsl:template match="InternalDataSet/LogicalTemperature">
    <xsl:variable name="UID" select="UID" />
    <LogicalTemperature UID="{UID}" Type="{/InternalDataSet/LogicalDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$UID]/Name" /></Name>
    </LogicalTemperature>
  </xsl:template>

  <xsl:template match="InternalDataSet/HWGPIOInput">
    <xsl:variable name="UID" select="UID" />
    <GPIOInput UID="{UID}" Type="{/InternalDataSet/HardwareDevice[UID=$UID]/Type}">      
      <Name><xsl:value-of select="/InternalDataSet/HardwareDevice[UID=$UID]/Name" /></Name>
      <Address><xsl:value-of select="/InternalDataSet/HardwareDevice[UID=$UID]/Address" /></Address>
      <LDUID><xsl:value-of select="LogicalInputUID" /></LDUID>
    </GPIOInput>
  </xsl:template>

  <xsl:template match="InternalDataSet/HWGPIOOutput">
    <xsl:variable name="UID" select="UID" />
    <GPIOOutput UID="{UID}" Type="{/InternalDataSet/HardwareDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/HardwareDevice[UID=$UID]/Name" /></Name>
      <Address><xsl:value-of select="/InternalDataSet/HardwareDevice[UID=$UID]/Address" /></Address>
      <LDUID><xsl:value-of select="LogicalOutputUID" /></LDUID>
    </GPIOOutput>
  </xsl:template>

  <xsl:template match="InternalDataSet/HWSPIInput">
    <xsl:variable name="UID" select="UID" />
    <SPIInput UID="{UID}" Type="{/InternalDataSet/HardwareDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/HardwareDevice[UID=$UID]/Name" /></Name>
      <Address><xsl:value-of select="/InternalDataSet/HardwareDevice[UID=$UID]/Address" /></Address>
      <LDUID><xsl:value-of select="LogicalInputUID" /></LDUID>    
    </SPIInput>
  </xsl:template>

  <xsl:template match="InternalDataSet/HWSPIOutput">
    <xsl:variable name="UID" select="UID" />
    <SPIOutput UID="{UID}" Type="{/InternalDataSet/HardwareDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/HardwareDevice[UID=$UID]/Name" /></Name>
      <Address><xsl:value-of select="/InternalDataSet/HardwareDevice[UID=$UID]/Address" /></Address>
      <LDUID><xsl:value-of select="LogicalOutputUID" /></LDUID>      
    </SPIOutput>
  </xsl:template>

  <xsl:template match="InternalDataSet/HWAnalogInput">
    <xsl:variable name="UID" select="UID" />
    <AnalogInput UID="{UID}" Type="{/InternalDataSet/HardwareDevice[UID=$UID]/Type}">
      <Name><xsl:value-of select="/InternalDataSet/HardwareDevice[UID=$UID]/Name" /></Name>
      <Address><xsl:value-of select="/InternalDataSet/HardwareDevice[UID=$UID]/Address" /></Address>
      <LDUID><xsl:value-of select="LogicalInputUID" /></LDUID>
      <TerminationResistor><xsl:value-of select="TerminationResistor" /></TerminationResistor>      
      <ThresholdReleaseTop><xsl:value-of select="ThresholdReleaseTop" /></ThresholdReleaseTop>
      <ThresholdReleaseDown><xsl:value-of select="ThresholdReleaseDown" /></ThresholdReleaseDown>
      <ThresholdInterrupt><xsl:value-of select="ThresholdInterrupt" /></ThresholdInterrupt>      
      <ThresholdShortCircuit><xsl:value-of select="ThresholdShortCircuit" /></ThresholdShortCircuit>     
    </AnalogInput>
  </xsl:template>

  <xsl:template name="InsertBusControllers">
    <xsl:variable name="PanelUID">
      <xsl:value-of select="/InternalDataSet/Panel/UID" />
    </xsl:variable>    
    <!-- iterates all controllers connected to the panel (ParentDeviceUID == PanelUID) -->
    <xsl:for-each select="/InternalDataSet/HardwareDevice[ParentDeviceUID=$PanelUID]">
      <xsl:call-template name="InsertController" />
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="InsertSupportControllers">
    <!-- iterates all support controllers (ParentDeviceUID tag is missing and UID is not equal to PanelUID) -->
    <xsl:variable name="PanelUID" select="InternalDataSet/Panel/UID" />    
    <xsl:for-each select="/InternalDataSet/Controller">
      <xsl:variable name="ControllerUID" select="UID" />
      <xsl:for-each select="/InternalDataSet/HardwareDevice[UID=$ControllerUID]"><!-- this foreach actually switches context to HardwareDevice xml tag (number of iterations is always 1) -->
        <xsl:if test="(not(ParentDeviceUID))">  <!-- and (UID!=$PanelUID)"> -->
          <!-- iterates all controllers without parent, all such controllers must be support controllers -->
          <xsl:call-template name="InsertController" />
        </xsl:if>
      </xsl:for-each>
    </xsl:for-each>
  </xsl:template>
  
  <xsl:template name="InsertController">
      <Controller UID="{UID}" Type="{Type}">
        <Name><xsl:value-of select="Name" /></Name>
        <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>
        <xsl:for-each select = "/InternalDataSet/Port[ControllerUID=$DeviceUID]">
          <xsl:if test="translate(Hardware, 'UART', 'uart')='uart'"> <!-- it actually means: if (LowerCase(Hardware)='uart') =-->
            <Port Hardware="{Hardware}" Name="{Name}" Mode="{Mode}" BaudRate="{BaudRate}" DataBits="{DataBits}" StopBits="{StopBits}" Parity="{Parity}" />
          </xsl:if>          
          <xsl:if test="translate(Hardware, 'SOCKET','socket')='socket'"><!-- it actually means: if (LowerCase(Hardware)='socket') =-->
            <Port Hardware="{Hardware}" IP="{IP}" Port="{Port}" Type="{Type}" Protocol="{Protocol}" Blocking="{Blocking}" />
          </xsl:if>      
        </xsl:for-each>
        <!-- iterates all device specific properties and inserts them into xml -->
        <xsl:call-template name="InsertDeviceParameters"> <xsl:with-param name="DeviceUID" select="$DeviceUID" /></xsl:call-template>
		    <!-- partition tamper settings -->
        <PartitionTamper><xsl:value-of select="PartitionTamper" /></PartitionTamper>
        <TamperOnLoss><xsl:value-of select="TamperOnLoss" /></TamperOnLoss>                                    
        <ConfiguredDevices>
          <!-- iterates all hardware devices connected to this controller (recursive call) -->
          <xsl:call-template name="InsertConfiguredDevices">
            <xsl:with-param name="ParentDeviceUID" select="$DeviceUID" />
            <xsl:with-param name="DeviceTagName" select="'BusDevice'" />
            <xsl:with-param name="WirelessDevice" select="'false'" />
          </xsl:call-template>
          <xsl:call-template name="InsertConfiguredDevices">
            <xsl:with-param name="ParentDeviceUID" select="$DeviceUID" />
            <xsl:with-param name="DeviceTagName" select="'WirelessDevice'" />
            <xsl:with-param name="WirelessDevice" select="'true'" />
          </xsl:call-template>          
        </ConfiguredDevices>
      </Controller>
  </xsl:template>

  <xsl:template name="InsertConfiguredDevices">
    <xsl:param name="ParentDeviceUID" />
    <xsl:param name="DeviceTagName" />
    <xsl:param name="WirelessDevice" />

    <xsl:for-each select="/InternalDataSet/HardwareDevice[ParentDeviceUID=$ParentDeviceUID and WirelessDevice=$WirelessDevice]">

      <xsl:element name="{$DeviceTagName}">
        <xsl:attribute name="UID"><xsl:value-of select="UID" /></xsl:attribute>
        <xsl:attribute name="Type"><xsl:value-of select="Type" /></xsl:attribute>
        <Name><xsl:value-of select="Name" /></Name>
        <Address><xsl:value-of select="Address" /></Address>
        
        <xsl:variable name="DeviceUID"><xsl:value-of select="UID" /></xsl:variable>

        <!-- iterates all device specific properties and inserts them into xml -->
        <xsl:call-template name="InsertDeviceParameters"><xsl:with-param name="DeviceUID" select="$DeviceUID" /></xsl:call-template>       

        <!-- finds linked logicaldevices (except Inputs/Outputs) and inserts its UIDs -->
        <xsl:call-template name="InsertLDUIDs"><xsl:with-param name="DeviceUID" select="$DeviceUID" /></xsl:call-template>
        
        <TimePattern><xsl:value-of select="TimePattern" /></TimePattern>
        <PartitionTamper><xsl:value-of select="PartitionTamper" /></PartitionTamper>
        <TamperOnLoss><xsl:value-of select="TamperOnLoss" /></TamperOnLoss>        
                
        <!-- finds all linked wireless master controllers -->
        <xsl:call-template name="InsertWirelessMasters"><xsl:with-param name="DeviceUID" select="$DeviceUID" /></xsl:call-template>

        <!-- finds linked logical inputs and outputs and inserts its UIDs -->
        <xsl:call-template name="InsertInputsOutputs"><xsl:with-param name="DeviceUID" select="$DeviceUID" /></xsl:call-template>

        <!-- finds linked logical doors and inserts them -->
        <xsl:call-template name="InsertLogicalDoors"><xsl:with-param name="DeviceUID" select="$DeviceUID" /></xsl:call-template>

        <!-- finds linked logical accesspoints and and inserts them -->
        <xsl:call-template name="InsertAccessPoints"><xsl:with-param name="DeviceUID" select="$DeviceUID" /></xsl:call-template>                

        <xsl:choose>
          <xsl:when test="SubdeviceUID>0">
            <Controller UID="{SubdeviceUID}" Type="{SubdeviceType}">
              <ConfiguredDevices>
                <!-- iterates all hardware devices connected to this controller 
                     (in this case the controller is a subdevice of configured device -->               
                <xsl:call-template name="InsertConfiguredDevices">
                  <xsl:with-param name="ParentDeviceUID" select="$DeviceUID" />
                  <xsl:with-param name="DeviceTagName" select="'BusDevice'" />
                  <xsl:with-param name="WirelessDevice" select="'false'" />
                </xsl:call-template>
                <xsl:call-template name="InsertConfiguredDevices">
                  <xsl:with-param name="ParentDeviceUID" select="$DeviceUID" />
                  <xsl:with-param name="DeviceTagName" select="'WirelessDevice'" />
                  <xsl:with-param name="WirelessDevice" select="'true'" />
                </xsl:call-template>          
              </ConfiguredDevices>
            </Controller>
          </xsl:when>
        </xsl:choose>
      </xsl:element>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="InsertLDUIDs">
    <xsl:param name="DeviceUID" />
    <xsl:for-each select = "/InternalDataSet/LogicalDevice[HardwareDeviceUID=$DeviceUID]">
      <xsl:choose>
        <xsl:when test="Type='ccLogicalInput'">
          <!-- no xml required -->
        </xsl:when>
        <xsl:when test="Type='ccLogicalOutput'">
          <!-- no xml required -->
        </xsl:when>
        <xsl:when test="Type='ccLogicalSounder'">
          <!-- no XML required -->
        </xsl:when>
        <xsl:when test="Type='ccLogicalDoor'">
          <!-- no XML required -->
        </xsl:when>        
        <xsl:when test="Type='ccLogicalAccessPoint'">
          <!-- no XML required -->
        </xsl:when>
        <xsl:when test="Type='ccLogicalKey'">
          <!-- no XML required -->
        </xsl:when>
        <xsl:when test="Type='ccLogicalLed'">
          <!-- no XML required -->
        </xsl:when>
        <xsl:when test="Type='ccLogicalPeripheral'">
          <LDPeripheral><xsl:value-of select="UID" /></LDPeripheral>
        </xsl:when>
        <xsl:when test="Type='ccLogicalRFPeripheral'">
          <LDRFPeripheral><xsl:value-of select="UID" /></LDRFPeripheral>
        </xsl:when>
        <xsl:when test="Type='ccLogicalRfReceiver'">
          <LDRFPeripheral><xsl:value-of select="UID" /></LDRFPeripheral>
        </xsl:when>        
        <xsl:when test="Type='ccLogicalInstallationService'">        
          <LDInstallServices><xsl:value-of select="UID" /></LDInstallServices>
        </xsl:when>
        <xsl:otherwise>
          <LDUID><xsl:value-of select="UID" /></LDUID>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>

  <xsl:template name="InsertInputsOutputs">
    <xsl:param name="DeviceUID" />   
    <!--creates Inputs section -->
    <Inputs>
      <xsl:for-each select = "/InternalDataSet/LogicalDevice[(HardwareDeviceUID=$DeviceUID) and (Type='ccLogicalInput')]">
        <xsl:variable name="LogicalUID"><xsl:value-of select="UID" /></xsl:variable>
        <xsl:variable name="Parameter"><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$LogicalUID]/Parameter" /></xsl:variable>
        <Input UID="{ClassUID}" Type="{ClassType}">
          <Name><xsl:value-of select="Name" /></Name>
          <Number><xsl:value-of select="Number" /></Number>              
          <LDUID><xsl:value-of select="UID" /></LDUID>
          <xsl:if test="$Parameter>0">
            <!-- Parameter for example GlassInput -->
            <Param><xsl:value-of select="/InternalDataSet/LogicalDevice[UID=$LogicalUID]/Parameter" /></Param>
          </xsl:if>
        </Input>                               
      </xsl:for-each>
    </Inputs>   
    <!--creates Outputs section-->
    <Outputs>
      <xsl:for-each select="/InternalDataSet/LogicalDevice[(HardwareDeviceUID=$DeviceUID) and (Type='ccLogicalOutput')]">
        <Output UID="{ClassUID}" Type="{ClassType}">
          <Name><xsl:value-of select="Name" /></Name>          
          <Number><xsl:value-of select="Number" /></Number>
          <LDUID><xsl:value-of select="UID" /></LDUID>              
        </Output>
      </xsl:for-each>
    </Outputs>    
    <!-- Inserts Keys -->
    <Keys>    
      <xsl:for-each select="/InternalDataSet/LogicalDevice[(HardwareDeviceUID=$DeviceUID) and (Type='ccLogicalKey')]">
        <Key UID="{ClassUID}" Type="{ClassType}">
          <Name><xsl:value-of select="Name" /></Name>          
          <Number><xsl:value-of select="Number" /></Number>
          <LDUID><xsl:value-of select="UID" /></LDUID>              
        </Key>
      </xsl:for-each>
    </Keys>    
    <!-- Inserts Leds -->
    <Leds>
      <xsl:for-each select="/InternalDataSet/LogicalDevice[(HardwareDeviceUID=$DeviceUID) and (Type='ccLogicalLed')]">
        <Led UID="{ClassUID}" Type="{ClassType}">
          <Name><xsl:value-of select="Name" /></Name>
          <Number><xsl:value-of select="Number" /></Number>
          <LDUID><xsl:value-of select="UID" /></LDUID>
        </Led>
      </xsl:for-each>
    </Leds>
    <!-- inserts Sounder (usually there is only one) if required -->
    <xsl:for-each select="/InternalDataSet/LogicalDevice[(HardwareDeviceUID=$DeviceUID) and (Type='ccLogicalSounder')]">
      <Sounder UID="{ClassUID}" Type="{ClassType}">
        <Name><xsl:value-of select="Name" /></Name>        
        <LDUID><xsl:value-of select="UID" /></LDUID>
      </Sounder>      
    </xsl:for-each>
    
  </xsl:template>

  <!-- finds linked logical doors and inserts them -->
  <xsl:template name="InsertLogicalDoors">
    <xsl:param name="DeviceUID" />        
    <Doors>
      <xsl:for-each select="/InternalDataSet/LogicalDevice[HardwareDeviceUID=$DeviceUID]">
        <xsl:variable name="LogicalUID"><xsl:value-of select="UID" /></xsl:variable>
        <xsl:if test="/InternalDataSet/LogicalDoor[UID=$LogicalUID]">
          <Door UID="{ClassUID}" Type="{ClassType}">
            <Name><xsl:value-of  select="Name" /></Name>
            <Number><xsl:value-of select="/InternalDataSet/LogicalDoor[UID=$LogicalUID]/DoorNumber" /></Number>
            <LDUID><xsl:value-of select="UID" /></LDUID>
          </Door>
        </xsl:if>
      </xsl:for-each>
    </Doors>
  </xsl:template>
  
  <!-- finds linked logical accesspoints and and inserts them -->
  <xsl:template name="InsertAccessPoints">
    <xsl:param name="DeviceUID" />
    <AccessPoints>
      <xsl:for-each select="/InternalDataSet/LogicalDevice[HardwareDeviceUID=$DeviceUID]">
        <xsl:variable name="LogicalUID"><xsl:value-of select="UID" /></xsl:variable>
        <xsl:if test="/InternalDataSet/LogicalAccessPoint[UID=$LogicalUID]">        
          <AccessPoint UID="{ClassUID}" Type="{ClassType}">
            <Name><xsl:value-of  select="Name" /></Name>
            <Number><xsl:value-of select="Number" /></Number>
            <LDUID><xsl:value-of select="UID" /></LDUID>
            <DoorNumber><xsl:value-of select="/InternalDataSet/LogicalAccessPoint[UID=$LogicalUID]/DoorNumber" /></DoorNumber>
            <DoorOutside><xsl:value-of select="/InternalDataSet/LogicalAccessPoint[UID=$LogicalUID]/DoorOutside" /></DoorOutside>
          </AccessPoint>
        </xsl:if>
      </xsl:for-each>
    </AccessPoints>
  </xsl:template>
  
  <!-- finds linked wireless masters and inserts them -->
  <xsl:template name="InsertWirelessMasters">
    <xsl:param name="DeviceUID" />
    <WirelessMasters>
      <xsl:for-each select="/InternalDataSet/WirelessMaster[DeviceUID=$DeviceUID]">
        <UID><xsl:value-of select="MasterUID" /></UID>
      </xsl:for-each>
    </WirelessMasters>
  </xsl:template>
  
  <xsl:template name="InsertDeviceParameters"> 
    <xsl:param name="DeviceUID" />            
    <xsl:for-each select="/InternalDataSet/*[starts-with(name(),'HW') and (UID=$DeviceUID)]">	
      <xsl:for-each select="*">
        <!-- inserts all subtags except UID tag -->
        <xsl:choose>
          <xsl:when test="name()='UID'">      
            <!-- do nothing, UID is ignored -->
          </xsl:when>
          <xsl:when test="name()='ConfigData'">
          	<!-- makes copy all tags and attributes -->
          	<xsl:call-template name="CopyAll" />                    		
          </xsl:when>
          <xsl:when test="name()='MSB'">
            <MSB>
              <xsl:call-template name="ConvertDecToHex">
                <xsl:with-param name="value">
                  <xsl:value-of select="."/>
                </xsl:with-param>
              </xsl:call-template>
            </MSB>
          </xsl:when>
          <xsl:otherwise>
            <xsl:element name="{name()}"><xsl:value-of select="." /></xsl:element>              
          </xsl:otherwise>                    
        </xsl:choose>  
      </xsl:for-each>      	 
    </xsl:for-each>    
  </xsl:template>   
    
  <!-- Copy XSL elements and their attributes -->
  <xsl:template name="CopyAll">      
    <xsl:element name="{name()}">
      <xsl:for-each select="@*">
        <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
      </xsl:for-each>                  
      <xsl:for-each select="*">
        <xsl:call-template name="CopyAll" />
      </xsl:for-each>      
      <xsl:value-of select="." />
    </xsl:element>
  </xsl:template>

  <xsl:template name="ConvertDecToHex">
    <xsl:param name="value" />
    <xsl:param name="len" select="0" />
    <xsl:choose>
      <xsl:when test="$value >0">
        <xsl:call-template name="ConvertDecToHex">
          <xsl:with-param name="value" select="floor($value div 16)" />
          <xsl:with-param name="len" select="$len + 1" />
        </xsl:call-template>
        <xsl:choose>
          <xsl:when test="$value mod 16 &lt; 10">
            <xsl:value-of select="$value mod 16" />
          </xsl:when>
          <xsl:otherwise>
            <xsl:choose>
              <xsl:when test="$value mod 16 = 10">A</xsl:when>
              <xsl:when test="$value mod 16 = 11">B</xsl:when>
              <xsl:when test="$value mod 16 = 12">C</xsl:when>
              <xsl:when test="$value mod 16 = 13">D</xsl:when>
              <xsl:when test="$value mod 16 = 14">E</xsl:when>
              <xsl:when test="$value mod 16 = 15">F</xsl:when>
              <xsl:otherwise>A</xsl:otherwise>
            </xsl:choose>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="$len &lt; 8">0<xsl:call-template name="ConvertDecToHex">
            <xsl:with-param name="value" select="0" />
            <xsl:with-param name="len" select="$len + 1" />
          </xsl:call-template>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
	  
   
</xsl:stylesheet>



Zerion Mini Shell 1.0