我正在尝试将我的 XML 转换为固定宽度的文件,但参数xtt:fixedLength
不适用于我的 XSLT 转换。这是我的 XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
version="2.0" xmlns:wd="urn:com.workday.report/INT069_REP-Emp_File"
xmlns:lancet="http://example.com/mf"
xmlns:xtt="urn:com.workday/xtt" xmlns:etv="urn:com.workday/etv">
<xsl:variable name="lineFeeder" select="' '" />
<xsl:template match="/wd:Report_Data">
<root>
<xsl:for-each select="wd:Report_Entry">
<Company_code xtt:fixedLength="4" xtt:paddingCharacter="0" xtt:align="right">
<xsl:value-of select="format-number(wd:Company, '0000')" />
</Company_code>
<Employee_ID xtt:fixedLength="9" xtt:paddingCharacter="0" xtt:align="right">
<xsl:value-of select="format-number(wd:Employee_ID, '000000000')" />
</Employee_ID>
<Last_Name xtt:fixedLength="30">
<xsl:value-of select="lancet:stripSpecialChars(replace(normalize-unicode(translate(wd:Last_Name, ',', ''), 'NFKD'), '⁄', '/'))" />
</Last_Name>
<First_name xtt:fixedLength="15">
<xsl:value-of select="lancet:stripSpecialChars(replace(normalize-unicode(translate(wd:First_Name, ',', ''), 'NFKD'), '⁄', '/'))" />
</First_name>
<Status xtt:fixedLength="2">
<xsl:value-of select="wd:status" />
</Status>
<Cost_Center xtt:fixedLength="5">
<xsl:value-of select="wd:Cost_Center" />
</Cost_Center>
<xsl:text>
</xsl:text>
</xsl:for-each>
</root>
</xsl:template>
<xsl:function name="lancet:stripSpecialChars">
<xsl:param name="string" />
<xsl:variable name="AllowedSymbols" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()*%$#@!~<>,.?[]=- + /\ '" />
<xsl:value-of select="translate($string, translate($string, $AllowedSymbols, ''), ' ')" />
</xsl:function>
</xsl:stylesheet>
我得到的输出是
0001013507738HALLERICA01050
我需要这样的东西
0001013507738HALL(此处多出 26 个空格) ERICA(此处多出 10 个空格) 010 50
我xtt:FixedLength
的不工作。这个你能帮我吗。
谢谢