XML Transformator
- 1 Example
- 1.1 Goal
- 1.2 Konfiguration
This document function helps if a specialist application does not send 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. For the client such a call looks like this:
primedocs.exe /connector "C:\temp\testfile.xml" /interfaceType "myDefinedInterface"
.
In this document function we now define with XSLT by means of rules, how the received XML file (here testfile.xml) for "myDefinedInterface" is transformed to a correct connect file. Here 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. But 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 when called above, in order for this Connect file to be 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>
Konfiguration
CAUTION
For this configuration you have to pay attention to the upper and lower case! E.g. the beginning of the word "Id" must be capitalized, otherwise the connect call will not work.
Â
The configuration of the interface converter must look like this:
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 where the field TestCustomInterface.Field01
has the content "Test Content from XML file" (comes from testfile.xml):
Â
PrimeSoft AG, Bahnhofstrasse 4, 8360 Eschlikon, Switzerland