简体   繁体   English

使用平面文件进行XSLT转换

[英]XSLT Transformation using flat file

Need some inputs on the below problem. 需要以下问题的一些投入。 I have a flat file which contains Accounts numbers 我有一个包含帐号的平面文件

Account1:Valid 
Account2:Valid 
Account3:Invalid

There is another system generated XML whose contents are transformed in Java via a Transformer class through an XSL file. 还有另一种系统生成的XML,其内容通过XSL文件通过Transformer类在Java中进行转换。 I need to enhance the XSL file so that it takes Accounts from flat file into consideration and based on Valid or Invalid status, generate the o/p response XML. 我需要增强XSL文件,以便将平面文件中的Accounts考虑在内,并基于有效或无效状态生成o / p响应XML。

Any pointers on how to approach this? 关于如何处理此问题的任何指示? In Java application, I have done simple transformation. 在Java应用程序中,我完成了简单的转换。 But how to enhance to take data from Flat File into consideration ? 但是如何增强将平面文件中的数据考虑在内的能力呢?

If you want to do it with the input as shown, then you need to use XSLT 2.0 and later to use unparsed-text("accounts.txt") to read in the text file and for instance parse it with tokenize(unparsed-text("accounts.txt"), '\\n') into lines and/or further with xsl:analyze-string . 如果要使用所示输入进行操作,则需要使用XSLT 2.0及更高版本来使用unparsed-text("accounts.txt")读取文本文件,例如,使用tokenize(unparsed-text("accounts.txt"), '\\n')行和/或进一步使用xsl:analyze-string

XSLT 2.0 is supported in Java by Saxon 9 from http://saxon.sourceforge.net/ . Saxon 9从http://saxon.sourceforge.net/在Java中支持XSLT 2.0。

With XSLT 1.0 all you could do is pass in a string parameter with the file contents and then use the rudimentary string functions in XPath 1.0 and named templates to extract the data. 使用XSLT 1.0,您所能做的就是传入带有文件内容的字符串参数,然后使用XPath 1.0中的基本字符串函数和命名模板提取数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM