%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /data/bordel/scanned/
Upload File :
Create Path :
Current File : //data/bordel/scanned/transformFrom.xsl

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  <xsl:template match="/" >
    <InternalDataSet>
      <xsl:call-template name="Panel" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/RuntimePersistence/Storage" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/Partitions/Partition" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/Partitions/Partition/DependencyChildren/UID" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/Partitions/Partition/Sounders/UID" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/Partitions/Partition/ExternalSignallingGroups/UID" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/ExternalSignallingGroups/ExternalSignallingGroup" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/ExternalSignallingGroups/ExternalSignallingGroup/Sounders/UID" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/ExternalSignallingGroups/ExternalSignallingGroup/Flashers/UID" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionMemberManager/PartitionMembers/DetectorGroups/DetectorGroup" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionMemberManager/PartitionMembers/AccessPoints/AccessPoint" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionMemberManager/PartitionMembers/AccessPoints/AccessPoint/Users/User" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionMemberManager/PMCollections/PMCollection" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionMemberManager/PMCollections/PMCollection/PMs/PM" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualPIRs/VirtualPIR" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualInputs/VirtualInput" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualOutputs/VirtualOutput" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualCameras/VirtualCamera" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualCarbonMonoxides/VirtualCarbonMonoxide" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualDoors/VirtualDoor" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualDSDevices/VirtualDSDevice" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualFlashers/VirtualFlasher" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualKeySwitchs/VirtualKeySwitch" />  
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualKeys/VirtualKey" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualLeds/VirtualLed" />      
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualPeripherals/VirtualPeripheral" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualPeripherals/VirtualPeripheral/Owners/Owner" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualRelays/VirtualRelay" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualRFPeripherals/VirtualRFPeripheral" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualRFPeripherals/VirtualRFPeripheral/Owners/Owner" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualRfMasters/VirtualRfMaster" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualRfReceivers/VirtualRfReceiver" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualSmartUIs/VirtualSmartUI" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualSmokeDetectors/VirtualSmokeDetector" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualSounders/VirtualSounder" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualTemperatures/VirtualTemperature" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualUserInterfaces/VirtualUserInterface" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualWindows/VirtualWindow" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduleManager/Holidays/Holiday" /> 
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/UserManager/Users/User" />  
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/UserManager/Users/User/UserGroups/UserGroup" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/UserGroupManager/UserGroup" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/UserGroupManager/UserGroup/ScheduledItems/ScheduledItem" /> 
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduleManager/TimeSchedules/TimeSchedule" /> 
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduledItemManager/ScheduledItem" />      
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/ApplicationManager/EventLogs/EventLog" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/Macros/TriggerPool/Trigger" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/Macros/ConditionPool/Condition" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/Macros/SignalPool/Signal" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/Macros/CommandPool/Command" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/Macros/ActionPool/Action" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/Macros/ActionPool/Action/ActionList/CommandRef" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/Macros/MacroPool/Macro" />      
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/UserInterfaceManager/UIProxy" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/UserInterfaceManager/UIProxy/Partitions/UID" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/UserInterfaceManager/UIProxy/Items/Item" />            
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/RemoteApplicationManager/Connections/RemoteApplication" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/AlarmReportingManager/AlarmDevices/AlarmDevice" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/Application/AlarmReportingManager/AlarmDevices/AlarmDevice/FaultPartitions/UID" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalPirs/LogicalPir" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalInputs/LogicalInput" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalOutputs/LogicalOutput" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalAccessPoints/LogicalAccessPoint" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalCameras/LogicalCamera" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalCarbonMonoxides/LogicalCarbonMonoxide" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalDisplays/LogicalDisplay" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalDoors/LogicalDoor" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalDSAlarmReportings/LogicalDSAlarmReporting" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalEventBroadcasters/LogicalEventBroadcaster" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalInstallationServices/LogicalInstallationService" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalKeyboards/LogicalKeyboard" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalKeyboardReaders/LogicalKeyboardReader" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalKeys/LogicalKey" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalLeds/LogicalLed" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalPeripherals/LogicalPeripheral" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalReaders/LogicalReader" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalRFPeripherals/LogicalRFPeripheral" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalRFMasters/LogicalRFMaster" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalSmartUIs/LogicalSmartUI" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalSmokeDetectors/LogicalSmokeDetector" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalSounders/LogicalSounder" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalSounders/SounderTemplates/SounderTemplate" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalTemperatures/LogicalTemperature" />
      <!-- not supported by panel yet
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalEmails/LogicalEmail" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalSMSs/LogicalSMS" />
      -->
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/GPIO/GPIOOutputs/GPIOOutput" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/GPIO/GPIOInputs/GPIOInput" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/GPIO/SPIOutputs/SPIOutput" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/GPIO/SPIInputs/SPIInput" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/GPIO/AnalogInputs/AnalogInput" />
      
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/BusController/Controller" />
      <xsl:apply-templates select="/PanelConfiguration/Panel/HardwareManager/SupportController/Controller" />
      <xsl:apply-templates select="//ConfiguredDevices/*/WirelessMasters/UID" />
    </InternalDataSet>
  </xsl:template>

  <xsl:template name="Panel">
    <UID>
      <UID><xsl:value-of select="PanelConfiguration/Panel/@UID" /></UID>
      <TableName>Panel</TableName>
    </UID>
    <Panel>
      <UID><xsl:value-of select="PanelConfiguration/Panel/@UID" /></UID>
      <!-- is it here for compatibility with older version (data will not be lost), can be deleted later -->
      <Name><xsl:value-of select="PanelConfiguration/Panel/@Name" /></Name>
      <!-- -->
      <Name><xsl:value-of select="PanelConfiguration/Panel/Name" /></Name>
      <Type><xsl:value-of select="PanelConfiguration/Panel/@Type" /></Type>      
    </Panel>
    <ConfigInfo>
      <UID>1</UID>
      <Version><xsl:value-of select="PanelConfiguration/Panel/ConfigInfo/Version" /></Version>
      <GUID><xsl:value-of select="PanelConfiguration/Panel/ConfigInfo/GUID" /></GUID>
      <CompatibilityID><xsl:value-of select="PanelConfiguration/Panel/ConfigInfo/CompatibilityID" /></CompatibilityID>
      <ChangeCounter><xsl:value-of select="PanelConfiguration/Panel/ConfigInfo/ChangeCounter" /></ChangeCounter>
      <Timestamp><xsl:value-of select="PanelConfiguration/Panel/ConfigInfo/Timestamp" /></Timestamp>      
    </ConfigInfo>
    <GeneralSettings>
      <UID>1</UID>
      <UserCodeLength><xsl:value-of select="PanelConfiguration/Panel/Application/ApplicationManager/UserManager/CodeLength" /></UserCodeLength>
      <UserCodeDuressPosition><xsl:value-of select="PanelConfiguration/Panel/Application/ApplicationManager/UserManager/DuressPosition" /></UserCodeDuressPosition>
      <UserCodeDuressOffset><xsl:value-of select="PanelConfiguration/Panel/Application/ApplicationManager/UserManager/DuressOffset" /></UserCodeDuressOffset>
    </GeneralSettings>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/RuntimePersistence/Storage">
    <Storage>
      <UID><xsl:value-of select="position()" /></UID>
      <SaveFrequency><xsl:value-of select="@eSaveFrequency" /></SaveFrequency>
      <Seconds><xsl:value-of select="@Seconds" /></Seconds>
      <Mode><xsl:value-of select="@Mode" /></Mode>
      <FileName><xsl:value-of select="@Filename" /></FileName>
      <FileStream><xsl:value-of select="@FileStream" /></FileStream>
      <DecoratorStream><xsl:value-of select="@DecoratorStream" /></DecoratorStream>
    </Storage>
  </xsl:template>
     
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualPIRs/VirtualPIR">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualPIR</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>
    <xsl:if test="@Type='ccVirtualBusPIR'">
      <VirtualPIR>
        <UID><xsl:value-of select="@UID" /></UID>
      </VirtualPIR>
      <VirtualBusPIR>
        <UID><xsl:value-of select="@UID" /></UID>
        <LogicalPIRUID><xsl:value-of select="HWUID" /></LogicalPIRUID>
      </VirtualBusPIR>
    </xsl:if>
    <xsl:if test="@Type='ccVirtualHardwiredPIR'">
      <VirtualPIR>
        <UID><xsl:value-of select="@UID" /></UID>
      </VirtualPIR>
      <VirtualHardwiredPIR>
        <UID><xsl:value-of select="@UID" /></UID>
        <AlarmInputUID><xsl:value-of select="Inputs/Input[Position='pipAlarm']/HWUID" /></AlarmInputUID>
        <TamperInputUID><xsl:value-of select="Inputs/Input[Position='pipTamper']/HWUID" /></TamperInputUID>
        <FaultInputUID><xsl:value-of select="Inputs/Input[Position='pipFault']/HWUID" /></FaultInputUID>
        <WalkTestOutputUID><xsl:value-of select="Outputs/Output[Position='popWalkTest']/HWUID" /></WalkTestOutputUID>
        <SetOutputUID><xsl:value-of select="Outputs/Output[Position='popSet']/HWUID" /></SetOutputUID>
      </VirtualHardwiredPIR>
    </xsl:if>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualInputs/VirtualInput">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualInput</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>
    <VirtualInput>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalInputUID><xsl:value-of select="HWUID" /></LogicalInputUID>
    </VirtualInput>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualOutputs/VirtualOutput">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualOutput</TableName>
    </UID>  
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>      
    </VirtualDevice>
    <VirtualOutput>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalOutputUID><xsl:value-of select="HWUID" /></LogicalOutputUID>
      <SignalUID><xsl:value-of select="Signal" /></SignalUID>
    </VirtualOutput>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualDoors/VirtualDoor">
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>
    <VirtualDoor>
      <UID><xsl:value-of select="@UID" /></UID>
      <SecondaryOwner><xsl:value-of select="SecondaryOwner" /></SecondaryOwner>
      <Tamper><xsl:value-of select="Tamper" /></Tamper>
      <LockingError><xsl:value-of select="LockingError" /></LockingError>
    </VirtualDoor>
	<xsl:if test="@Type='ccVirtualBusDoor'">
      <UID>
        <UID><xsl:value-of select="@UID" /></UID>
        <TableName>VirtualBusDoor</TableName>
      </UID>
      <VirtualBusDoor>
        <UID><xsl:value-of select="@UID" /></UID>
        <OpenSignalSounder><xsl:value-of select="OpenSignalSounder" /></OpenSignalSounder>
        <OpenSignalTime><xsl:value-of select="OpenSignalTime" /></OpenSignalTime>
        <OpenAlarmTime><xsl:value-of select="OpenAlarmTime" /></OpenAlarmTime>
        <LogicalDoorUID><xsl:value-of select="HWUID" /></LogicalDoorUID>
      </VirtualBusDoor>		
    </xsl:if>
    <xsl:if test="@Type='ccVirtualHardwiredDoor'">
      <UID>
        <UID><xsl:value-of select="@UID" /></UID>
        <TableName>VirtualHardwiredDoor</TableName>
      </UID>
      <VirtualHardwiredDoor>
        <UID><xsl:value-of select="@UID" /></UID>
        <OpenSignalSounder><xsl:value-of select="OpenSignalSounder" /></OpenSignalSounder>
        <OpenSignalTime><xsl:value-of select="OpenSignalTime" /></OpenSignalTime>
        <OpenAlarmTime><xsl:value-of select="OpenAlarmTime" /></OpenAlarmTime>
        <StateContactUID><xsl:value-of select="Inputs/Input[Position='dipStateContact']/HWUID" /></StateContactUID>
        <LatchContactUID><xsl:value-of select="Inputs/Input[Position='dipLatchContact']/HWUID" /></LatchContactUID>
        <BoltContactUID><xsl:value-of select="Inputs/Input[Position='dipBoltContact']/HWUID" /></BoltContactUID>
        <OpenerRelayUID><xsl:value-of select="Outputs/Output[Position='dopOpenerRelais']/HWUID" /></OpenerRelayUID>
        <PrealarmRelayUID><xsl:value-of select="Outputs/Output[Position='dopPrealarmRelais']/HWUID" /></PrealarmRelayUID>
        <LockRelayUID><xsl:value-of select="Outputs/Output[Position='dopLockRelais']/HWUID" /></LockRelayUID>
        <EscapeRelayUID><xsl:value-of select="Outputs/Output[Position='dopEscapeRelais']/HWUID" /></EscapeRelayUID>
      </VirtualHardwiredDoor>		
    </xsl:if>
  </xsl:template>


  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualPeripherals/VirtualPeripheral">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualPeripheral</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
    </VirtualDevice>
    <VirtualPeripheral>
      <UID><xsl:value-of select="@UID" /></UID>
      <xsl:choose>
        <xsl:when test="HWUID=/PanelConfiguration/Panel/@UID">
          <UsedByPanel>true</UsedByPanel>
        </xsl:when>
        <xsl:otherwise>
          <UsedByPanel>false</UsedByPanel>
          <LogicalPeripheralUID><xsl:value-of select="HWUID" /></LogicalPeripheralUID>  
        </xsl:otherwise>
      </xsl:choose>
      <xsl:for-each select="FaultTypes/FaultType">
        <xsl:variable name="effectName" select="concat('fe',substring(Type, 3))" />
        <xsl:if test="$effectName!=''">
          <xsl:element name="{$effectName}"><xsl:value-of select="Effect" /></xsl:element>
        </xsl:if>
      </xsl:for-each>
    </VirtualPeripheral>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualPeripherals/VirtualPeripheral/Owners/Owner">
    <xsl:variable name="PMUID"><xsl:value-of select="UID" /></xsl:variable>
    <xsl:variable name="VPUID"><xsl:value-of select="./../../@UID" /></xsl:variable>
    <VirtualPeripheralPartitionMemberFaultType> 
      <UID><xsl:value-of select="position()" /></UID>  <!--xml tag position is used as unique ID-->
      <VirtualPeripheralUID><xsl:value-of select="$VPUID" /></VirtualPeripheralUID>
      <PartitionMemberUID><xsl:value-of select="$PMUID" /></PartitionMemberUID> 
      <xsl:choose>
        <xsl:when test="FaultTypes">
          <SendAllFaultTypes>false</SendAllFaultTypes>
          <!-- only some faulttypes are sent to the owner (partitionmember) -->
          <xsl:for-each select="FaultTypes/FaultType">
            <xsl:if test="string-length(.)>0">
              <xsl:element name="{.}">true</xsl:element>
            </xsl:if>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <!-- missing faulttypelist means that all fault event types are sent to the owner (partitionmember) -->
          <SendAllFaultTypes>true</SendAllFaultTypes>
        </xsl:otherwise>
      </xsl:choose>
    </VirtualPeripheralPartitionMemberFaultType>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualSmokeDetectors/VirtualSmokeDetector">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualSmokeDetector</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>  
    <VirtualSmokeDetector>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalSmokeDetectorUID><xsl:value-of select="HWUID" /></LogicalSmokeDetectorUID>
      <LowSenseEffect><xsl:value-of select="LowSenseEffect" /></LowSenseEffect>
      <WrongHeadEffect><xsl:value-of select="WrongHeadEffect" /></WrongHeadEffect>
    </VirtualSmokeDetector>
  </xsl:template>
  
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualRFPeripherals/VirtualRFPeripheral">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualWirelessPeripheral</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>  
    <VirtualWirelessPeripheral>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalWirelessPeripheralUID><xsl:value-of select="HWUID" /></LogicalWirelessPeripheralUID>
      <xsl:for-each select="FaultTypes/FaultType">
        <xsl:variable name="effectName" select="concat('fe',substring(Type, 3))" />
        <xsl:if test="$effectName!=''">
          <xsl:element name="{$effectName}"><xsl:value-of select="Effect" /></xsl:element>
        </xsl:if>
      </xsl:for-each>
    </VirtualWirelessPeripheral>  
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualRFPeripherals/VirtualRFPeripheral/Owners/Owner">
    <xsl:variable name="PMUID"><xsl:value-of select="UID" /></xsl:variable>
    <xsl:variable name="VPUID"><xsl:value-of select="./../../@UID" /></xsl:variable>
    <VirtualPeripheralPartitionMemberFaultType> 
      <UID><xsl:value-of select="position()" /></UID>  <!--xml tag position is used as unique ID-->
      <VirtualRFPeripheralUID><xsl:value-of select="$VPUID" /></VirtualRFPeripheralUID>
      <PartitionMemberUID><xsl:value-of select="$PMUID" /></PartitionMemberUID> 
      <xsl:choose>
        <xsl:when test="FaultTypes">
          <SendAllFaultTypes>false</SendAllFaultTypes>
          <!-- only some faulttypes are sent to the owner (partitionmember) -->
          <xsl:for-each select="FaultTypes/FaultType">
            <xsl:if test="string-length(.)>0">
              <xsl:element name="{.}">true</xsl:element>
            </xsl:if>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <!-- missing faulttypelist means that all fault event types are sent to the owner (partitionmember) -->
          <SendAllFaultTypes>true</SendAllFaultTypes>
        </xsl:otherwise>
      </xsl:choose>
    </VirtualPeripheralPartitionMemberFaultType>
  </xsl:template>
  

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualRfMasters/VirtualRfMaster">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualWirelessPeripheral</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>  
    <VirtualWirelessMaster>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalWirelessMasterUID><xsl:value-of select="HWUID" /></LogicalWirelessMasterUID>
    </VirtualWirelessMaster>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualRfReceivers/VirtualRfReceiver">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualWirelessReceiver</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>  
    <VirtualWirelessReceiver>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalRfReceiverUID><xsl:value-of select="HWUID" /></LogicalRfReceiverUID>
    </VirtualWirelessReceiver>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualSmartUIs/VirtualSmartUI">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualSmartUI</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>  
    <VirtualSmartUI>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalSmartUI_UID><xsl:value-of select="HWUID" /></LogicalSmartUI_UID>
    </VirtualSmartUI>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualTemperatures/VirtualTemperature">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualTemperature</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>  
    <VirtualTemperature>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalTemperatureUID><xsl:value-of select="HWUID" /></LogicalTemperatureUID>
    </VirtualTemperature>
  </xsl:template>  
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualCameras/VirtualCamera">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualCamera</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>  
    <VirtualCamera>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalCameraUID><xsl:value-of select="HWUID" /></LogicalCameraUID>
    </VirtualCamera>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualCarbonMonoxides/VirtualCarbonMonoxide">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualCarbonMonoxide</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>  
    <VirtualCarbonMonoxide>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalCarbonMonoxideUID><xsl:value-of select="HWUID" /></LogicalCarbonMonoxideUID>
    </VirtualCarbonMonoxide>  
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualKeySwitchs/VirtualKeySwitch">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualKeySwitch</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>
    <VirtualKeySwitch>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalInputUID><xsl:value-of select="HWUID" /></LogicalInputUID>
    </VirtualKeySwitch>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualKeys/VirtualKey">  
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>    
      <TableName>VirtualKey</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>
    <VirtualKey>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalKeyUID><xsl:value-of select="HWUID" /></LogicalKeyUID>
    </VirtualKey>   
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualLeds/VirtualLed">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualLED</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>
    <VirtualLed>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalOutputUID><xsl:value-of select="HWUID" /></LogicalOutputUID>
    </VirtualLed>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualRelays/VirtualRelay">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualRelay</TableName>
    </UID>  
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>
    <VirtualRelay>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalOutputUID><xsl:value-of select="HWUID" /></LogicalOutputUID>
    </VirtualRelay>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualWindows/VirtualWindow">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualWindow</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>   
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>
    <VirtualWindow>
      <UID><xsl:value-of select="@UID" /></UID>
      <AlarmInputUID><xsl:value-of select="Inputs/Input[Position='pipAlarm']/HWUID" /></AlarmInputUID>
      <TamperInputUID><xsl:value-of select="Inputs/Input[Position='pipTamper']/HWUID" /></TamperInputUID>
    </VirtualWindow>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualSounders/VirtualSounder">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualSounder</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>
    <VirtualSounder>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalSirenUID><xsl:value-of select="HWUID" /></LogicalSirenUID>
    </VirtualSounder>
  </xsl:template>  
  
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualUserInterfaces/VirtualUserInterface">  
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualUserInterface</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>
    <VirtualUserInterface>  
      <UID><xsl:value-of select="@UID" /></UID>
    </VirtualUserInterface>
    <xsl:if test="@Type='ccVirtualReader'">
      <VirtualReader>
		<UID><xsl:value-of select="@UID" /></UID>
		<LogicalReaderUID><xsl:value-of select="HWUID" /></LogicalReaderUID>
      </VirtualReader>
    </xsl:if>
    <xsl:if test="@Type='ccVirtualKeyboard'">
      <VirtualKeyboard>
        <UID><xsl:value-of select="@UID" /></UID>
        <LogicalKeyboardUID><xsl:value-of select="HWUID" /></LogicalKeyboardUID>
      </VirtualKeyboard>
    </xsl:if>
    <xsl:if test="@Type='ccVirtualKeyboardReader'">
      <VirtualKeyboardReader>
        <UID><xsl:value-of select="@UID" /></UID>
        <LogicalKeyboardReaderUID><xsl:value-of select="HWUID" /></LogicalKeyboardReaderUID>
      </VirtualKeyboardReader>
    </xsl:if>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualDSDevices/VirtualDSDevice">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualDSDevice</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>  
    <VirtualDSDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalDSAlarmReportingUID><xsl:value-of select="HWUID" /></LogicalDSAlarmReportingUID>
    </VirtualDSDevice>  
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/VirtualDevices/VirtualFlashers/VirtualFlasher">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>VirtualFlasher</TableName>
    </UID>
    <VirtualDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <HWUID><xsl:value-of select="HWUID" /></HWUID>
      <Owner><xsl:value-of select="Owner" /></Owner>
    </VirtualDevice>  
    <VirtualFlasher>
      <UID><xsl:value-of select="@UID" /></UID>
      <LogicalOutputUID><xsl:value-of select="HWUID" /></LogicalOutputUID>
    </VirtualFlasher>
  </xsl:template>  
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/Partitions/Partition">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>Partition</TableName>
    </UID>  
    <Partition>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <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>
      <AlarmIndicationDelayTime><xsl:value-of select="AlarmIndicationDelay/Time" /></AlarmIndicationDelayTime>
      <EntryTime><xsl:value-of select="Entry/Time" /></EntryTime>
      <EntryPreWarnTime><xsl:value-of select="Entry/PreWarnTime" /></EntryPreWarnTime>
      <EntrySounderType><xsl:value-of select="Entry/SounderType" /></EntrySounderType>
      <EntrySounderStyle><xsl:value-of select="Entry/SounderStyle" /></EntrySounderStyle>
      <EntryPreWarnSounderStyle><xsl:value-of select="Entry/PreWarnSounderStyle" /></EntryPreWarnSounderStyle>
      <EntryAlarmSounderStyle><xsl:value-of select="Entry/AlarmSounderStyle" /></EntryAlarmSounderStyle>
      <ExitTime><xsl:value-of select="Exit/Time" /></ExitTime>
      <ExitPreWarnTime><xsl:value-of select="Exit/PreWarnTime" /></ExitPreWarnTime>
      <ExitSounderType><xsl:value-of select="Exit/SounderType" /></ExitSounderType>
      <ExitSounderStyle><xsl:value-of select="Exit/SounderStyle" /></ExitSounderStyle>
      <ExitPreWarnSounderStyle><xsl:value-of select="Exit/PreWarnSounderStyle" /></ExitPreWarnSounderStyle>
      <FullAlarmTime><xsl:value-of select="FullAlarm/Time" /></FullAlarmTime>
      <LocalAlarmTime><xsl:value-of select="LocalAlarm/Time" /></LocalAlarmTime>
      <LocalAlarmSounderType><xsl:value-of select="LocalAlarm/SounderType" /></LocalAlarmSounderType>
      <LocalAlarmSounderStyle><xsl:value-of select="LocalAlarm/SounderStyle" /></LocalAlarmSounderStyle>
      <FullSetConfirmTime><xsl:value-of select="FullSetConfirm/Time" /></FullSetConfirmTime>
      <FullSetConfirmSounderType><xsl:value-of select="FullSetConfirm/SounderType" /></FullSetConfirmSounderType>
      <FullSetConfirmSounderStyle><xsl:value-of select="FullSetConfirm/SounderStyle" /></FullSetConfirmSounderStyle>
      <PartSetDelayTime><xsl:value-of select="PartSetDelay/Time" /></PartSetDelayTime>
      <PartSetDelaySounderType><xsl:value-of select="PartSetDelay/SounderType" /></PartSetDelaySounderType>
      <PartSetDelaySounderStyle><xsl:value-of select="PartSetDelay/SounderStyle" /></PartSetDelaySounderStyle>
      <UnsetPreventionTime><xsl:value-of select="UnsetPrevention/Time" /></UnsetPreventionTime>
      <UnsetPreventionAlarmTime><xsl:value-of select="UnsetPrevention/AlarmTime" /></UnsetPreventionAlarmTime>
      <ExternalSignallingWaitTime><xsl:value-of select="ExternalSignallingWait/Time" /></ExternalSignallingWaitTime>
      <ExternalSignallingIntruder><xsl:if test="ExternalSignallingWait/AlarmTypes[AlarmType='atIntruder']">true</xsl:if></ExternalSignallingIntruder>
      <ExternalSignallingTamper><xsl:if test="ExternalSignallingWait/AlarmTypes[AlarmType='atTamper']">true</xsl:if></ExternalSignallingTamper>
      <ExternalSignallingPanic><xsl:if test="ExternalSignallingWait/AlarmTypes[AlarmType='atPanic']">true</xsl:if></ExternalSignallingPanic>
      <ExternalSignallingFire><xsl:if test="ExternalSignallingWait/AlarmTypes[AlarmType='atFire']">true</xsl:if></ExternalSignallingFire>
      <ExternalSignallingTechnical><xsl:if test="ExternalSignallingWait/AlarmTypes[AlarmType='atTechnical']">true</xsl:if></ExternalSignallingTechnical>      
      <ClearWaitTime><xsl:value-of select="ClearWait/Time" /></ClearWaitTime>
      <AlarmReportingWaitTime><xsl:value-of select="AlarmReportingWait/Time" /></AlarmReportingWaitTime>
      <AlarmReportingIntruder><xsl:if test="AlarmReportingWait/AlarmTypes[AlarmType='atIntruder']">true</xsl:if></AlarmReportingIntruder>
      <AlarmReportingTamper><xsl:if test="AlarmReportingWait/AlarmTypes[AlarmType='atTamper']">true</xsl:if></AlarmReportingTamper>
      <AlarmReportingPanic><xsl:if test="AlarmReportingWait/AlarmTypes[AlarmType='atPanic']">true</xsl:if></AlarmReportingPanic>
      <AlarmReportingFire><xsl:if test="AlarmReportingWait/AlarmTypes[AlarmType='atFire']">true</xsl:if></AlarmReportingFire>
      <AlarmReportingTechnical><xsl:if test="AlarmReportingWait/AlarmTypes[AlarmType='atTechnical']">true</xsl:if></AlarmReportingTechnical>
      <FaultTime><xsl:value-of select="Fault/Time" /></FaultTime>
      <FaultSounderType><xsl:value-of select="Fault/SounderType" /></FaultSounderType>
      <FaultSounderStyle><xsl:value-of select="Fault/SounderStyle" /></FaultSounderStyle>      
      <!-- Partition Dependencies 1:N 
      <ParentPartitionUID><xsl:value-of select="DependencyParent/UID" /></ParentPartitionUID>
      -->
    </Partition>
    <xsl:variable name="PartitionUID"><xsl:value-of select="@UID" /></xsl:variable>
    <ExternalSounderStyle>
      <UID><xsl:value-of select="$PartitionUID" /></UID>
      <PartitionUID><xsl:value-of select="$PartitionUID" /></PartitionUID>
      <FireAlarmSounderStyle><xsl:value-of select="ExternalSounderStyles/ExternalSounderStyle[AlarmType='atFire']/SounderStyle" /></FireAlarmSounderStyle>
      <FireAlarmSounderTemplateUID><xsl:value-of select="ExternalSounderStyles/ExternalSounderStyle[AlarmType='atFire']/SounderTemplate" /></FireAlarmSounderTemplateUID>
      <PanicAlarmSounderStyle><xsl:value-of select="ExternalSounderStyles/ExternalSounderStyle[AlarmType='atPanic']/SounderStyle" /></PanicAlarmSounderStyle>
      <PanicAlarmSounderTemplateUID><xsl:value-of select="ExternalSounderStyles/ExternalSounderStyle[AlarmType='atPanic']/SounderTemplate" /></PanicAlarmSounderTemplateUID>
      <IntruderAlarmSounderStyle><xsl:value-of select="ExternalSounderStyles/ExternalSounderStyle[AlarmType='atIntruder']/SounderStyle" /></IntruderAlarmSounderStyle>
      <IntruderAlarmSounderTemplateUID><xsl:value-of select="ExternalSounderStyles/ExternalSounderStyle[AlarmType='atIntruder']/SounderTemplate" /></IntruderAlarmSounderTemplateUID>
      <TamperAlarmSounderStyle><xsl:value-of select="ExternalSounderStyles/ExternalSounderStyle[AlarmType='atTamper']/SounderStyle" /></TamperAlarmSounderStyle>
      <TamperAlarmSounderTemplateUID><xsl:value-of select="ExternalSounderStyles/ExternalSounderStyle[AlarmType='atTamper']/SounderTemplate" /></TamperAlarmSounderTemplateUID>
      <TechnicalAlarmSounderStyle><xsl:value-of select="ExternalSounderStyles/ExternalSounderStyle[AlarmType='atTechnical']/SounderStyle" /></TechnicalAlarmSounderStyle>
      <TechnicalAlarmSounderTemplateUID><xsl:value-of select="ExternalSounderStyles/ExternalSounderStyle[AlarmType='atTechnical']/SounderTemplate" /></TechnicalAlarmSounderTemplateUID>
    </ExternalSounderStyle>
    <xsl:for-each select="UnsetPrevention/AlarmTypes/AlarmType">
      <UnsetPreventionAlarmType>
        <PartitionUID><xsl:value-of select="$PartitionUID" /></PartitionUID>
        <AlarmType><xsl:value-of select="." /></AlarmType>
      </UnsetPreventionAlarmType>
    </xsl:for-each>
    <SoundingFaultTypes>
      <PartitionUID><xsl:value-of select="$PartitionUID" /></PartitionUID>
      <!-- only TRUE values are inserted, (FALSE values are default values in dataset) -->
      <xsl:for-each select="Fault/Sounding/FaultType">
        <xsl:if test="string-length(.)>0">
          <xsl:element name="{.}">true</xsl:element>
        </xsl:if>
      </xsl:for-each>
	</SoundingFaultTypes>
    <StoredFaultTypes>
      <PartitionUID><xsl:value-of select="$PartitionUID" /></PartitionUID>
      <!-- only TRUE values are inserted, (FALSE values are default values in dataset) -->
      <xsl:for-each select="Fault/Stored/FaultType">
        <xsl:if test="string-length(.)>0">
          <xsl:element name="{.}">true</xsl:element>
        </xsl:if>
      </xsl:for-each>
    </StoredFaultTypes>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/Partitions/Partition/DependencyChildren/UID">
    <xsl:variable name="PartitionUID" select="./../../@UID" />
    <PartitionDependency>
      <UID><xsl:value-of select="position()" /></UID> <!--xml tag position is used as unique ID-->
      <ParentPartitionUID><xsl:value-of select="$PartitionUID" /></ParentPartitionUID>
      <ChildPartitionUID><xsl:value-of select="." /></ChildPartitionUID>
    </PartitionDependency>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/Partitions/Partition/Sounders/UID">
    <xsl:variable name="PartitionUID" select="./../../@UID" />
    <Partition_LocalSounder>
      <UID><xsl:value-of select="position()" /></UID>
      <PartitionUID><xsl:value-of select="$PartitionUID" /></PartitionUID>
      <LocalSounderUID><xsl:value-of select="." /></LocalSounderUID>
    </Partition_LocalSounder>  
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/Partitions/Partition/ExternalSignallingGroups/UID">
    <xsl:variable name="PartitionUID" select="./../../@UID" />
    <Partition_SignalingGroup>
      <UID><xsl:value-of select="position()" /></UID> <!--xml tag position is used as unique ID-->
      <PartitionUID><xsl:value-of select="$PartitionUID" /></PartitionUID>
      <SignalingGroupUID><xsl:value-of select="." /></SignalingGroupUID>
    </Partition_SignalingGroup>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/ExternalSignallingGroups/ExternalSignallingGroup">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>SignalingGroup</TableName>
    </UID>
    <SignalingGroup>
      <UID><xsl:value-of select="@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>
    </SignalingGroup>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/ExternalSignallingGroups/ExternalSignallingGroup/Sounders/UID">
    <xsl:variable name="GroupUID"><xsl:value-of select="./../../@UID" /></xsl:variable>
    <SignalingGroup_Sounder>
      <UID><xsl:value-of select="position()" /></UID>  <!--xml tag position is used as unique ID-->
      <SignalingGroupUID><xsl:value-of select="$GroupUID" /></SignalingGroupUID>
      <SounderUID><xsl:value-of select="." /></SounderUID>  
    </SignalingGroup_Sounder>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionManager/ExternalSignallingGroups/ExternalSignallingGroup/Flashers/UID">
    <xsl:variable name="GroupUID"><xsl:value-of select="./../../@UID" /></xsl:variable>
    <SignalingGroup_Flasher>
      <UID><xsl:value-of select="position()" /></UID>  <!--xml tag position is used as unique ID-->
      <SignalingGroupUID><xsl:value-of select="$GroupUID" /></SignalingGroupUID>
      <FlasherUID><xsl:value-of select="." /></FlasherUID>
    </SignalingGroup_Flasher>  
  </xsl:template>
  

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionMemberManager/PartitionMembers/DetectorGroups/DetectorGroup">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>DetectorGroup</TableName>
    </UID>
    <PartitionMember>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <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>
      <ClearAlarmReleased><xsl:value-of select="ClearAlarmReleased" /></ClearAlarmReleased>
    </PartitionMember>
    <DetectorGroup>
      <UID><xsl:value-of select="@UID" /></UID>
      <PartSetDelayPostTrigger><xsl:value-of select="PartSetDelayPostTrigger" /></PartSetDelayPostTrigger>
      <UnsetPrevention><xsl:value-of select="UnsetPrevention" /></UnsetPrevention>
      <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>
      <SounderTemplateUID><xsl:value-of select="SounderTemplate" /></SounderTemplateUID>
    </DetectorGroup>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionMemberManager/PartitionMembers/AccessPoints/AccessPoint">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>AccessPoint</TableName>
    </UID>  
    <PartitionMember>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <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>
    </PartitionMember>
    <AccessPoint>
      <UID><xsl:value-of select="@UID" /></UID>
      <DoorReleaseTime><xsl:value-of select="DoorReleaseTime" /></DoorReleaseTime>
      <ModeAccess><xsl:value-of select="OperatingModes/Access" /></ModeAccess>
      <ModeAccessNoSchedule><xsl:value-of select="OperatingModes/AccessAutomatic" /></ModeAccessNoSchedule>
      <ModeSet><xsl:value-of select="OperatingModes/FullSet" /></ModeSet>
      <ModePartSet><xsl:value-of select="OperatingModes/PartSet" /></ModePartSet>
      <ModeUnset><xsl:value-of select="OperatingModes/Unset" /></ModeUnset>
      <ModeMacro><xsl:value-of select="OperatingModes/Macro" /></ModeMacro>
      <ModeQuickMacro><xsl:value-of select="OperatingModes/QuickMacro" /></ModeQuickMacro>
      <CodeData><xsl:value-of select="CodeData" /></CodeData>
      <DuressAlarmSetType><xsl:value-of select="Alarms/Duress/AlarmSetType" /></DuressAlarmSetType>
      <DuressAlertingType><xsl:value-of select="Alarms/Duress/AlertingType" /></DuressAlertingType>
      <FailAttemptAlarmSetType><xsl:value-of select="Alarms/FailAttempt/AlarmSetType" /></FailAttemptAlarmSetType>
      <FailAttemptAlertingType><xsl:value-of select="Alarms/FailAttempt/AlertingType" /></FailAttemptAlertingType>
      <DoorTamperAlarmSetType><xsl:value-of select="Alarms/DoorTamper/AlarmSetType" /></DoorTamperAlarmSetType>
      <DoorTamperAlertingType><xsl:value-of select="Alarms/DoorTamper/AlertingType" /></DoorTamperAlertingType>
      <DoorOpenTimeAlarmSetType><xsl:value-of select="Alarms/DoorOpenTime/AlarmSetType" /></DoorOpenTimeAlarmSetType>
      <DoorOpenTimeAlertingType><xsl:value-of select="Alarms/DoorOpenTime/AlertingType" /></DoorOpenTimeAlertingType>
      <LogicalAccessPointUID><xsl:value-of select="HWUID" /></LogicalAccessPointUID>
    </AccessPoint>
    <xsl:variable name="UID"><xsl:value-of select="@UID" /></xsl:variable>
    <MultiplePersonAccess>
      <AccessPoint_UID><xsl:value-of select="$UID" /></AccessPoint_UID>
      <MPALimit><xsl:value-of select="MultiplePersonAccess/MPALimit" /></MPALimit>
    </MultiplePersonAccess>
    <FailAttempt>
      <AccessPoint_UID><xsl:value-of select="$UID" /></AccessPoint_UID>
      <Limit><xsl:value-of select="FailAttempt/Limit" /></Limit>
      <DeactivateAccess><xsl:value-of select="FailAttempt/DeactivateAccess" /></DeactivateAccess>
      <DeactivateMacros><xsl:value-of select="FailAttempt/DeactivateMacros" /></DeactivateMacros>
      <LockoutTime><xsl:value-of select="FailAttempt/LockoutTime" /></LockoutTime>
    </FailAttempt>  
    <xsl:for-each select="Macros/QuickMacro">
      <APQuickMacro>
        <AccessPointUID><xsl:value-of select="$UID" /></AccessPointUID>
        <Key><xsl:value-of select="MacroKey" /></Key>
        <MacroUID><xsl:value-of select="UID" /></MacroUID>
      </APQuickMacro>
    </xsl:for-each>
    <xsl:for-each select="Macros/Macro">
      <APMacro>
        <AccessPointUID><xsl:value-of select="$UID" /></AccessPointUID>
        <Code><xsl:value-of select="MacroCode" /></Code>
        <MacroUID><xsl:value-of select="UID" /></MacroUID>
      </APMacro>
    </xsl:for-each>
    <xsl:for-each select="Users/User">
    </xsl:for-each>
    <xsl:for-each select="Turnstile">
      <APTurnstile>
        <AccessPointUID><xsl:value-of select="$UID" /></AccessPointUID>
        <Type><xsl:value-of select="Type" /></Type>
        <OpenerRelayOutputUID><xsl:value-of select="Output[Position='dopOpenerRelais']/HWUID" /></OpenerRelayOutputUID>
        <LatchContactInputUID><xsl:value-of select="Input[Position='dipLatchContact']/HWUID" /></LatchContactInputUID>
      </APTurnstile>
    </xsl:for-each>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionMemberManager/PartitionMembers/AccessPoints/AccessPoint/Users/User">
    <xsl:variable name="AccessPointUID" select="./../../@UID" />
    <AccessPoint_User>
      <UID><xsl:value-of select="position()" /></UID>  <!--xml tag position is used as unique ID-->
      <AccessPointUID><xsl:value-of select="$AccessPointUID" /></AccessPointUID>
      <UserUID><xsl:value-of select="." /></UserUID>
    </AccessPoint_User>
  </xsl:template>  
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionMemberManager/PMCollections/PMCollection">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>PMCollection</TableName>
    </UID>
    <PMCollection>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <Order><xsl:value-of select="Order" /></Order>
      <Owner><xsl:value-of select="Owner" /></Owner>
      <ReleaseStorage><xsl:value-of select="ReleaseStorage" /></ReleaseStorage>
      <ReleaseStorageTime><xsl:value-of select="ReleaseStorageTime" /></ReleaseStorageTime>
    </PMCollection>
    <xsl:choose>
      <xsl:when test="@Type='ccPMCollectionDependency'">
        <PMCollectionDependency>
          <UID><xsl:value-of select="@UID" /></UID>
          <All><xsl:value-of select="All" /></All>
          <Min><xsl:value-of select="Min" /></Min>
          <AlarmPeriod><xsl:value-of select="AlarmPeriod" /></AlarmPeriod>
        </PMCollectionDependency>
      </xsl:when>
      <xsl:when test="@Type='ccPMCollectionEntryRoute'">
        <PMCollectionEntryRoute>
          <UID><xsl:value-of select="@UID" /></UID>
        </PMCollectionEntryRoute> 
      </xsl:when>
      <xsl:when test="@Type='ccPMCollectionExitRoute'">
        <PMCollectionExitRoute>
          <UID><xsl:value-of select="@UID" /></UID>
        </PMCollectionExitRoute>
      </xsl:when>
    </xsl:choose>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/PartitionMemberManager/PMCollections/PMCollection/PMs/PM">
    <xsl:variable name="PMCollectionUID" select="./../../@UID" />
    <PMCollection_PartitionMember>
      <UID><xsl:value-of select="position()" /></UID>
      <Number><xsl:value-of select="Number" /></Number>
      <PMCollectionUID><xsl:value-of select="$PMCollectionUID" /></PMCollectionUID>
      <PartitionMemberUID><xsl:value-of select="UID" /></PartitionMemberUID>
    </PMCollection_PartitionMember>
  </xsl:template>
  

  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduleManager/Holidays/Holiday">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>Holiday</TableName>
    </UID>
    <Holiday>
      <UID><xsl:value-of select="@UID" /></UID>
      <xsl:choose>
      	<xsl:when test="@HolidayType">
      	  <Type><xsl:value-of select="@HolidayType" /></Type>
      	</xsl:when>
      	<xsl:otherwise>
      	  <Type>htFullDay</Type>
      	</xsl:otherwise>
      </xsl:choose>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:choose>
        <xsl:when test="contains(Date,'0000-')">
          <Day><xsl:value-of select="concat('2000',substring(Date,5,6))" /></Day>
          <Yearly>true</Yearly>
        </xsl:when>
        <xsl:otherwise>
          <Day><xsl:value-of select="Date" /></Day>
          <Yearly>false</Yearly>
        </xsl:otherwise>
      </xsl:choose>
    </Holiday>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/UserManager/Users/User">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>User</TableName>
    </UID>
    <User>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <Enabled><xsl:value-of select="Enabled" /></Enabled>
      <CodeData><xsl:value-of select="CodeData" /></CodeData>
      <CardData><xsl:value-of select="CardData" /></CardData>
      <RFFobData><xsl:value-of select="RFFobData" /></RFFobData>
      <xsl:choose>
	    <xsl:when test="StartDate or EndDate">
          <UnlimitedValidity>false</UnlimitedValidity>
        </xsl:when>
        <xsl:otherwise>
          <UnlimitedValidity>true</UnlimitedValidity>
        </xsl:otherwise>
      </xsl:choose>
      <ValidityStartDate><xsl:value-of select="StartDate" /></ValidityStartDate>
      <ValidityEndDate><xsl:value-of select="EndDate" /></ValidityEndDate>
    </User>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/UserManager/Users/User/UserGroups/UserGroup">  
    <xsl:variable name="UserUID" select="../../@UID" />
    <User_UserGroup>
      <UID><xsl:value-of select="position()" /></UID>
      <UserUID><xsl:value-of select="$UserUID" /></UserUID>
      <UserGroupUID><xsl:value-of select="." /></UserGroupUID>
    </User_UserGroup>  
  </xsl:template>
    
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/UserGroupManager/UserGroup">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>RTZ</TableName>
    </UID>
    <xsl:variable name="UserGroupUID" select="@UID" />
    <xsl:variable name="UserGroupPosition" select="position()" />
    <!-- in GCP each ScheduledItem can have a different Schedule, 
         in MB panels all scheduleditems in usergroup always share the same schedule (because GUI would be too complex), 
         therefore ScheduleUID is always read from first ScheduledItem -->
    <xsl:variable name="FirstScheduledItemUID" select="ScheduledItems/ScheduledItem" />
    <xsl:variable name="FirstScheduleUID" select="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduledItemManager/ScheduledItem[@UID=$FirstScheduledItemUID]/Schedule" />
    <UserGroup>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <ScheduleUID><xsl:value-of select="$FirstScheduleUID" /></ScheduleUID>
      <!-- sets helper flags - these flags are used for grid filtering (without these flags is not possible to write correct data filter) -->
      <xsl:if test="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduledItemManager/ScheduledItem[@UID=$FirstScheduledItemUID]/@Type='ccScheduledAccessPointGroup'">
        <APGFlag>true</APGFlag>
      </xsl:if>
      <xsl:if test="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduledItemManager/ScheduledItem[@UID=$FirstScheduledItemUID]/@Type='ccScheduledAccessControlMode'">
        <ACMFlag>true</ACMFlag>
      </xsl:if>
      <xsl:if test="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduledItemManager/ScheduledItem[@UID=$FirstScheduledItemUID]/@Type='ccScheduledDoorControlMode'">
        <DCMFlag>true</DCMFlag>
      </xsl:if>      
      <xsl:for-each select="Privileges/Privilege">
        <xsl:element name="{.}">true</xsl:element>
      </xsl:for-each>              
      <!-- according to Schedule type are set flags UseCalendar and Priority -->
      <xsl:for-each select="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduleManager/Schedules/Schedule[@UID=$FirstScheduleUID]">
        <UseCalendar>  	   	    
          <xsl:choose>	    
            <xsl:when test="@Type='ccSchedule'">false</xsl:when>
            <xsl:otherwise>true</xsl:otherwise>
          </xsl:choose>
         </UseCalendar>
         <Priority>
           <xsl:choose>
             <xsl:when test="@Type='ccDateSchedulePriority'">true</xsl:when>
             <xsl:otherwise>false</xsl:otherwise>
           </xsl:choose>	  
         </Priority>
      </xsl:for-each>
    </UserGroup>
    <!-- stores ScheduleUID into list of unique UIDs -->
    <UID>
      <UID><xsl:value-of select="$FirstScheduleUID" /></UID>
      <TableName>Schedule</TableName>
    </UID>
    <!-- Time schedules + day periods -->
    <xsl:for-each select="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduleManager/Schedules/Schedule[@UID=$FirstScheduleUID]">
      <xsl:variable name="SchedulePosition" select="position()" />
      <xsl:for-each select="TimeSchedules/TimeSchedule">
        <UserGroup_TimeSchedule>
          <UID><xsl:value-of select="$UserGroupPosition*1000000+$SchedulePosition*1000+position()" /></UID>
          <UserGroupUID><xsl:value-of select="$UserGroupUID" /></UserGroupUID>
          <TimeScheduleUID><xsl:value-of select="." /></TimeScheduleUID>
        </UserGroup_TimeSchedule>
      </xsl:for-each>
      <xsl:for-each select="DatePeriods/DatePeriod">
        <DatePeriod>
          <UID><xsl:value-of select="$UserGroupPosition*1000000+$SchedulePosition*1000+position()" /></UID>
          <UserGroupUID><xsl:value-of select="$UserGroupUID" /></UserGroupUID>
          <StartDate><xsl:value-of select="StartDate" /></StartDate>
          <EndDate><xsl:value-of select="EndDate" /></EndDate>
          <Yearly><xsl:value-of select="Yearly" /></Yearly>
        </DatePeriod>
      </xsl:for-each>
    </xsl:for-each>    
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/UserGroupManager/UserGroup/ScheduledItems/ScheduledItem"> 
    <xsl:variable name="UserGroupUID" select="../../@UID" />
    <xsl:variable name="ScheduledItemUID" select="." />
    <UserGroup_ScheduledItem>
      <UID><xsl:value-of select="position()" /></UID>      
      <UserGroupUID><xsl:value-of select="$UserGroupUID" /></UserGroupUID>
      <ScheduledItemUID><xsl:value-of select="$ScheduledItemUID" /></ScheduledItemUID>    
      <expUserGroupType><xsl:value-of select="/PanelConfiguration/Panel/Application/ApplicationManager/UserGroupManager/UserGroup[@UID=$UserGroupUID]/@Type" /></expUserGroupType>
      <expScheduledItemType><xsl:value-of select="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduledItemManager/ScheduledItem[@UID=$ScheduledItemUID]/@Type" /></expScheduledItemType>
    </UserGroup_ScheduledItem>  
  </xsl:template>
   
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduledItemManager/ScheduledItem">
    <xsl:variable name="ScheduledItemUID" select="@UID" />
    <xsl:variable name="ScheduledItemType" select="@Type" />
    <xsl:variable name="UserGroupUID" select="/PanelConfiguration/Panel/Application/ApplicationManager/UserGroupManager/UserGroup[ScheduledItems/ScheduledItem=$ScheduledItemUID]/@UID" />
    <xsl:variable name="ScheduledItemPosition" select="position()" />
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>ScheduledItem</TableName>
    </UID> 
    <ScheduledItem>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>
      <ControlMode><xsl:value-of select="ControlMode" /></ControlMode>
    </ScheduledItem>
    <xsl:for-each select="AccessPoints/AccessPoint">
      <xsl:choose>
        <!-- mapping rows for RTZ (ScheduledAccessPointGroup) -->
        <xsl:when test="$ScheduledItemType='ccScheduledAccessPointGroup'">
          <ScheduledItem_APGroup>
            <!-- uid in mapping table is calculated as group number * 2000 + number of accesspoint in accesspoint group -->
            <UID><xsl:value-of select="$ScheduledItemPosition*2000 + position()" /></UID>
            <ScheduledItemUID><xsl:value-of select="$ScheduledItemUID" /></ScheduledItemUID>
            <AccessPointUID><xsl:value-of select="@UID" /></AccessPointUID>
            <xsl:for-each select="Privileges/Privilege">
              <xsl:element name="{.}">true</xsl:element>
            </xsl:for-each>
          </ScheduledItem_APGroup>
        </xsl:when>
        <!-- mapping rows for AccessControlMode (ScheduledAccessControlMode) -->
        <xsl:when test="$ScheduledItemType='ccScheduledAccessControlMode'">
          <ScheduledItem_AP>
            <UID><xsl:value-of select="$ScheduledItemPosition*2000 + position()" /></UID>
            <ScheduledItemUID><xsl:value-of select="$ScheduledItemUID" /></ScheduledItemUID>
            <AccessPointUID><xsl:value-of select="." /></AccessPointUID>
            <Valid>true</Valid>
          </ScheduledItem_AP>
        </xsl:when>
      </xsl:choose>
    </xsl:for-each>
    <xsl:for-each select="Doors/Door">
      <ScheduledItem_Door>
        <!-- uid in mapping table is calculated as group number * 2000 + door position -->
        <UID><xsl:value-of select="$ScheduledItemPosition*2000 + position()" /></UID>
        <ScheduledItemUID><xsl:value-of select="$ScheduledItemUID" /></ScheduledItemUID>
        <DoorUID><xsl:value-of select="." /></DoorUID>
      </ScheduledItem_Door>
    </xsl:for-each>
    <xsl:for-each select="UIProxies/UIProxy">
      <ScheduledItem_UIProxy>
        <UID><xsl:value-of select="$ScheduledItemPosition*2000 + position()" /></UID>
        <ScheduledItemUID><xsl:value-of select="$ScheduledItemUID" /></ScheduledItemUID>
        <UIProxyUID><xsl:value-of select="." /></UIProxyUID>
      </ScheduledItem_UIProxy>
    </xsl:for-each>
    <xsl:for-each select="Partitions/Partition">
      <ScheduledItem_Partition>
        <UID><xsl:value-of select="$ScheduledItemPosition*2000 + position()" /></UID>
        <ScheduledItemUID><xsl:value-of select="$ScheduledItemUID" /></ScheduledItemUID>
        <PartitionUID><xsl:value-of select="." /></PartitionUID>
      </ScheduledItem_Partition>
    </xsl:for-each>    
  </xsl:template>
    
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/ScheduleManager/TimeSchedules/TimeSchedule">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>TimeSchedule</TableName>
    </UID>  
    <TimeSchedule>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="Weekdays/Weekday">
        <xsl:variable name="DayName" select="." />
        <xsl:element name="{substring($DayName,4)}">true</xsl:element>
      </xsl:for-each>
      <ExpiredDay><xsl:value-of select="ExpiredDay" /></ExpiredDay>
    </TimeSchedule>
    <xsl:variable name="TimeScheduleUID" select="@UID" />
    <xsl:for-each select="TimePeriods/TimePeriod">
      <TimePeriod>
        <TimeScheduleUID><xsl:value-of select="$TimeScheduleUID" /></TimeScheduleUID>
        <StartTime><xsl:value-of select="StartTime" /></StartTime>
        <EndTime><xsl:value-of select="EndTime" /></EndTime>
        <Position><xsl:value-of select="position()" /></Position>
        <Enabled>true</Enabled>
      </TimePeriod>
    </xsl:for-each>
  </xsl:template>  
    
  <xsl:template match="/PanelConfiguration/Panel/Application/ApplicationManager/EventLogs/EventLog">  
  
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/Macros/TriggerPool/Trigger">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>Trigger</TableName>
    </UID>  
    <Trigger>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <GeneratorUID><xsl:value-of select="GeneratorUID" /></GeneratorUID>
    </Trigger>
    <xsl:variable name="tableName">
      <xsl:value-of select="concat('Trigger_',substring(@Type,10,100))" />
    </xsl:variable>
    <xsl:element name="{$tableName}">
      <!-- iterates the rest of command parameters and stores them into extra table -->
      <UID><xsl:value-of select="@UID" /></UID>
      <xsl:for-each select="*">
        <xsl:if test="(name()!='Name') and (name()!='GeneratorUID')">
          <xsl:element name="{name()}"><xsl:value-of select="." /></xsl:element>
        </xsl:if>
      </xsl:for-each>
    </xsl:element> 
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/Macros/ConditionPool/Condition">  
    <xsl:variable name="UID">1</xsl:variable>
    <xsl:variable name="ConditionUID"><xsl:value-of select="@UID" /></xsl:variable>
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>Condition</TableName>
    </UID>
    <Condition>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <ExpressionRootUID>1</ExpressionRootUID>
    </Condition>
    <xsl:for-each select="ExpressionRoot">
      <xsl:call-template name="ReadExpression">
        <xsl:with-param name="ConditionUID" select="$ConditionUID" />
        <xsl:with-param name="NewExpressionUID" select="1" />
        <xsl:with-param name="ParentExpressionUID" select="0" />
      </xsl:call-template>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/Macros/SignalPool/Signal">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>Signal</TableName>
    </UID>
    <Signal>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <SourceUID><xsl:value-of select="Ref" /></SourceUID>
      <Inverted><xsl:value-of select="Inverted" /></Inverted>
      <SingleEdge><xsl:value-of select="SingleEdge" /></SingleEdge>
      <Impulse><xsl:value-of select="Impulse" /></Impulse>
    </Signal>         
  </xsl:template>  
  
  <xsl:template name="ReadExpression">
    <xsl:param name="ConditionUID" />
    <xsl:param name="NewExpressionUID" />
    <xsl:param name="ParentExpressionUID" />
    <xsl:variable name="MAXTREENODESINBRANCH" select="20" /><!-- constant must have the same value in XSL and in C# -->
    <Expression>
      <ExpressionUID><xsl:value-of select="$NewExpressionUID" /></ExpressionUID>
      <ConditionUID><xsl:value-of select="$ConditionUID" /></ConditionUID>
      <Type><xsl:value-of select="@Type" /></Type>
      <xsl:if test="@Type='ccAtomic'">
        <xsl:if test="@TriggerRef>0">
          <TriggerUID><xsl:value-of select="@TriggerRef" /></TriggerUID>				
        </xsl:if>
      </xsl:if>
      <xsl:if test="$ParentExpressionUID>0">
        <ParentExpressionUID><xsl:value-of select="$ParentExpressionUID" /></ParentExpressionUID>
      </xsl:if>
    </Expression>
    <xsl:if test="@Type!='ccAtomic'">
      <xsl:for-each select="Expression">
        <xsl:if test="position()&lt;=$MAXTREENODESINBRANCH">
          <xsl:variable name="NewUID" select="($NewExpressionUID+position()-1)*($MAXTREENODESINBRANCH+1)" />
          <xsl:call-template name="ReadExpression">
            <xsl:with-param name="ConditionUID" select="$ConditionUID" />
            <xsl:with-param name="NewExpressionUID" select="$NewUID" />
            <xsl:with-param name="ParentExpressionUID" select="$NewExpressionUID" />
          </xsl:call-template>
        </xsl:if>
      </xsl:for-each>
    </xsl:if>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/Macros/CommandPool/Command">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>Command</TableName>
    </UID>
    <Command>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <ExecutorUID><xsl:value-of select="ExecutorUID" /></ExecutorUID>
    </Command>
    <xsl:variable name="tableName"><xsl:value-of select="concat('Command_',substring(@Type,9,100))" /></xsl:variable>
    <xsl:element name="{$tableName}">
      <!-- iterates the rest of command parameters and stores them into extra table -->
      <UID><xsl:value-of select="@UID" /></UID>
      <xsl:for-each select="*">
        <xsl:if test="(name()!='Name') and (name()!='ExecutorUID')">
          <xsl:element name="{name()}"><xsl:value-of select="." /></xsl:element>
        </xsl:if>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/Macros/ActionPool/Action">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>Action</TableName>
    </UID>
    <Action>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
    </Action>
    <xsl:variable name="ActionUID" select="@UID" />
    <xsl:for-each select="ActionList/CommandRef">
    </xsl:for-each>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/Macros/ActionPool/Action/ActionList/CommandRef">
    <xsl:variable name="ActionUID" select="./../../@UID" />
    <Action_Command>
      <UID><xsl:value-of select="position()" /></UID>
      <Action_UID><xsl:value-of select="$ActionUID" /></Action_UID>
      <Command_UID><xsl:value-of select="." /></Command_UID>
    </Action_Command>
  </xsl:template>
  

  <xsl:template match="/PanelConfiguration/Panel/Application/Macros/MacroPool/Macro">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>Macro</TableName>
    </UID>
    <Macro>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <ConditionUID><xsl:value-of select="ConditionRef" /></ConditionUID>      
      <ActionOnUID><xsl:value-of select="ActionRef" /></ActionOnUID>
      <ActionOffUID><xsl:value-of select="ActionRef2" /></ActionOffUID>
    </Macro>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/Application/UserInterfaceManager/UIProxy">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>UIProxy</TableName>
    </UID>
    <UIProxy>
      <UID><xsl:value-of select="@UID" /></UID>
      <Name><xsl:value-of select="Name" /></Name>
      <Type><xsl:value-of select="@Type" /></Type>      
    </UIProxy>
    <xsl:choose>
      <xsl:when test="@Type='ccUITouchCenter'">
        <UITouchCenter>
          <UID><xsl:value-of select="@UID" /></UID>
          <LogicalSmartUI_UID><xsl:value-of select="HWUID" /></LogicalSmartUI_UID>
          <Language><xsl:value-of select="Language" /></Language>
          <TamperPartitionUID><xsl:value-of select="TamperPartition" /></TamperPartitionUID>
          <PreferedPartitionUID><xsl:value-of select="PreferedPartition" /></PreferedPartitionUID>
          <AmountCodeInput><xsl:value-of select="AmountCodeInput" /></AmountCodeInput>
          <OperatingTime><xsl:value-of select="OperatingTime" /></OperatingTime>
          <BlockingTime><xsl:value-of select="BlockingTime" /></BlockingTime>
          <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>
        </UITouchCenter>
      </xsl:when>
      <xsl:otherwise>
        <UIKeypad>
          <UID><xsl:value-of select="@UID" /></UID>
          <LogicalKeyboardReaderUID><xsl:value-of select="HWUID" /></LogicalKeyboardReaderUID>
          <LogicalPeripheralUID><xsl:value-of select="HWUIDPeripheral" /></LogicalPeripheralUID>
          <LogicalDisplayUID><xsl:value-of select="HWUIDDisplay" /></LogicalDisplayUID>
          <OwnerKeypadUID><xsl:value-of select="Owner" /></OwnerKeypadUID>
          <OperatingTime><xsl:value-of select="OperatingTime" /></OperatingTime>
          <Indication><xsl:value-of select="Indication" /></Indication>
          <Operating><xsl:value-of select="Operating" /></Operating>
        </UIKeypad>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/UserInterfaceManager/UIProxy/Partitions/UID">
    <xsl:variable name="UIProxyUID" select="../../@UID" />
    <UITouchCenter_Partition>
      <UID><xsl:value-of select="position()" /></UID>
      <UIProxyUID><xsl:value-of select="$UIProxyUID" /></UIProxyUID>
      <PartitionUID><xsl:value-of select="." /></PartitionUID>
    </UITouchCenter_Partition>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/UserInterfaceManager/UIProxy/Items/Item">
    <xsl:variable name="UIProxyUID" select="../../@UID" />
    <UIKeypadItem>
      <UID><xsl:value-of select="position()" /></UID> <!-- autonumbering is used, because in panel xml is no such UID -->
      <UIKeypadUID><xsl:value-of select="$UIProxyUID" /></UIKeypadUID>
      <!-- common part -->
      <Number><xsl:value-of select="Number" /></Number>
      <LogicalLedUID><xsl:value-of select="Led" /></LogicalLedUID>
      <Function><xsl:value-of select="Function" /></Function>
      <Indication><xsl:value-of select="Indication" /></Indication>
      <!-- signal part -->
      <RedLed_SignalUID><xsl:value-of select="SignalRed" /></RedLed_SignalUID>
      <YellowLed_SignalUID><xsl:value-of select="SignalYellow" /></YellowLed_SignalUID>
      <GreenLed_SignalUID><xsl:value-of select="SignalGreen" /></GreenLed_SignalUID>
      <!-- function part -->
      <LogicalKeyUID><xsl:value-of select="Key" /></LogicalKeyUID>
      <Operating><xsl:value-of select="Operating" /></Operating>
      <Operating2><xsl:value-of select="Operating2" /></Operating2>
      <TargetDeviceUID><xsl:value-of select="UID" /></TargetDeviceUID>
    </UIKeypadItem>
  </xsl:template>
      
  <xsl:template match="/PanelConfiguration/Panel/Application/RemoteApplicationManager/Connections/RemoteApplication">
    <RemoteApplication>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <IPAddress><xsl:value-of select="Port/@IP" /></IPAddress>
      <Port><xsl:value-of select="Port/@Port" /></Port>
      <SocketType><xsl:value-of select="Port/@Type" /></SocketType>
      <Protocol><xsl:value-of select="Port/@TCPUDP" /></Protocol>
      <Blocking><xsl:value-of select="Port/@Blocking" /></Blocking>
      <Interval><xsl:value-of select="Interval" /></Interval>
      <PassWD><xsl:value-of select="Password" /></PassWD>
    </RemoteApplication>  
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/AlarmReportingManager/AlarmDevices/AlarmDevice">  
    <xsl:variable name="AlarmDeviceUID" select="@UID" />
    <UID>
      <UID><xsl:value-of select="$AlarmDeviceUID" /></UID>
      <TableName>AlarmDevice</TableName>
    </UID>
    <AlarmDevice>
      <UID><xsl:value-of select="$AlarmDeviceUID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <VirtualDSDeviceUID><xsl:value-of select="VirtualDSDevice" /></VirtualDSDeviceUID>
      <PartitionUID><xsl:value-of select="Partition" /></PartitionUID>
      <SendDescription><xsl:value-of select="Description" /></SendDescription>
      <CommFailureEffect><xsl:value-of select="FaultTypes/FaultType[Type='ftCommFailure']/Effect" /></CommFailureEffect>
      <WireFaultEffect><xsl:value-of select="FaultTypes/FaultType[Type='ftWireFault']/Effect" /></WireFaultEffect>
    </AlarmDevice>
    <AlarmDevice_FaultType>
      <AlarmDeviceUID><xsl:value-of select="$AlarmDeviceUID" /></AlarmDeviceUID>
      <CommFailureEffect><xsl:value-of select="FaultTypes/FaultType[Type='ftCommFailure']/Effect" /></CommFailureEffect>
      <WireFaultEffect><xsl:value-of select="FaultTypes/FaultType[Type='ftWireFault']/Effect" /></WireFaultEffect>
    </AlarmDevice_FaultType>
    <xsl:for-each select="Channels/Channel">
      <Channel>
        <AlarmDeviceUID><xsl:value-of select="$AlarmDeviceUID" /></AlarmDeviceUID>
        <Type><xsl:value-of select="@Type" /></Type>
        <Number><xsl:value-of select="@Number" /></Number>
        <xsl:choose>
          <xsl:when test="@Type='Alarm'">
            <SignalUID><xsl:value-of select="@Partition" /></SignalUID>
            <PartitionAlarmType><xsl:value-of select="@AlarmType" /></PartitionAlarmType>
 		  </xsl:when>
          <xsl:when test="@Type='Signal'">
			<SignalUID><xsl:value-of select="@Ref" /></SignalUID>
          </xsl:when>
          <xsl:otherwise>
            <!-- channels with empty type are not included into xml -->
          </xsl:otherwise>
        </xsl:choose>
        <Inverted><xsl:value-of select="@Inverted" /></Inverted>
        <SingleEdge><xsl:value-of select="@SingleEdge" /></SingleEdge>
        <Impulse><xsl:value-of select="@Impulse" /></Impulse>
      </Channel>
    </xsl:for-each>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/Application/AlarmReportingManager/AlarmDevices/AlarmDevice/FaultPartitions/UID">  
    <xsl:variable name="AlarmDeviceUID" select="../../@UID" />
    <AlarmDevice_FaultPartition>
      <UID><xsl:value-of select="position()" /></UID>
      <AlarmDeviceUID><xsl:value-of select="$AlarmDeviceUID" /></AlarmDeviceUID>
      <PartitionUID><xsl:value-of select="." /></PartitionUID>
    </AlarmDevice_FaultPartition>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalInputs/LogicalInput">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalInput</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <xsl:for-each select="//ConfiguredDevices/*[Inputs/Input/LDUID=$LDUID]">
      <xsl:for-each select="Inputs/Input[LDUID=$LDUID]">
        <UID>
          <UID><xsl:value-of select="@UID" /></UID> 
          <TableName>LogicalInput</TableName>
        </UID>
      </xsl:for-each>
	</xsl:for-each>        
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <!--inserts HardwareDeviceUID in various ways -->      
      <xsl:for-each select="//ConfiguredDevices/*[Inputs/Input/LDUID=$LDUID]">
        <xsl:for-each select="Inputs/Input[LDUID=$LDUID]">
          <ClassType><xsl:value-of select="@Type" /></ClassType>
          <ClassUID><xsl:value-of select="@UID" /></ClassUID> 
          <Number><xsl:value-of select="Number" /></Number>
          <Parameter><xsl:value-of select="Param" /></Parameter>
        </xsl:for-each>
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
      <xsl:for-each select="//GPIO/GPIOInputs/GPIOInput[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
      <xsl:for-each select="//GPIO/SPIInputs/SPIInput[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
      <xsl:for-each select="//GPIO/AnalogInputs/AnalogInput[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>       
      <!-- end of HardwareDeviceUID -->
    </LogicalDevice>
    <LogicalInput>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalInput>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalOutputs/LogicalOutput">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalOutput</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <xsl:for-each select="//ConfiguredDevices/*[Outputs/Output/LDUID=$LDUID]">
      <xsl:for-each select="Outputs/Output[LDUID=$LDUID]">
        <UID>
          <UID><xsl:value-of select="@UID" /></UID> 
          <TableName>LogicalOutput</TableName>
        </UID>
      </xsl:for-each>
	</xsl:for-each>            
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <!--inserts HardwareDeviceUID in various ways -->
      <xsl:for-each select="//ConfiguredDevices/*[Outputs/Output/LDUID=$LDUID]">
        <xsl:for-each select="Outputs/Output[LDUID=$LDUID]">
          <ClassType><xsl:value-of select="@Type" /></ClassType>
          <ClassUID><xsl:value-of select="@UID" /></ClassUID> 
          <Number><xsl:value-of select="Number" /></Number>
        </xsl:for-each>
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
      <xsl:for-each select="//GPIO/GPIOOutputs/GPIOOutput[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
      <xsl:for-each select="//GPIO/SPIOutputs/SPIOutput[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
      <!-- end of HardwareDeviceUID -->
    </LogicalDevice>
    <LogicalOutput>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalOutput>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalPirs/LogicalPir">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalPIR</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalPIR>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalPIR>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalSounders/LogicalSounder">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalSounder</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />    
    <xsl:for-each select="//ConfiguredDevices/*[Sounder/LDUID=$LDUID]">
      <xsl:for-each select="Sounder">
        <UID>
          <UID><xsl:value-of select="@UID" /></UID> 
          <TableName>LogicalSounder</TableName>
        </UID>
      </xsl:for-each>      
    </xsl:for-each>        
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name> 
      <xsl:for-each select="//ConfiguredDevices/*[Sounder/LDUID=$LDUID]">
        <xsl:for-each select="Sounder">
          <ClassType><xsl:value-of select="@Type" /></ClassType>
          <ClassUID><xsl:value-of select="@UID" /></ClassUID> 
          <Number><xsl:value-of select="Number" /></Number>
        </xsl:for-each>      
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalSounder>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalSounder>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalKeys/LogicalKey">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalKey</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>      
      <!--inserts HardwareDeviceUID in various ways -->
      <xsl:for-each select="//ConfiguredDevices/*[Keys/Key/LDUID=$LDUID]">
        <xsl:for-each select="Keys/Key[LDUID=$LDUID]">
          <ClassType><xsl:value-of select="@Type" /></ClassType>
          <ClassUID><xsl:value-of select="@UID" /></ClassUID> 
          <Number><xsl:value-of select="Number" /></Number>
        </xsl:for-each>
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
      <!-- end of HardwareDeviceUID -->
    </LogicalDevice>
    <LogicalKey>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalKey>  
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalLeds/LogicalLed">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalLed</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>      
      <!--inserts HardwareDeviceUID in various ways -->
      <xsl:for-each select="//ConfiguredDevices/*[Leds/Led/LDUID=$LDUID]">
        <xsl:for-each select="Leds/Led[LDUID=$LDUID]">
          <ClassType><xsl:value-of select="@Type" /></ClassType>
          <ClassUID><xsl:value-of select="@UID" /></ClassUID> 
          <Number><xsl:value-of select="Number" /></Number>
        </xsl:for-each>
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
      <!-- end of HardwareDeviceUID -->
    </LogicalDevice>
    <LogicalLed>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalLed>
  </xsl:template>
  
  
  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalSounders/SounderTemplates/SounderTemplate">
    <UID>
      <UID><xsl:value-of select="Number" /></UID>
      <TableName>SounderTemplate</TableName>
    </UID>
    <SounderTemplate>
      <UID><xsl:value-of select="Number" /></UID>
      <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="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalEmails/LogicalEmail">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalEmail</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalEmail>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalEmail>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalSMSs/LogicalSMS">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalSMS</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name> 
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalSMS>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalSMS>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalReaders/LogicalReader">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalReader</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name> 
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalReader>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalReader>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalKeyboards/LogicalKeyboard">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalKeyboard</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name> 
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalKeyboard>
      <UID><xsl:value-of select="@UID" /></UID>      
    </LogicalKeyboard>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalKeyboardReaders/LogicalKeyboardReader">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalKeyboardReader</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalKeyboardReader>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalKeyboardReader>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalKeypads/LogicalKeypad">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalKeypad</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalKeypad>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalKeypad>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalSmartUIs/LogicalSmartUI">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalSmartUI</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalSmartUI>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalSmartUI>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalCameras/LogicalCamera">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalCamera</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalCamera>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalCamera>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalCarbonMonoxides/LogicalCarbonMonoxide">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalCarbonMonoxide</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name> 
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalCarbonMonoxide>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalCarbonMonoxide>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalDisplays/LogicalDisplay">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalDisplay</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name> 
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalDisplay>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalDisplay>            
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalDoors/LogicalDoor">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalDoor</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />    
    <xsl:for-each select="//ConfiguredDevices/*[Doors/Door/LDUID=$LDUID]">
      <xsl:for-each select="Doors/Door[LDUID=$LDUID]">
        <UID>
          <UID><xsl:value-of select="@UID" /></UID>
          <TableName>LogicalDoor</TableName>
        </UID>
      </xsl:for-each>
    </xsl:for-each>        
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[Doors/Door/LDUID=$LDUID]">
        <xsl:for-each select="Doors/Door[LDUID=$LDUID]">
          <ClassType><xsl:value-of select="@Type" /></ClassType>
          <ClassUID><xsl:value-of select="@UID" /></ClassUID> 
          <Number><xsl:value-of select="Number" /></Number>
        </xsl:for-each>
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalDoor>
      <UID><xsl:value-of select="@UID" /></UID>
      <xsl:for-each select="//Doors/Door[LDUID=$LDUID]">
        <DoorNumber><xsl:value-of select="Number" /></DoorNumber>
      </xsl:for-each>
    </LogicalDoor>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalAccessPoints/LogicalAccessPoint">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalAccessPoint</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <xsl:for-each select="//ConfiguredDevices/*[AccessPoints/AccessPoint/LDUID=$LDUID]">
      <xsl:for-each select="AccessPoints/AccessPoint[LDUID=$LDUID]">
        <UID><xsl:value-of select="@UID" /></UID> 
        <TableName>LogicalAccessPoint</TableName>
      </xsl:for-each>
    </xsl:for-each>    
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name> 
      <xsl:for-each select="//ConfiguredDevices/*[AccessPoints/AccessPoint/LDUID=$LDUID]">
        <xsl:for-each select="AccessPoints/AccessPoint[LDUID=$LDUID]">
          <ClassType><xsl:value-of select="@Type" /></ClassType>
          <ClassUID><xsl:value-of select="@UID" /></ClassUID> 
          <Number><xsl:value-of select="Number" /></Number>         
        </xsl:for-each>
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalAccessPoint>
      <UID><xsl:value-of select="@UID" /></UID>
      <xsl:variable name="UID"><xsl:value-of select="@UID" /></xsl:variable>
      <xsl:for-each select="//ConfiguredDevices/*/AccessPoints/AccessPoint[LDUID=$UID]">
        <DoorNumber><xsl:value-of select="DoorNumber" /></DoorNumber>
        <DoorOutside><xsl:value-of select="DoorOutside" /></DoorOutside>
      </xsl:for-each>
    </LogicalAccessPoint>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalEventBroadcasters/LogicalEventBroadcaster">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalEventBroadCaster</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalEventBroadcaster>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalEventBroadcaster>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalPeripherals/LogicalPeripheral">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalPeripheral</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />    
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDPeripheral=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalPeripheral>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalPeripheral>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalRFPeripherals/LogicalRFPeripheral">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalWirelessPeripheral</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />    
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDRFPeripheral=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalWirelessPeripheral>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalWirelessPeripheral>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalRFMasters/LogicalRFMaster">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalRFMaster</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />    
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalWirelessMaster>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalWirelessMaster>
  </xsl:template>  

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalSmokeDetectors/LogicalSmokeDetector">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalSmokeDetector</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />    
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalSmokeDetector>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalSmokeDetector>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalTemperatures/LogicalTemperature">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalTemperature</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />    
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalTemperature>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalTemperature>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalDSAlarmReportings/LogicalDSAlarmReporting">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalDSAlarmReporting</TableName>
    </UID>  
    <xsl:variable name="LDUID" select="@UID" />    
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDUID=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalDSAlarmReporting>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalDSAlarmReporting>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/LogicalDevices/LogicalInstallationServices/LogicalInstallationService">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>LogicalInstaService</TableName>
    </UID>
    <xsl:variable name="LDUID" select="@UID" />    
    <LogicalDevice>
      <UID><xsl:value-of select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <xsl:for-each select="//ConfiguredDevices/*[LDInstallServices=$LDUID]">
        <HardwareDeviceUID><xsl:value-of select="@UID" /></HardwareDeviceUID>
      </xsl:for-each>
    </LogicalDevice>
    <LogicalInstallService>
      <UID><xsl:value-of select="@UID" /></UID>
    </LogicalInstallService>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/GPIO/GPIOInputs/GPIOInput">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>GPIOInput</TableName>
    </UID>
    <HardwareDevice>
      <UID><xsl:value-of  select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <Address><xsl:value-of select="Address" /></Address>
      <OnboardDevice>true</OnboardDevice>
    </HardwareDevice>
    <HWGPIOInput>
      <UID><xsl:value-of  select="@UID" /></UID>      
      <LogicalInputUID><xsl:value-of select="LDUID" /></LogicalInputUID>
    </HWGPIOInput>  
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/GPIO/GPIOOutputs/GPIOOutput">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>GPIOOutput</TableName>
    </UID>
    <HardwareDevice>
      <UID><xsl:value-of  select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <Address><xsl:value-of select="Address" /></Address>
      <OnboardDevice>true</OnboardDevice>
    </HardwareDevice>
    <HWGPIOOutput>
      <UID><xsl:value-of  select="@UID" /></UID>      
      <LogicalOutputUID><xsl:value-of select="LDUID" /></LogicalOutputUID>
    </HWGPIOOutput>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/GPIO/SPIInputs/SPIInput">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>SPIInput</TableName>
    </UID>  
    <HardwareDevice>
      <UID><xsl:value-of  select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <Address><xsl:value-of select="Address" /></Address>
      <OnboardDevice>true</OnboardDevice>
    </HardwareDevice>
    <HWSPIInput>
      <UID><xsl:value-of  select="@UID" /></UID>      
      <LogicalInputUID><xsl:value-of select="LDUID" /></LogicalInputUID>
    </HWSPIInput>
  </xsl:template>

  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/GPIO/SPIOutputs/SPIOutput">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>SPIOutput</TableName>
    </UID>
    <HardwareDevice>
      <UID><xsl:value-of  select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <Address><xsl:value-of select="Address" /></Address>      
      <OnboardDevice>true</OnboardDevice>
    </HardwareDevice>
    <HWSPIOutput>
      <UID><xsl:value-of  select="@UID" /></UID>      
      <LogicalOutputUID><xsl:value-of select="LDUID" /></LogicalOutputUID>
    </HWSPIOutput>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/GPIO/AnalogInputs/AnalogInput">
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>AnalogInput</TableName>
    </UID>
    <HardwareDevice>
      <UID><xsl:value-of  select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <Address><xsl:value-of select="Address" /></Address>      
      <OnboardDevice>true</OnboardDevice>
    </HardwareDevice>
    <HWAnalogInput>
      <UID><xsl:value-of  select="@UID" /></UID>      
      <LogicalInputUID><xsl:value-of select="LDUID" /></LogicalInputUID>
      <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>
    </HWAnalogInput>
  </xsl:template>
  
  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/BusController/Controller"> 
    <xsl:call-template name="ReadControllers">
      <xsl:with-param name="OwnerUID"><xsl:value-of select="/PanelConfiguration/Panel/@UID" /></xsl:with-param>
    </xsl:call-template>  
  </xsl:template>
  
  
  <xsl:template match="/PanelConfiguration/Panel/HardwareManager/SupportController/Controller">
    <xsl:call-template name="ReadControllers">
      <xsl:with-param name="OwnerUID"><xsl:value-of select="0" /></xsl:with-param>
    </xsl:call-template>  
  </xsl:template> 
  
  <xsl:template match="//ConfiguredDevices/*/WirelessMasters/UID">
    <xsl:param name="DeviceUID" select="./../../@UID" />
    <WirelessMaster>
      <UID><xsl:value-of select="position()" /></UID>
      <DeviceUID><xsl:value-of select="$DeviceUID" /></DeviceUID>
      <MasterUID><xsl:value-of select="." /></MasterUID>	  
    </WirelessMaster>
  </xsl:template> 
  
  <xsl:template name="ReadControllers">
    <xsl:param name="OwnerUID" />
    <!-- loads all controllers -->
    <xsl:variable name="PanelUID"><xsl:value-of select="/PanelConfiguration/Panel/@UID" /></xsl:variable>
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>HardwareDevice</TableName>
    </UID>
    <HardwareDevice>
      <UID><xsl:value-of  select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <Address><xsl:value-of select="Address" /></Address>
      <xsl:if test="$OwnerUID>0">
        <ParentDeviceUID><xsl:value-of select="$OwnerUID" /></ParentDeviceUID>
      </xsl:if>
      <!-- first level of hardware devices (controllers) is connected directly to the panel, therefore onboard flag is set-->
      <OnboardController>true</OnboardController>
      <PartitionTamper><xsl:value-of select="PartitionTamper" /></PartitionTamper>
      <TamperOnLoss><xsl:value-of select="TamperOnLoss" /></TamperOnLoss>
      <!-- In this case columns SubdeviceUID and SubdeviceType are not used -->
    </HardwareDevice>
    <Controller>
      <UID><xsl:value-of select="@UID" /></UID>
    </Controller>
    <xsl:variable name="DeviceUID"><xsl:value-of select="@UID" /></xsl:variable>
    <xsl:variable name="DeviceType"><xsl:value-of select="@Type" /></xsl:variable>
    <xsl:call-template name="ReadPortSettings">
      <xsl:with-param name="DeviceUID" select="$DeviceUID" />
    </xsl:call-template>
    <xsl:call-template name="ReadHardwareDeviceProperties">
      <xsl:with-param name="DeviceUID" select="$DeviceUID"/>
      <xsl:with-param name="DeviceType" select="$DeviceType"/>
    </xsl:call-template>

    <!-- loads list of configured devices -->
    <xsl:for-each select="ConfiguredDevices/BusDevice">
      <xsl:call-template name="LoadConfiguredDevice">
        <xsl:with-param name="ControllerUID" select="$DeviceUID" />
        <xsl:with-param name="WirelessDevice" select="'false'" />
      </xsl:call-template>
    </xsl:for-each>
    <xsl:for-each select="ConfiguredDevices/WirelessDevice">
      <xsl:call-template name="LoadConfiguredDevice">
        <xsl:with-param name="ControllerUID" select="$DeviceUID" />
        <xsl:with-param name="WirelessDevice" select="'true'" />
      </xsl:call-template>
    </xsl:for-each>
    
    <!--ConfiguredDevice tag is no longer supported -->
    <xsl:for-each select="ConfiguredDevices/ConfiguredDevice">
      <xsl:call-template name="LoadConfiguredDevice">
        <xsl:with-param name="ControllerUID" select="$DeviceUID" />
        <xsl:with-param name="WirelessDevice" select="'false'" />
      </xsl:call-template>
    </xsl:for-each>

  </xsl:template>


  <xsl:template name="ReadPortSettings">
    <xsl:param name="DeviceUID" />
    <xsl:variable name="PortCount"><xsl:value-of select="count(Port)" /></xsl:variable>
    <xsl:if test="$PortCount>0">
      <Port>
        <Name><xsl:value-of select="Port/@Name" /></Name>
        <Hardware><xsl:value-of select="Port/@Hardware" /></Hardware>
        <Mode><xsl:value-of select="Port/@Mode" /></Mode>
        <BaudRate><xsl:value-of select="Port/@BaudRate" /></BaudRate>
        <DataBits><xsl:value-of select="Port/@DataBits" /></DataBits>
        <StopBits><xsl:value-of select="Port/@StopBits" /></StopBits>
        <Parity><xsl:value-of select="Port/@Parity" /></Parity>
        <ControllerUID><xsl:value-of select="$DeviceUID" /></ControllerUID>
      </Port>
    </xsl:if>
  </xsl:template>

  <xsl:template name="ReadHardwareDeviceProperties">
    <xsl:param name="DeviceUID" />
    <xsl:param name="DeviceType" />
    
    <!-- cuts the prefix cc and adds prefix HW, e.g. "ccBus25InputModule"->"HWBus25InputModule" -->
    <xsl:variable name="tableName"><xsl:value-of select="concat('HW',substring($DeviceType,3,100))" /></xsl:variable>
       
    <!-- creates device specific table, e.g. HWBus25InputModule -->
    <xsl:if test="string-length($tableName)>0">
      <xsl:element name="{$tableName}">
        <UID><xsl:value-of select="$DeviceUID" /></UID>
        <xsl:for-each select="./*">
          <!-- main purpose is to iterate all unknown tags, therefore all well known tags are skipped (list of all known hardware device tags is quite long)-->
          <xsl:if test="(name()!='Name') and (name()!='Address') and (name()!='Port') and (name()!='Controller') and (name()!='ConfiguredDevices') and (name()!='ConfiguredDevice') and (name()!='DetectedDevices') and (name()!='Inputs') and (name()!='Outputs') and (name()!='Doors') and (name()!='AccessPoints') and (name()!='Sounder')  and (name()!='WirelessMasters') and (name()!='Keys') and (name()!='Leds')" >
            <!-- all tags for peripherals must be skipped -->
            <xsl:if test="not(contains(name(),'LDUID')) and (name()!='LDPeripheral') and (name()!='LDRFPeripheral') and (name()!='LDInstallServices')">
              <!-- columns from HardwareDevice table must be skipped also -->
              <xsl:if test="(name()!='TimePattern') and (name()!='PartitionTamper') and (name()!='TamperOnLoss')">
              <!--  the rest of parameters is specific for each device type, therefore such parameters are stored into extra table (see tables with HW... prefix) -->
                <xsl:choose>
                  <xsl:when test="name()='ConfigData'">
                    <!-- ConfigData is helper treenode for DS devices. DS devices contain separate 
                       xml configuration with many tree levels, therefore deep copy is required
                    -->
                    <xsl:call-template name="CopyAll" />
                  </xsl:when>
                  <xsl:when test="name()='MSB'">
                    <MSB>
                      <xsl:call-template name="ConvertHexToDec">
                        <xsl:with-param name="input-string">
                          <xsl:value-of select="string(.)" />
                        </xsl:with-param>
                      </xsl:call-template>
                    </MSB>
                  </xsl:when>
                  <xsl:otherwise>
                    <!-- other parameters are single values only, therefore shallow copy is enough -->
                    <xsl:element name="{name()}"><xsl:value-of select="." /></xsl:element>
                  </xsl:otherwise>
                </xsl:choose>				                                                                
              </xsl:if>
            </xsl:if>
          </xsl:if>
        </xsl:for-each>
      </xsl:element>
    </xsl:if>
  </xsl:template>
      
  <xsl:template name="LoadConfiguredDevice">
    <xsl:param name="ControllerUID" />
    <xsl:param name="WirelessDevice" />
    <UID>
      <UID><xsl:value-of select="@UID" /></UID>
      <TableName>HardwareDevice</TableName>
    </UID>
    <!-- subdevice uid -->
	<xsl:for-each select="Controller">
	<UID>
	   <UID><xsl:value-of select="@UID" /></UID>
	   <TableName>UID</TableName>
	</UID>
	</xsl:for-each>
    <HardwareDevice>
      <UID><xsl:value-of  select="@UID" /></UID>
      <Type><xsl:value-of select="@Type" /></Type>
      <Name><xsl:value-of select="Name" /></Name>
      <Address><xsl:value-of select="Address" /></Address>
      <xsl:for-each select="Controller">
        <SubdeviceUID><xsl:value-of select="@UID" /></SubdeviceUID>
        <SubdeviceType><xsl:value-of select="@Type" /></SubdeviceType>
      </xsl:for-each>
      <TimePattern><xsl:value-of select="TimePattern" /></TimePattern>
      <WirelessDevice><xsl:value-of select="$WirelessDevice" /></WirelessDevice>
      <PartitionTamper><xsl:value-of select="PartitionTamper" /></PartitionTamper>
      <TamperOnLoss><xsl:value-of select="TamperOnLoss" /></TamperOnLoss>
      <ParentDeviceUID><xsl:value-of select="$ControllerUID" /></ParentDeviceUID>
    </HardwareDevice>
    <xsl:call-template name="ReadHardwareDeviceProperties">
      <xsl:with-param name="DeviceUID" select="@UID"/>
      <xsl:with-param name="DeviceType" select="@Type"/>
    </xsl:call-template>
    <xsl:variable name="DeviceUID"><xsl:value-of select="@UID" /></xsl:variable>
    <xsl:for-each select="Controller">
      <xsl:for-each select="ConfiguredDevices/BusDevice">
        <xsl:call-template name="LoadConfiguredDevice">
          <xsl:with-param name="ControllerUID" select="$DeviceUID" />
          <xsl:with-param name="WirelessDevice" select="'false'" />
        </xsl:call-template>
      </xsl:for-each>
      <xsl:for-each select="ConfiguredDevices/WirelessDevice">
        <xsl:call-template name="LoadConfiguredDevice">
          <xsl:with-param name="ControllerUID" select="$DeviceUID" />
          <xsl:with-param name="WirelessDevice" select="'true'" />
        </xsl:call-template>
      </xsl:for-each>
      <!--ConfiguredDevice tag is no longer supported -->
      <xsl:for-each select="ConfiguredDevices/ConfiguredDevice">
        <xsl:call-template name="LoadConfiguredDevice">
          <xsl:with-param name="ControllerUID" select="$DeviceUID" />
          <xsl:with-param name="WirelessDevice" select="'false'" />
        </xsl:call-template>
     </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="ConvertHexToDec">
  <xsl:param name="input-string" select=" '' "/>
  <xsl:param name="result" select="0" />
  <xsl:choose>
      <xsl:when test="$input-string = ''">
        <xsl:value-of select="$result" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:variable name="digit" select="substring($input-string, 1, 1)" />
        <xsl:variable name="rest" select="substring($input-string, 2)" />
        <xsl:choose>
          <xsl:when test="$digit = '0'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = '1'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 1"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = '2'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 2"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = '3'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 3"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = '4'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 4"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = '5'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 5"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = '6'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 6"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = '7'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 7"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = '8'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 8"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = '9'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 9"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = 'A'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 10"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = 'B'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 11"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = 'C'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 12"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = 'D'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 13"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = 'E'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 14"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="$digit = 'F'">
            <xsl:call-template name="ConvertHexToDec">
              <xsl:with-param name="result" select="$result * 16 + 15"/>
              <xsl:with-param name="input-string" select="$rest"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:text>bad hex digit</xsl:text>
            <xsl:value-of select="$digit"/>
            <xsl:text>found at:</xsl:text>
            <xsl:value-of select="$input-string" />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  
</xsl:stylesheet>


Zerion Mini Shell 1.0