I wish to use babeldoc to scan a directory in wich the system puts a set of log files. I wish to copy these files and rename they appending system date and time.
Is it possible in a pipeline stage to extract the system date and time and use they to compose a file name?
Thanks in advance.
Massimo
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In short: I save original file name; I read a dummy xml, convert it using xsl in which I get current system date by a java extension; I extract system date as an attribute; I re-read original file (thanks to original file name saved earlier); I write original file to backup folder naming it using the date I have in my pipeline attribute.
Here is the XSL to get system date:
<?xml version="1.0" encoding="UTF-8"?>
Hi all,
Can anyone helps me with a problem that I have?
I wish to use babeldoc to scan a directory in wich the system puts a set of log files. I wish to copy these files and rename they appending system date and time.
Is it possible in a pipeline stage to extract the system date and time and use they to compose a file name?
Thanks in advance.
Massimo
I've succeeded in getting system date to rename and store files accordingly by following this idea:
pipeline:
entryStage = enrich
enrich.stageType=Enrich
enrich.nextStage=reader1
enrich.enrichScript.orig_file=${document.get('file_name')}
reader1.stageType=Reader
reader1.nextStage=transform
reader1.file=D:/data/dummy.xml
transform.stageType=XslTransform
transform.nextStage=extract1
transform.transformationFile=D:/data/test_pana.xsl
extract1.stageType=XpathExtract
extract1.nextStage=reader2
extract1.XPath.date=/Date/text()
reader2.stageType=Reader
reader2.nextStage=writer
reader2.file=D:/tmp/done/${document.get('orig_file')}
writer.stageType=FileWriter
writer.nextStage=null
writer.outputFile=D:/tmp/logfile${document.get('date')}.out
In short: I save original file name; I read a dummy xml, convert it using xsl in which I get current system date by a java extension; I extract system date as an attribute; I re-read original file (thanks to original file name saved earlier); I write original file to backup folder naming it using the date I have in my pipeline attribute.
Here is the XSL to get system date:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:java="http://xml.apache.org/xslt/java"
exclude-result-prefixes="java">
<xsl:output method="xml" encoding="iso-8859-1" version="1.0" indent="yes" omit-xml-declaration="no" cdata-section-elements="value data"/>
<xsl:template match="/">
<xsl:element name="Date">
<xsl:variable name="current_date">
<xsl:value-of select="java:format(java:java.text.SimpleDateFormat.new('yyyyMMdd'), java:java.util.Date.new())"/>
</xsl:variable>
<xsl:value-of select="$current_date" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Hope this helps.
We get current date and time from a database and put it into Babeldoc via SqlEnrich.
Sherman
Hi all,
many thanks for your responses.
I think in my case is useful to take date and time from xslt system because for my pourposes I have not a DB in the application.
Massimo