XIP Datenbank Import Beispiel

Aus SiteparkWiki
Zur Navigation springen Zur Suche springen

XML Konfiguration

<?xml version="1.0" encoding="UTF-8"?>
<import id="databaseimport" name="Import from Database">
   <logging>
      <Appenders>
         <RollingFile   
            name="FILE"         
            fileName="${sys:sitepark.home}/database-import.log"
            filePattern="${sys:sitepark.home}/ldap/database-import-%d{dd-MM-yyyy}-%i.log.gz"
            append="true">      
            <PatternLayout>     
               <Pattern>%d %-5p %m%n</Pattern>
            </PatternLayout>    
            <Policies>          
               <TimeBasedTriggeringPolicy />
               <SizeBasedTriggeringPolicy size="10MB" />
            </Policies>
            <DefaultRolloverStrategy max="10" />
         </RollingFile> 
      </Appenders>
      <Loggers> 
         <Logger name="com.sitepark.ies" level="trace" additivity="false">
            <AppenderRef ref="FILE" />
         </Logger>      
      </Loggers>
   </logging>
   <ies-connection login="Wartung" password="secret" client="ies2work" module="LDAP Importer"/>
   <options>
      <createElements>true</createElements>
      <deleteWorkDir>true</deleteWorkDir>
      <createPools>true</createPools>
      <updatePools>true</updatePools>
      <updateElements>true</updateElements>
      <deletePools>true</deletePools>
      <deleteOnlyEmptyPools>true</deleteOnlyEmptyPools>
      <deleteElements>true</deleteElements>
      <xslt>database-import.xslt</xslt>
      <syncFile>${sitepark.home}/conf/database-import.sync</syncFile>
   </options>
    <source type="database" id="1">
        <sql>SELECT * FROM UserDefinition</sql>
    </source>
</import>

XSLT

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xip="http://ies.sitepark.com/xip"
    extension-element-prefixes="xip">

    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

    <xsl:template match="/">
        <xip>
        <xsl:for-each select="/rowset/row">
            <article parent="database.import.root" anchor="database.import.{_login}" name="{_lastname}, {_firstname}" filename="{_login}" template="database.import.template">
                <text name="sp_title"><xsl:value-of select="_lastname"/>, <xsl:value-of select="_firstname"/></text>
            </article>
        </xsl:for-each>
        </xip>
    </xsl:template>
</xsl:stylesheet>