XIP HTTP Import Beispiel

Aus SiteparkWiki
Zur Navigation springen Zur Suche springen

XML Konfiguration

<?xml version="1.0" encoding="UTF-8"?>
<import id="formsolutions" name="Formsolutions Import">
   <logging>
      <Appenders>
         <RollingFile   
            name="FILE"         
            fileName="${sys:sitepark.home}/import-database.log"
            filePattern="${sys:sitepark.home}/import-database-%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>

    </logging>
   <ies-connection login="Wartung" password="secret" client="ies2work" module="Form Solutions 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>${sitepark.home}/conf/form-solutions.xslt</xslt>
      <syncFile>${sitepark.home}/conf/form-solutions.sync</syncFile>
      <attributes>
        <attribute name="cmskey">xxx</attribute>
        <attribute name="wsurl">https://webservice-url</attribute>
        <attribute name="user">123</attribute>
      </attributes>
   </options>
    <source type="http" url="${wsurl}/getformlist.php" method="post">
        <header name="SOAPAction">"urn:FS#getformlist"</header>
        <body content-type="text/xml; charset=UTF-8"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:FS" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
    <tns:getformlist xmlns:tns="urn:FS">
        <cms xsi:type="xsd:string">${cmskey}</cms>
    </tns:getformlist>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>]]></body>
    </source>
</import>

XSLT

<?xml version="1.0" encoding="ISO-8859-1"?>
<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:function name="xip:getCategoryId"> <xsl:param name="s"/>
        <!-- Erstes Zeichen ermitteln -->
        <xsl:variable name="id" select="substring-before($s,' ')"/>
        <xsl:value-of select="substring-before($s,' ')"/>
    </xsl:function>

    <xsl:key name="categoryId" match="item" use="xip:getCategoryId(kat)"/>

    <xsl:template match="/">
        <xip>
            <resource parent="formsolutions" anchor="formsolutions.config" name="Form Solutions Konfiguration" template="formsolutions.template.config">
                <text name="wsurl">${wsurl}</text>
                <text name="cms">${cmskey}</text>
                <text name="user">${user}</text>
            </resource>
        <!-- Schleife über Kategorien -->
        <xsl:for-each select="//item[generate-id() = generate-id(key('categoryId', xip:getCategoryId(kat))[1])]">

            <xsl:variable name="category" select="xip:getCategoryId(kat)"/>
            <!-- gelöschte Formulare haben keine Kategorie -->
            <xsl:if test="$category != ''">
                <xsl:variable name="categoryName" select="kat/text()"/>
                <articlepool parent="formsolutions" anchor="formsolutions.category.{$category}" name="{$categoryName}">
                    <resource>
                        <text name="container" anchor="is5:gui.container.infosite.standard"/>
                        <text name="registrationTemplate" anchor="is5:gui.container.infosite.standard.all"/>
                        <text name="editorTemplatePool" anchor="standard.container.editing"></text>
                    </resource>
                <!-- Schleife über alle mit gleicher Kategorie -->
                <xsl:for-each select="key('categoryId',$category)">
                    <resource anchor="formsolutions.form.{fnr}" name="{title} ({fnr})" template="formsolutions.template.form">
                        <comment><xsl:value-of select="bem"/></comment>
                        <text name="fs_fnr"><xsl:value-of select="fnr"/></text>
                        <text name="fs_pagecount"><xsl:value-of select="pagecount"/></text>
                        <text name="fs_created"><xsl:value-of select="created"/></text>
                        <text name="fs_changed"><xsl:value-of select="changed"/></text>
                        <text name="fs_beschr"><xsl:value-of select="beschr"/></text>
                        <text name="fs_type"><xsl:value-of select="type"/></text>
                    </resource>
                </xsl:for-each>
                </articlepool>
            </xsl:if>
        </xsl:for-each>
        </xip>
    </xsl:template>

</xsl:stylesheet>