我需要使用 xslt 从文本文件生成格式良好的 XML 结构。我是 xslt 转换的新手,这对我来说有点挑战。示例文本文件如下。我需要省略第一部分并将引号中的值映射到输出 xml 文件。
Directory: sample/archive
Name: 20130613-T210002.TXT
---------------------------------------------------------------
"11FCK1GR0026" "G190" "FPB - OK Ship Pt" "A" "11" "XX" "02"
"11FCA1GR0034" "G980" "FPB -San Antonio" "A" "11" "XX" "02"
"11FCA1GR0034" "G160" "FPB -San Antonio" "A" "11" "XX" "02"
以下是所需的输出 xml 格式:
<Account>
<Action>A</Action> <!-- 3rd element in the row-->
<org>G190</org> <!-- 2nd element-->
<code>11FCK1GR002611XX</code> <!--concat(1st element, 4th element, 5th element)-->
<FiscalYear>2013</FiscalYear> <!--calculate fiscal year from current date -->
<Info>
<Action>A</Action> <!-- 3rd element in the row-->
<org>G190</org> <!-- 2nd element-->
<code>11FCK1GR002611XX</code><!--concat(1st element, 4th element, 5th element)-->
<Fieldlab>Acc1</Fieldlab> <!-- Static value-->
<FieldVal>11FCK1GR0026 </FieldVal> <!-- if field order is 1, map 1st element -->
<FieldOrd>1</FieldOrd> <!-- Static value-->
<Info>
<Info>
<Action>A</Action>
<org>G190</org>
<code>11FCK1GR002611XX</code>
<Fieldlab>Acc2</Fieldlab>
<FieldVal>11</FieldVal> <!-- if field order is 2, map 5th element -->
<FieldOrd>2</FieldOrd>
<Info>
<Info>
<Action>A</Action> <!-- 4th element in the row-->
<org>G190</org> <!-- 2nd element-->
<code>11FCK1GR002611XX</code>
<Fieldlab>Acc3</Fieldlab>
<FieldVal>xx</FieldVal> <!-- if field order is 3, map 6th element -->
<FieldOrd>3</FieldOrd>
<Info>
<Info>
<Action>A</Action> <!-- 4th element in the row-->
<org>G190</org> <!-- 2nd element-->
<code>11FCK1GR002611XX</code>
<Fieldlab>Acc4</Fieldlab>
<FieldVal>02</FieldVal> <!-- if field order is 4, map 7th element -->
<FieldOrd>4</FieldOrd>
<Info>
<Info>
<Action>A</Action> <!-- 4th element in the row-->
<org>G190</org> <!-- 2nd element-->
<code>11FCK1GR002611XX</code>
<Fieldlab>Acc5</Fieldlab>
<FieldVal>FPB - OK Ship Pt</FieldVal> <!-- if field order is 5, map 3rd element -->
<FieldOrd>5</FieldOrd>
<Info>
</Account>
<Account>
<Action>A</Action> <!-- 3rd element in the row-->
<org>G980</org> <!-- 2nd element-->
<code>111FCA1GR003411XX</code> <!--concat(1st element, 4th element, 5th element)-->
<FiscalYear>2013</FiscalYear>
<Info>
<Action>A</Action> <!-- 3rd element in the row-->
<org>G190</org> <!-- 2nd element-->
<code>111FCA1GR003411XX</code><!--concat(1st element, 4th element, 5th element)-->
<Fieldlab>Acc1</Fieldlab>
<FieldVal>11FCA1GR0034</FieldVal> <!-- if field order is 1, map 1st element -->
<FieldOrd>1</FieldOrd>
<Info>
<Info>
<Action>A</Action>
<org>G190</org>
<code>111FCA1GR003411XX</code>
<Fieldlab>Acc2</Fieldlab>
<FieldVal>11</FieldVal> <!-- if field order is 2, map 5th element -->
<FieldOrd>2</FieldOrd>
<Info>
<Info>
<Action>A</Action> <!-- 4th element in the row-->
<org>G190</org> <!-- 2nd element-->
<code>111FCA1GR003411XX</code>
<Fieldlab>Acc3</Fieldlab>
<FieldVal>xx</FieldVal> <!-- if field order is 3, map 6th element -->
<FieldOrd>3</FieldOrd>
<Info>
<Info>
<Action>A</Action> <!-- 4th element in the row-->
<org>G190</org> <!-- 2nd element-->
<code>111FCA1GR003411XX</code>
<Fieldlab>Acc4</Fieldlab>
<FieldVal>02</FieldVal> <!-- if field order is 4, map 7th element -->
<FieldOrd>4</FieldOrd>
<Info>
<Info>
<Action>A</Action> <!-- 4th element in the row-->
<org>G190</org> <!-- 2nd element-->
<code>111FCA1GR003411XX</code>
<Fieldlab>Acc5</Fieldlab>
<FieldVal>FPB -San Antonio</FieldVal> <!-- if field order is 5, map 3rd element -->
<FieldOrd>5</FieldOrd>
<Info>
</Account>
谁能帮我生成这个文件。提前致谢!