XSLT 1.0 中的意外标记问题否则元素
Unexpected token problem in XSLT 1.0 otherwise element
我想在 xsl:otherwise 元素中分离我的成本。
我已经在具有祖先的 otherwise 元素中尝试了我的 XPATH,但无法获取任何数据。
我在没有祖先的 otherwise 元素中尝试了我的 XPATH,但它也不起作用。
重要的是在 otherwise 元素下解决这个问题。
我想像这样分开所有费用:
enter image description here
我的XML:
<?xml version="1.0" encoding="UTF-8"?>
<contracts>
<ES_CMContract contractName="test_01">
<productInContracts>
<ES_CMProductInContract>
<broadcastRights>
<ES_CM2BROADCASTRIGHT>
<broadcastRightGroup>
<ES_BROADCASTRIGHTGROUP>
<costDefinitions>
<ES_CM2CostDefinition>
<costGroup>
<ESP_2COSTGROUP name="Distributor"/>
</costGroup>
<involvedParty>
<ES_FIRM f_name="FREMANTLE MEDIA"/>
</involvedParty>
</ES_CM2CostDefinition>
<ES_CM2CostDefinition>
<costGroup>
<ESP_2COSTGROUP name="Material Cost"/>
</costGroup>
<involvedParty>
<ES_FIRM f_name="FREMANTLE MEDIA"/>
</involvedParty>
</ES_CM2CostDefinition>
<ES_CM2CostDefinition>
<costGroup>
<ESP_2COSTGROUP name="Dubbing Cost"/>
</costGroup>
<involvedParty>
<ES_FIRM f_name="FREMANTLE MEDIA"/>
</involvedParty>
</ES_CM2CostDefinition>
<ES_CM2CostDefinition>
<costGroup>
<ESP_2COSTGROUP name="Technical Cost"/>
</costGroup>
<involvedParty>
<ES_FIRM f_name="FREMANTLE MEDIA"/>
</involvedParty>
</ES_CM2CostDefinition>
</costDefinitions>
</ES_BROADCASTRIGHTGROUP>
</broadcastRightGroup>
</ES_CM2BROADCASTRIGHT>
</broadcastRights>
</ES_CMProductInContract>
</productInContracts>
</ES_CMContract>
<ES_CMContract contractName="test_02">
<productInContracts>
<ES_CMProductInContract>
<broadcastRights>
<ES_CM2BROADCASTRIGHT>
<broadcastRightGroup>
<ES_BROADCASTRIGHTGROUP>
<costDefinitions>
<ES_CM2CostDefinition>
<costGroup>
<ESP_2COSTGROUP name="Distributor"/>
</costGroup>
<involvedParty>
<ES_FIRM f_name="Walt Disney Co Ltd."/>
</involvedParty>
</ES_CM2CostDefinition>
<ES_CM2CostDefinition>
<costGroup>
<ESP_2COSTGROUP name="Dubbing Cost"/>
</costGroup>
<involvedParty>
<ES_FIRM f_name="GRANDVIEW"/>
</involvedParty>
</ES_CM2CostDefinition>
</costDefinitions>
</ES_BROADCASTRIGHTGROUP>
</broadcastRightGroup>
</ES_CM2BROADCASTRIGHT>
</broadcastRights>
</ES_CMProductInContract>
</productInContracts>
</ES_CMContract>
</contracts>
我的 XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<xsl:template match="contracts">
<xsl:processing-instruction name="mso-application">progid="Excel.Sheet"</xsl:processing-instruction>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<Styles>
<Style ss:ID="header" ss:Name="Normal">
<Font ss:FontName="Verdana" ss:Bold="1"/>
</Style>
</Styles>
<Worksheet ss:Name="Report">
<Table>
<Row ss:Index="1">
<!-- contract name -->
<Cell ss:Index="1" ss:StyleID="header">
<Data ss:Type="String">contract name</Data>
</Cell>
<!-- Distributor_01 -->
<Cell ss:Index="2" ss:StyleID="header">
<Data ss:Type="String">Cost_1</Data>
</Cell>
<!-- Firm_01 -->
<Cell ss:Index="3" ss:StyleID="header">
<Data ss:Type="String">firm_1</Data>
</Cell>
<!-- Distributor_02 -->
<Cell ss:Index="4" ss:StyleID="header">
<Data ss:Type="String">Cost_2</Data>
</Cell>
<!-- Firm_02 -->
<Cell ss:Index="5" ss:StyleID="header">
<Data ss:Type="String">firm_2</Data>
</Cell>
<!-- Distributor_03 -->
<Cell ss:Index="6" ss:StyleID="header">
<Data ss:Type="String">Cost_3</Data>
</Cell>
<!-- Firm_03 -->
<Cell ss:Index="7" ss:StyleID="header">
<Data ss:Type="String">firm_3</Data>
</Cell>
<!-- Distributor_04 -->
<Cell ss:Index="8" ss:StyleID="header">
<Data ss:Type="String">Cost_4</Data>
</Cell>
<!-- Firm_04 -->
<Cell ss:Index="9" ss:StyleID="header">
<Data ss:Type="String">firm_4</Data>
</Cell>
</Row>
<xsl:for-each select="ES_CMContract">
<xsl:variable name="cost" select="productInContracts/ES_CMProductInContract/broadcastRights/ES_CM2BROADCASTRIGHT/broadcastRightGroup/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition"/>
<xsl:choose>
<xsl:when test="productInContracts/ES_CMProductInContract/episodesInContract">
<xsl:for-each select="productInContracts/ES_CMProductInContract/broadcastRights/ES_CM2BROADCASTRIGHT/broadcastRightGroup/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition">
<Row>
<!-- contract name -->
<Cell ss:Index="1" >
<Data ss:Type="String">
<xsl:value-of select="@contractName"/>
</Data>
</Cell>
<!-- Distributor_01 -->
<Cell ss:Index="2" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Distributor']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_01 -->
<Cell ss:Index="3" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Distributor']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
<!-- Distributor_02 -->
<Cell ss:Index="4" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Material Cost']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_02 -->
<Cell ss:Index="5" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Material Cost']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
<!-- Distributor_03 -->
<Cell ss:Index="6" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Dubbing Cost']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_03 -->
<Cell ss:Index="7" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Dubbing Cost']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
<!-- Distributor_04 -->
<Cell ss:Index="8" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Technical Cost']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_04 -->
<Cell ss:Index="9" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Technical Cost']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
</Row>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="productInContracts/ES_CMProductInContract/broadcastRights/ES_CM2BROADCASTRIGHT/broadcastRightGroup/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition">
<Row>
<!-- contract name -->
<Cell ss:Index="1" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/@contractName"/>
</Data>
</Cell>
<!-- Distributor_01 -->
<Cell ss:Index="2" >
<Data ss:Type="String">
<xsl:value-of select="[costGroup/ESP_2COSTGROUP/@name='Distributor']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_01 -->
<Cell ss:Index="3" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Distributor']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
<!-- Distributor_02 -->
<Cell ss:Index="4" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Material Cost']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_02 -->
<Cell ss:Index="5" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Material Cost']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
<!-- Distributor_03 -->
<Cell ss:Index="6" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Dubbing Cost']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_03 -->
<Cell ss:Index="7" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Dubbing Cost']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
<!-- Distributor_04 -->
<Cell ss:Index="8" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Technical Cost']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_04 -->
<Cell ss:Index="9" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Technical Cost']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
</Row>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</Table>
</Worksheet>
</Workbook>
</xsl:template>
</xsl:stylesheet>
我错过了什么?
我认为我的 xpath 是问题所在,但不确定。
谢谢。
更新 1.:
我试过:
<xsl:template match="ES_CM2CostDefinition" mode="Distributor_name"> <!-- Distributor name -->
<xsl:if test="costGroup/ESP_2COSTGROUP/@name = 'Distributor'">
<xsl:value-of select="costGroup/ESP_2COSTGROUP/@name"/>
</xsl:if>
</xsl:template>
<xsl:template match="ES_CM2CostDefinition" mode="Distributor_Supplier"> <!-- Distributor Supplier -->
<xsl:if test="costGroup/ESP_2COSTGROUP/@name = 'Distributor'">
<xsl:value-of select="involvedParty/ES_FIRM/@f_name"/>
</xsl:if>
</xsl:template>
但这不是一个好的选择,因为我只想在“Cost_1”看到经销商,在“Cost_2”我只想看到“[=37” =] 成本”,在“Cost_3”只有“配音成本”,在“Cost_4”只有“技术成本”。
您写了:
select="[costGroup/ESP_2COSTGROUP/@name='Distributor']/costGroup/ESP_2COSTGROUP/@name"
这是无效的 XPath 语法。我不知道您认为它可能意味着什么,但它没有任何意义(XPath 表达式从不以“[”开头)。为了帮助您更正错误,我需要了解您的代码试图做什么,恐怕我没有时间。
我想在 xsl:otherwise 元素中分离我的成本。 我已经在具有祖先的 otherwise 元素中尝试了我的 XPATH,但无法获取任何数据。 我在没有祖先的 otherwise 元素中尝试了我的 XPATH,但它也不起作用。 重要的是在 otherwise 元素下解决这个问题。
我想像这样分开所有费用: enter image description here
我的XML:
<?xml version="1.0" encoding="UTF-8"?>
<contracts>
<ES_CMContract contractName="test_01">
<productInContracts>
<ES_CMProductInContract>
<broadcastRights>
<ES_CM2BROADCASTRIGHT>
<broadcastRightGroup>
<ES_BROADCASTRIGHTGROUP>
<costDefinitions>
<ES_CM2CostDefinition>
<costGroup>
<ESP_2COSTGROUP name="Distributor"/>
</costGroup>
<involvedParty>
<ES_FIRM f_name="FREMANTLE MEDIA"/>
</involvedParty>
</ES_CM2CostDefinition>
<ES_CM2CostDefinition>
<costGroup>
<ESP_2COSTGROUP name="Material Cost"/>
</costGroup>
<involvedParty>
<ES_FIRM f_name="FREMANTLE MEDIA"/>
</involvedParty>
</ES_CM2CostDefinition>
<ES_CM2CostDefinition>
<costGroup>
<ESP_2COSTGROUP name="Dubbing Cost"/>
</costGroup>
<involvedParty>
<ES_FIRM f_name="FREMANTLE MEDIA"/>
</involvedParty>
</ES_CM2CostDefinition>
<ES_CM2CostDefinition>
<costGroup>
<ESP_2COSTGROUP name="Technical Cost"/>
</costGroup>
<involvedParty>
<ES_FIRM f_name="FREMANTLE MEDIA"/>
</involvedParty>
</ES_CM2CostDefinition>
</costDefinitions>
</ES_BROADCASTRIGHTGROUP>
</broadcastRightGroup>
</ES_CM2BROADCASTRIGHT>
</broadcastRights>
</ES_CMProductInContract>
</productInContracts>
</ES_CMContract>
<ES_CMContract contractName="test_02">
<productInContracts>
<ES_CMProductInContract>
<broadcastRights>
<ES_CM2BROADCASTRIGHT>
<broadcastRightGroup>
<ES_BROADCASTRIGHTGROUP>
<costDefinitions>
<ES_CM2CostDefinition>
<costGroup>
<ESP_2COSTGROUP name="Distributor"/>
</costGroup>
<involvedParty>
<ES_FIRM f_name="Walt Disney Co Ltd."/>
</involvedParty>
</ES_CM2CostDefinition>
<ES_CM2CostDefinition>
<costGroup>
<ESP_2COSTGROUP name="Dubbing Cost"/>
</costGroup>
<involvedParty>
<ES_FIRM f_name="GRANDVIEW"/>
</involvedParty>
</ES_CM2CostDefinition>
</costDefinitions>
</ES_BROADCASTRIGHTGROUP>
</broadcastRightGroup>
</ES_CM2BROADCASTRIGHT>
</broadcastRights>
</ES_CMProductInContract>
</productInContracts>
</ES_CMContract>
</contracts>
我的 XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<xsl:template match="contracts">
<xsl:processing-instruction name="mso-application">progid="Excel.Sheet"</xsl:processing-instruction>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<Styles>
<Style ss:ID="header" ss:Name="Normal">
<Font ss:FontName="Verdana" ss:Bold="1"/>
</Style>
</Styles>
<Worksheet ss:Name="Report">
<Table>
<Row ss:Index="1">
<!-- contract name -->
<Cell ss:Index="1" ss:StyleID="header">
<Data ss:Type="String">contract name</Data>
</Cell>
<!-- Distributor_01 -->
<Cell ss:Index="2" ss:StyleID="header">
<Data ss:Type="String">Cost_1</Data>
</Cell>
<!-- Firm_01 -->
<Cell ss:Index="3" ss:StyleID="header">
<Data ss:Type="String">firm_1</Data>
</Cell>
<!-- Distributor_02 -->
<Cell ss:Index="4" ss:StyleID="header">
<Data ss:Type="String">Cost_2</Data>
</Cell>
<!-- Firm_02 -->
<Cell ss:Index="5" ss:StyleID="header">
<Data ss:Type="String">firm_2</Data>
</Cell>
<!-- Distributor_03 -->
<Cell ss:Index="6" ss:StyleID="header">
<Data ss:Type="String">Cost_3</Data>
</Cell>
<!-- Firm_03 -->
<Cell ss:Index="7" ss:StyleID="header">
<Data ss:Type="String">firm_3</Data>
</Cell>
<!-- Distributor_04 -->
<Cell ss:Index="8" ss:StyleID="header">
<Data ss:Type="String">Cost_4</Data>
</Cell>
<!-- Firm_04 -->
<Cell ss:Index="9" ss:StyleID="header">
<Data ss:Type="String">firm_4</Data>
</Cell>
</Row>
<xsl:for-each select="ES_CMContract">
<xsl:variable name="cost" select="productInContracts/ES_CMProductInContract/broadcastRights/ES_CM2BROADCASTRIGHT/broadcastRightGroup/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition"/>
<xsl:choose>
<xsl:when test="productInContracts/ES_CMProductInContract/episodesInContract">
<xsl:for-each select="productInContracts/ES_CMProductInContract/broadcastRights/ES_CM2BROADCASTRIGHT/broadcastRightGroup/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition">
<Row>
<!-- contract name -->
<Cell ss:Index="1" >
<Data ss:Type="String">
<xsl:value-of select="@contractName"/>
</Data>
</Cell>
<!-- Distributor_01 -->
<Cell ss:Index="2" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Distributor']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_01 -->
<Cell ss:Index="3" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Distributor']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
<!-- Distributor_02 -->
<Cell ss:Index="4" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Material Cost']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_02 -->
<Cell ss:Index="5" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Material Cost']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
<!-- Distributor_03 -->
<Cell ss:Index="6" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Dubbing Cost']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_03 -->
<Cell ss:Index="7" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Dubbing Cost']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
<!-- Distributor_04 -->
<Cell ss:Index="8" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Technical Cost']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_04 -->
<Cell ss:Index="9" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Technical Cost']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
</Row>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="productInContracts/ES_CMProductInContract/broadcastRights/ES_CM2BROADCASTRIGHT/broadcastRightGroup/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition">
<Row>
<!-- contract name -->
<Cell ss:Index="1" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/@contractName"/>
</Data>
</Cell>
<!-- Distributor_01 -->
<Cell ss:Index="2" >
<Data ss:Type="String">
<xsl:value-of select="[costGroup/ESP_2COSTGROUP/@name='Distributor']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_01 -->
<Cell ss:Index="3" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Distributor']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
<!-- Distributor_02 -->
<Cell ss:Index="4" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Material Cost']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_02 -->
<Cell ss:Index="5" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Material Cost']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
<!-- Distributor_03 -->
<Cell ss:Index="6" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Dubbing Cost']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_03 -->
<Cell ss:Index="7" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Dubbing Cost']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
<!-- Distributor_04 -->
<Cell ss:Index="8" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Technical Cost']/costGroup/ESP_2COSTGROUP/@name"/>
</Data>
</Cell>
<!-- Firm_04 -->
<Cell ss:Index="9" >
<Data ss:Type="String">
<xsl:value-of select="ancestor::ES_CMContract/broadcastRightGroups/ES_BROADCASTRIGHTGROUP/costDefinitions/ES_CM2CostDefinition[costGroup/ESP_2COSTGROUP/@name='Technical Cost']/involvedParty/ES_FIRM/@f_name"/>
</Data>
</Cell>
</Row>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</Table>
</Worksheet>
</Workbook>
</xsl:template>
</xsl:stylesheet>
我错过了什么? 我认为我的 xpath 是问题所在,但不确定。
谢谢。
更新 1.:
我试过:
<xsl:template match="ES_CM2CostDefinition" mode="Distributor_name"> <!-- Distributor name -->
<xsl:if test="costGroup/ESP_2COSTGROUP/@name = 'Distributor'">
<xsl:value-of select="costGroup/ESP_2COSTGROUP/@name"/>
</xsl:if>
</xsl:template>
<xsl:template match="ES_CM2CostDefinition" mode="Distributor_Supplier"> <!-- Distributor Supplier -->
<xsl:if test="costGroup/ESP_2COSTGROUP/@name = 'Distributor'">
<xsl:value-of select="involvedParty/ES_FIRM/@f_name"/>
</xsl:if>
</xsl:template>
但这不是一个好的选择,因为我只想在“Cost_1”看到经销商,在“Cost_2”我只想看到“[=37” =] 成本”,在“Cost_3”只有“配音成本”,在“Cost_4”只有“技术成本”。
您写了:
select="[costGroup/ESP_2COSTGROUP/@name='Distributor']/costGroup/ESP_2COSTGROUP/@name"
这是无效的 XPath 语法。我不知道您认为它可能意味着什么,但它没有任何意义(XPath 表达式从不以“[”开头)。为了帮助您更正错误,我需要了解您的代码试图做什么,恐怕我没有时间。