Subject:error converting .csv in a unix script Author:Jon Gallegos Date:12 Jan 2011 11:47 AM
I have been using the following code for a couple years converting XML to XML.
cd $IN_DIR
export PLF=ExtractedPartsList.csv
for eachfile in $PLF
do
java $TRANSFORM_DIR/saxon9.jar -s:$IN_DIR/$eachfile -warnings:silent -xsl:$MAP_DIR/NAPLMoTcMSE_TcMSE20a.xsl -o:$OUT_DIR/$eachfile
-----------------------------------------------------------------
But now I need to convert a .csv file. Here is the code I have;
Subject:error converting .csv in a unix script Author:Jon Gallegos Date:28 Jan 2011 01:35 PM Originally Posted: 28 Jan 2011 11:01 AM
in my UNIX directory I have the following files
$ ls -l
total 24672
-rwxr-xr-x 1 ngpqabat staff 7599 Jan 28 09:37 NAPLMiPDDA_TcMSE10.sh
-rw-r--r-- 1 ngpqabat staff 27255 Jan 28 10:27 NAPLMiPDDA_TcMSE10a.xsl
-rw-r--r-- 1 ngpqabat staff 887054 Jan 28 09:24 XMLConverters.jar
-rw-r--r-- 1 ngpqabat staff 4742210 Jan 27 13:57 saxon9.jar
-rw-r--r-- 1 ngpqabat staff 1864136 Jan 27 16:19 xerces-c_1.lib
-rw-r--r-- 1 ngpqabat staff 1597440 Jan 27 16:20 xerces-c_1_6_0.dll
-rw-r--r-- 1 ngpqabat staff 3385368 Jan 27 16:20 xerces260.lib
$
Yet i still get the following error when I run
$ ksh NAPLMiPDDA_TcMSE10.sh
Error on line 1 column 1 of file:/nas02/NGPA/NAPLMiPDDA_TcMSE10/InDir/ExtractedProcessStructure.csv:
SXXP0003: Error reported by XML parser: Content is not allowed in prolog.
Transformation failed: Run-time errors were reported
$
What am i doing wrong? Is there a file that i am missing?
Subject:error converting .csv in a unix script Author:Ivan Pedruzzi Date:29 Jan 2011 12:48 AM
Jon,
.dll and .lib have no use on unix machine, you can safely delete the xerces-c.* files.
Copy the attached file run.jar side by side with saxon9.jar and use the following command line
SET IN=converter:CSV:first=yes:double=yes:root=PDDA:row=Row?PDDAInShort.csv
SET OUT=converter:TAB:encoding=utf-8:quotes=:collapse=no:root=Document:row=Row?InitialProcessStructure.txt
SET XSL=NAPLMiPPDA_TcMSE10a.xsl
java -cp saxon9.jar;XMLConverters.jar;run.jar run %IN% %OUT% %XSL%
and here is the message I am getting
Setting the variable environment.
Create the Logfile and Archive file names.
Archive the Extracted Process Structure file
Translate the Extracted Process structure into the Initial Proccss Structure format
Usage: java [-options] class [args...]
(to execute a class)
or java [-jar] [-options] jarfile [args...]
(to execute a jar file)
where options include:
-cp -classpath <directories and zip/jar files separated by :>
set search path for application classes and resources
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-? -help print this help message
-X print help on non-standard options
-assert print help on assert options
Subject:error converting .csv in a unix script Author:Ivan Pedruzzi Date:04 Feb 2011 11:06 PM
Hi Jon,
On Unix the classpath separator is : and System variables are addressed with $. See if the following command line works other ways please reference the online documentation of the Java Virtual Machine version you are using running.
java -cp saxon9.jar:XMLConverters.jar:run.jar run $IN $OUT $XSL
Subject:error converting .csv in a unix script Author:Jon Gallegos Date:17 Feb 2011 04:28 PM
This will not compile
run.java:2: package com.ddtek.xmlconverter does not exist
import com.ddtek.xmlconverter.ConverterFactory;
^
run.java:3: package com.ddtek.xmlconverter does not exist
import com.ddtek.xmlconverter.ConverterResolver;
^
run.java:11: package net.sf.saxon does not exist
import net.sf.saxon.FeatureKeys;
^
run.java:24: cannot find symbol
symbol : class ConverterResolver
location: class run ConverterResolver resolver = new ConverterFactory().newResolver();
^
run.java:24: cannot find symbol
symbol : class ConverterFactory
location: class run ConverterResolver resolver = new ConverterFactory().newResolver();
^
run.java:34: package net.sf.saxon does not exist TransformerFactory tFactory = new net.sf.saxon.TransformerFactoryImpl();
^
run.java:35: cannot find symbol
symbol : variable FeatureKeys
location: class run tFactory.setAttribute(FeatureKeys.RECOGNIZE_URI_QUERY_PARAMETERS, Boolean.TRUE);
^
run.java:36: cannot find symbol
symbol : variable FeatureKeys
location: class run tFactory.setAttribute(FeatureKeys.STRIP_WHITESPACE, "ignorable");
^
run.java:37: cannot find symbol
symbol : variable FeatureKeys
location: class run tFactory.setAttribute(FeatureKeys.VERSION_WARNING, Boolean.FALSE);
^
9 errors