史荣久 2010年07月07日 星期三 11:39 | 3207次浏览 | 0条评论
<
xml
> 完整的ETL文件
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
<?xml
version="1.0" encoding="UTF-8"?>
<!--
指定编码,防止系统弄错字符集 -->
<!DOCTYPE
etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<
etl
>
<
connection id=
"
script"
driver=
"
script"
/
>
<
connection id=
"
out"
driver=
"
oracle"
url=
"
jdbc:oracle:thin:@localhost:1521:DB"
/
>
<
connection id=
"
log"
driver=
"
script"
url=
"
log.txt"
/
>
<
query connection-id=
"
script"
>
<![CDATA[
for (var i = 0; i < 10; i++) {
login = 'login' + i;
//You can instantiate Java objects and invoke static methods
var now = new java.sql.Timestamp(java.lang.System.currentTimeMillis());
query.next(); //Executes a child script element // * 执行后续的所有元素
}]]>
<!--
Inserts a parameterized row into a database -->
<
script connection-id=
"
out"
>
INSERT INTO Table(ID, Login, Login_Time) VALUES (?i, ?login, ?now);
<
/script
>
<!--
Logs the message using MessageFormat class and parent context variables -->
<
script connection-id=
"
log"
>
// create Java String array of 2 elements
var a = java.lang.reflect.Array.newInstance(java.lang.Object, 2)
a[0] = now;a[1] = i;
println(format.format(a));
>
/script
>
<
/query
>
<
/etl
>
<
xml
> ETL文件片段
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
<
connection id=
"
in"
driver=
"
csv"
url=
"
data.csv"
/
>
<
connection id=
"
out"
driver=
"
csv"
url=
"
report.csv"
>
#Use empty quote to turn off quoting
quote=
separator=;
<
/connection
>
<!--
connection里面可以设置参数,各个connection不一样 -->
<
script connection-id=
"
out"
>
ID,Priority,Summary,Status
<
/script
>
<
query connection-id=
"
in"
>
<!--
Empty query means select all-->
<
script connection-id=
"
out"
>
$rownum,$priority,$summary,$status
<
/script
>
<
/query
>
<
txt
> data.csv
priority,summary,status
11,summary1,21
12,summary1,22
<
txt
> report.csv
ID;Priority;Summary;Status
1;11;summary1;21
2;12;summary1;22
<
xml
> HTML邮件
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
<
etl
>
<
connection driver=
"
mail"
url=
"
mailto:user@nosuchhost.com?subject=Hello"
classpath=
"
mail.jar:activation.jar"
>
type=html
mail.smtp.host=mail.host.name
mail.user=user
mail.password=password
mail.from=Firstname Lastname
<
user@nosuchhost.com
>
<
/connection
>
<
script
>
<![CDATA[
<html>
<body>
Hello,
<hr>
<a href="http://scriptella.javaforge.com/" title="Powered by Scriptella ETL">
<img src="http://scriptella.javaforge.com/images/scriptella-powered.gif"
width="88" height="31" border="0" alt="Powered by Scriptella ETL">
</a>
</body>
</html>]]>
<
/script
>
<
/etl
>
<
xml
> 动态发邮件
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
<
etl
>
<
connection id=
"
mail"
driver=
"
mail"
url=
"
mailto:$email?subject=Hello $name"
classpath=
"
mail.jar:activation.jar"
>
mail.smtp.host=mail.host.name
mail.user=user
mail.password=password
mail.from=Administrator
<
user@nosuchhost.com
>
<
/connection
>
<
connection id=
"
db"
.../
>
<
query connection-id=
"
db"
>
SELECT * FROM Users
<
script connection-id=
"
mail"
>
#$rownum
Message produced by Scriptella ETL
<
/script
>
<
/query
>
<
/etl
>
<
xml
> ETL文件片段
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
<
connection id=
"
xls"
url=
"
jdbc:xls:file:report.xls"
classpath=
"
sqlsheet-0.1.0.jar; poi-3.0.2-FINAL-20080204.jar; jsqlparser.jar"
/
>
<
script connection-id=
"
xls"
>
CREATE TABLE SHEET1(
COL1 INT,
COL2 INT
);
<
/script
>
...
<
query connection-id=
"
db"
>
...
<
script connection-id=
"
xls"
>
INSERT INTO SHEET1 (COL1,COL2) VALUES(${rownum},${col2_value});
<
/script
>
<
/query
>
Zeuux © 2024
京ICP备05028076号
暂时没有评论