XSLT2.0转换 2269 5909 JA5637 2269 5909 JA4345 2269 5909 JA5637
XLST不工作。它不显示分隔符或新行。我还需要删除重复的employee_client_id。Ex JA5637出现两次,我需要使用XSLT删除它。每个依赖项都应位于一个带有逗号分隔符的新行中。请参见下面的输出 我构建的示例xsltXSLT2.0转换 2269 5909 JA5637 2269 5909 JA4345 2269 5909 JA5637,xslt,Xslt,XLST不工作。它不显示分隔符或新行。我还需要删除重复的employee_client_id。Ex JA5637出现两次,我需要使用XSLT删除它。每个依赖项都应位于一个带有逗号分隔符的新行中。请参见下面的输出 我构建的示例xslt <?xml version='1.0' encoding='UTF-8'?> <wd:Report_Data xmlns:wd="urn:com.workday.report/CIS_CR_INT122_HMS_Depen
<?xml version='1.0' encoding='UTF-8'?>
<wd:Report_Data
xmlns:wd="urn:com.workday.report/CIS_CR_INT122_HMS_Dependent_Report">
<wd:Report_Entry>
<wd:Dependents>
<wd:project_id>2269</wd:project_id>
<wd:plan_id>5909</wd:plan_id>
<wd:employee_client_id>JA5637</wd:employee_client_id>
</wd:Dependents>
</wd:Report_Entry>
<wd:Report_Entry>
<wd:Dependents>
<wd:project_id>2269</wd:project_id>
<wd:plan_id>5909</wd:plan_id>
<wd:employee_client_id>JA4345</wd:employee_client_id>
</wd:Dependents>
</wd:Report_Entry>
<wd:Report_Entry>
<wd:Dependents>
<wd:project_id>2269</wd:project_id>
<wd:plan_id>5909</wd:plan_id>
<wd:employee_client_id>JA5637</wd:employee_client_id>
</wd:Dependents>
</wd:Report_Entry>
</wd:Report_Data>
,
项目id、计划id、员工id、客户id
;
,
;
输出
项目id、计划id、员工id、客户id
22695909,JA5637
22695909,JA4345您的XML声明:
<?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">
<xsl:strip-space elements="*"/>
<xsl:variable name="NEWLINE">
<xsl:text> </xsl:text>
</xsl:variable>
<xsl:variable name="DELIMITER">,</xsl:variable>
<xsl:output method="text"/>
<xsl:template match="wd:Report_Data"
xmlns:wd="urn:com.comday.report/INT007BOutbound">
<!--These are just text column headers for output-->
<xsl:text>project_id,plan_id,employee_client_id</xsl:text>
<xsl:value-of select="$NEWLINE"/>
<xsl:for-each select="wd:Report_Entry">
<xsl:for-each select="wd:Dependents">
<xsl:value-of select="wd:project_id"/>
<xsl:value-of select="$DELIMITER"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="wd:plan_id"/>
<xsl:value-of select="$DELIMITER"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="wd:employee_client_id"/>
</xsl:for-each>
<xsl:value-of select="$NEWLINE"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
但你确实:
xmlns:wd="urn:com.workday.report/CIS_CR_INT122_HMS_Dependent_Report"
因此,您的模板与输入XML中的任何内容都不匹配,您看到的整个输出都是由生成的
我没有检查样式表的其余部分。尽管如此,我还是想在XSLT2.0中添加一点,您可以使用它来代替前缀。是的,我知道了
xmlns:wd="urn:com.comday.report/INT007BOutbound"
,
项目id、计划id、员工id、客户id
非常感谢michael,我想出来了,但没有发布和回复。我真的很感谢你的帮助。
<xsl:strip-space elements="*"/>
<xsl:variable name="NEWLINE">
<xsl:text> </xsl:text>
</xsl:variable>
<xsl:variable name="DELIMITER">,</xsl:variable>
<xsl:output method="text"/>
<xsl:template match="wd:Report_Data" xmlns:wd="urn:com.workday.report/CIS_CR_INT122_HMS_Dependent_Report">
<!--These are just text column headers for output-->
<xsl:text>project_id,plan_id,employee_client_id</xsl:text>
<xsl:value-of select="$NEWLINE"/>
<xsl:for-each-group select="wd:Report_Entry/wd:Dependents" group-by="wd:employee_client_id">
<xsl:value-of select="wd:project_id"/>
<xsl:value-of select="$DELIMITER"/>
<xsl:value-of select="wd:plan_id"/>
<xsl:value-of select="$DELIMITER"/>
<xsl:value-of select="wd:employee_client_id"/>
<xsl:value-of select="$DELIMITER"/>
<xsl:value-of select="wd:employee_name"/>