The 1000 Document Creator is a tool that can take an XML file describing lots of XML documents and create those documents in a Hippo Webdav repository. One example (the one that sparked the creation of this tool) is an Excel spreadsheet where each row is a document and each column is a field in that document.
Build
Build using
$ maven clean uberjar
Configure
Configure the properties file:
file.location=exceldump.xml file.transformer.location=exceldump-to-xmldoc.xsl file.xpath=/doclist/document file.name.transformer.location=exceldump-to-filename.xsl file.type=item # The destination location. Path can either be a folder or a file. destination.host=localhost destination.port=60000 destination.rootpath=/default destination.path=/files/default.preview/content/bulk/items # authentication of the source location authentication.username=root authentication.password=password
file.location is the filesystem location of the XML file from which the new XML documents have to be created.
file.transformer.location is the location of the XSLT file that will transform the original XML file into one big XML file containing the XML of the final documents, but encapsulated in one big XML file for now.
Example:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:date="http://exslt.org/dates-and-times" xmlns:str="http://exslt.org/strings" extension-element-prefixes="date str" exclude-result-prefixes="xsl date str"> <xsl:template match="/"> <doclist> <xsl:apply-templates select="/ss:Workbook/ss:Worksheet/ss:Table/ss:Row[position()!=1]" mode="doc"/> </doclist> </xsl:template> <xsl:template match="ss:Row" mode="doc"> <document> <content> <datum> <xsl:value-of select="date:date()"/> </datum> <titel> <xsl:value-of select="ss:Cell[1]/ss:Data"/> </titel> <postcode> <xsl:value-of select="ss:Cell[2]/ss:Data"/> </postcode> <plaats> <xsl:value-of select="ss:Cell[3]/ss:Data"/> </plaats> <postadres/> <telefoon> <xsl:value-of select="ss:Cell[5]/ss:Data"/> </telefoon> </content> <meta> <dossiers> <xsl:apply-templates select="ss:Cell[7]" mode="list"/> </dossiers> <categorie> <xsl:apply-templates select="ss:Cell[6]" mode="list"/> </categorie> </meta> </document> </xsl:template> <xsl:template match="ss:Cell" mode="list"> <xsl:variable name="list" select="str:split(.,',')"/> <xsl:apply-templates select="$list/node()" mode="comma-separated-list"/> </xsl:template> <xsl:template match="text()" mode="comma-separated-list"> <xsl:variable name="value" select="normalize-space(.)"/> <xsl:variable name="length" select="string-length($value)"/> <xsl:value-of select="concat(substring('0000000',1,7-number($length)),$value)"/> <xsl:if test="not(position()=last())"> <xsl:text>,</xsl:text> </xsl:if> </xsl:template> <xsl:template match="@*|node()"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy></xsl:template> </xsl:stylesheet>
file.xpath is the XPath to the location of the XML for the individual documents. After the transformation above,
file.xpath=/doclist/document
file.name.transformer.location is the location of the XSLT file that extracts the required filename from the final document. This name will be used for the http://hippo.nl/cms/1.0:caption property, and in cleaned-up version (all lowercase, without spaces or funny characters) it will also be used for the filename and DAV::displayname.
file.type is the type that will be assigned to the http://hippo.nl/cms/1.0:type property.
Run
Run using
$ java -jar target/hippo-1000-document-creator-<version>-uber.jar <propertiesfile>