XML Transformer
This document function helps if a third-party application does not transmit clean Connect files when calling primedocs, but XML files with an arbitrary structure. When calling primedocs, the name of the interface must also be specified. On the client such a call looks like this:
primedocs.exe /connector "C:\temp\testfile.xml" /interfaceType "myDefinedInterface"
In this document function, rules are now defined with XSLT to specify how the received XML file (here testfile.xml) for "myDefinedInterface" is transformed into a correct Connect file. We will do this using an example.
Example
In our example, "testfile.xml" has the following content:
<root>
<anElement>
<hereItIs>Test Content from XML file</hereItIs>
</anElement>
<anotherElement>This is an example.</anotherElement>
</root>
In this scenario, we want to use the above testfile.xml to populate a field of the Connect converter. For this we create a configuration in the Connect converter for the field "TestCustomInterface.Field01" in the interface "TestCustomInterface". This configuration looks like this:
<CustomInterfaces>
<!-- TestCustomInterface -->
<InterfaceDescription Name="TestCustomInterface" Description="Test Interface...">
<Node Id="TestCustomInterface.Field01">[default text]</Node>
</InterfaceDescription>
</CustomInterfaces>
The field "TestCustomInterface.Field01" can now be inserted in the Word editor of a template:
CAUTION
There are "Interfaces" elements in both the interface converter and the Connect converter. However, these must not be confused.
Goal
The goal now is to define the "myDefinedInterface" (see Call) in the Connect converter in such a way that primedocs performs a transformation for the above call, so that this Connect file is created and executed:
<OneOffixxConnectBatch xmlns="http://schema.oneoffixx.com/OneOffixxConnectBatch/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Settings />
<Entries>
<OneOffixxConnect>
<Arguments>
<TemplateId>804ea87d-37a4-4307-99d7-23d16032f426</TemplateId>
<LanguageLcid>2055</LanguageLcid>
</Arguments>
<Function name="CustomInterfaceConnector" id="70E94788-CE84-4460-9698-5663878A295B">
<Arguments>
<Interface Name="TestCustomInterface">
<Node Id="TestCustomInterface.Field01">
[Inhalt von "hereItIs"-Element: "Test Content from XML file"]
</Node>
</Interface>
</Arguments>
</Function>
</OneOffixxConnect>
</Entries>
</OneOffixxConnectBatch>
Configuration
CAUTION
For this configuration you must pay attention to upper and lower case! For example, the start of the word "Id" must be capitalised, otherwise the Connect call will not work.
The configuration of the interface converter must look like this:
<Configuration>
<Interfaces>
<!-- myTestInterface -->
<Interface name="myTestInterface" version="1.0">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<OneOffixxConnectBatch xmlns="http://schema.oneoffixx.com/OneOffixxConnectBatch/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Settings />
<Entries>
<OneOffixxConnect>
<Arguments>
<TemplateId>804ea87d-37a4-4307-99d7-23d16032f426</TemplateId>
<LanguageLcid>2055</LanguageLcid>
</Arguments>
<Function name="CustomInterfaceConnector" id="70E94788-CE84-4460-9698-5663878A295B">
<Arguments>
<Interface Name="TestCustomInterface">
<Node Id="TestCustomInterface.Field01">
<xsl:value-of select="/root/anElement/hereItIs" />
</Node>
</Interface>
</Arguments>
</Function>
</OneOffixxConnect>
</Entries>
</OneOffixxConnectBatch>
</xsl:template>
</xsl:stylesheet>
</Interface>
</Interfaces>
</Configuration>
When rebuilding this example, care must be taken to ensure that the correct template id is between <TemplateId> and </TemplateId>.
The call from above
primedocs.exe /connector "C:\temp\testfile.xml" /interfaceType "myDefinedInterface"
now creates a document in which the field TestCustomInterface.Field01 has the content "Test Content from XML file" (originating from testfile.xml):