XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Jon GallegosSubject: 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;

java $TRANSFORM_DIR/saxon9.jar -s:converter:CSV:root=Document:row=Row?file:///$IN_DIR/$eachfile -warnings:silent -xsl:$MAP_DIR/NAPLMoTcMSE_TcMSE20b.xsl

and I get the following error.

$ ksh NAPLMoTcMSE_TcMSE20.sh
total 1888
-rw-r--r-- 1 38999 cat2jt 211262 Jan 11 15:38 Extracted PartsList.csv
-rw-r--r-- 1 38999 cat2jt 357486 Jan 12 10:19 ExtractedProcessStructure.csv
-rw-r--r-- 1 38999 cat2jt 362727 Jan 11 15:36 ExtractedProcessStructure.csv.bak
Source file converter:CSV:root=Document:row=Row?file:/nas02/ECRF/NGPA/Test/TcMSE2TcMSE/IDIR/ExtractedProcessStructure.csv does not exist

---------------------------------------------------
The file obviously exists. What am I doing wrong?

Postnext
Ivan PedruzziSubject: error converting .csv in a unix script
Author: Ivan Pedruzzi
Date: 18 Jan 2011 10:33 PM


Jon,

Saxon doesn't know how to resolve convert: URL unless you register a XML Converter as URI resolver.

If you ask Stylus Studio to generate the Java code (click XSLT -> Generate Java Code) you will see which API you need to call

Hope this helps
Ivan

Postnext
Jon GallegosSubject: 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?


UnknownNAPLMiPPDA_TcMSE10a.xsl
xslt map

UnknownPDDAInShort.csv
input file

Postnext
Ivan PedruzziSubject: 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%

Hope this helps
Ivan


Documentrun.jar

Postnext
Jon GallegosSubject: error converting .csv in a unix script
Author: Jon Gallegos
Date: 04 Feb 2011 11:20 AM
This is still not working for me.

Here is my file directory
-rwxrwxrwx 1 ngpqabat staff 8789 Feb04 10:38 NAPLMiPDDA_TcMSE10.sh
-rwxrwxrwx 1 ngpqabat staff 27255 Feb01 11:39 NAPLMiPDDA_TcMSE10a.xsl
-rwxrwxrwx 1 ngpqabat staff 887054 Jan28 09:24 XMLConverters.jar
-rwxrwxrwx 1 ngpqabat staff 2697 Jan31 14:51 run.jar
-rwxrwxrwx 1 ngpqabat staff 4742210 Jan27 13:57 saxon9.jar

I have attached my script.

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

NAPLMiPDDA_TcMSE10.sh: XMLConverters.jar: 0403-006 Execute permission denied.
NAPLMiPDDA_TcMSE10.sh: run.jar: 0403-006 Execute permission denied.


UnknownNAPLMiPPDA_TcMSE10.xsl

Postnext
Ivan PedruzziSubject: 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

Hope this helps
Ivan

Postnext
Jon GallegosSubject: error converting .csv in a unix script
Author: Jon Gallegos
Date: 07 Feb 2011 10:09 AM
Originally Posted: 07 Feb 2011 10:08 AM
Ivan

I get the following error.

The java class could not be loaded. java.lang.UnsupportedClassVersionError: (run) bad major version at offset=6

We are runnning java5 on our unix servers

Postnext
Ivan PedruzziSubject: error converting .csv in a unix script
Author: Ivan Pedruzzi
Date: 08 Feb 2011 01:09 AM

I don't have Java 5 on my machine you have to recompile on your system

1) Extract Java source code from the run.jar

jar -xf run.jar run.java

2) compile run.java using Java Compile from JDK 1.5

javac -classpath saxon9.jar:XMLConverters.jar run.java

3) update run.jar

jar -uf run.jar run.class


Hope this helps
Ivan

Postnext
Jon GallegosSubject: 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

Posttop
Jon GallegosSubject: error converting .csv in a unix script
Author: Jon Gallegos
Date: 18 Feb 2011 01:20 PM
I resolved the compiling issue, but now I am getting the following error when I run my script

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
at run.main(run.java:27)

the code in my script looks like this

set IN=converter:CSV:first=yes:double=yes:root=Document:row=Row?$IN_DIR/ExtractedProcessStructure.csv

set OUT=converter:TAB:encoding=utf-8:quotes=:collapse=no:root=Document:row=Row$OUT_DIR/InitialProcessStructure.txt

set XSL=NAPLMiTcMSE_TcMSE20a.xsl

java -cp saxon9.jar:XMLConverters.jar:NAPLMiTcMSE_TcMSE.jar NAPLMiTcMSE_TcMSE $IN $OUT $XSL

exit


ApplicationNAPLMiTcMSE_TcMSE.jar
Run .jar file

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.