XML を変換する必要があり、いくつかの問題が発生しています...
現在の XML:
<?xml version="1.0" encoding="utf-8"?>
<Employees>
<Employee>
<ManagerFirstName>Joe</ManagerFirstName>
<ManagerLastName>Schmoe</ManagerLastName>
</Employee>
</Employees>
望ましい出力:
<?xml version="1.0" encoding="utf-8"?>
<Employees>
<Employee>
<supervisorName>Schmoe, Joe</supervisorName>
</Employee>
</Employees>
現在の XSL:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" >
<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="node()">
<xsl:copy><xsl:apply-templates select="node()"/></xsl:copy>
</xsl:template>
<xsl:template match="ManagerFirstName">
<supervisorName>
<xsl:apply-templates select="node()"/>
<xsl:value-of select="/ManagerLastName"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="/ManagerFirstName"/>
</supervisorName>
</xsl:template>
</xsl:stylesheet>
これは機能しておらず、理解できません。現在出力されている XML は次のようになります。
<?xml version="1.0" encoding="utf-8"?>
<Employees>
<Employee>
<supervisorName>Joe, </supervisorName>
<ManagerLastName>Schmoe/ManagerLastName>
</Employee>
</Employees>
すごく近くにいる気がする…
更新 ManagerFirstName と ManagerLastName が空白の場合、その SupervisorName にコンマが含まれていないことを確認するにはどうすればよいですか?
更新 2
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output indent="yes"/> <xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Employee">
<tbl_EmployeeList><xsl:apply-templates select="@*|node()"/></tbl_EmployeeList>
</xsl:template>
<xsl:template match="tbl_EmployeeList">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<supervisorName>
<xsl:value-of select="(ManagerLastName,ManagerFirstName)" separator=", "/>
</supervisorName>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>