下面是我拥有的输入xml
<InputAnimationConfigurationSchema>
<ConfigurationEffects>
<AEffect Id="1" DisplayName="A Effect">
</WipeEffect>
<BEffect Id="2" DisplayName="B Effect">
</FadeEffect>
<CEffect Id="3" DisplayName="C Effect">
</ConfigurationEffects>
<ConfigurationMappings>
<ConfigurationMap>
<Widget Type="All" Include="true" NeedsMandatoryEffectConfiguration="true"/>
<Trigger Type="Show" />
<ConfigurationEffects>
<Effect>1</Effect>
<Effect>2</Effect>
<Effect>3</Effect>
<Effect>9</Effect>
</ConfigurationEffects>
</ConfigurationMap>
<ConfigurationMap>
<Widget Type="All" Include="true" NeedsMandatoryEffectConfiguration="true"/>
<Trigger Type="Hide" />
<ConfigurationEffects>
<Effect>1</Effect>
<Effect>2</Effect>
<Effect>3</Effect>
<Effect>9</Effect>
</ConfigurationEffects>
</ConfigurationMap>
<ConfigurationMap>
<Widget Type="PIGWidget" Include="false" NeedsMandatoryEffectConfiguration="true"/>
</ConfigurationMap>
<ConfigurationMap>
<Widget Type="PlaceHolder" Include="false" NeedsMandatoryEffectConfiguration="true"/>
</ConfigurationMap>
</ConfigurationMappings>
</InputAnimationConfigurationSchema>
我得到以下格式的输出:
All Show A Effect
--------------------------
All Show C Effect
--------------------------
All Show F Effect
-------------------------
All Show I Effect
----------------------------
All Hide A Effect
---------------------------
All Hide C Effect
--------------------------
现在我面临的问题是,如果父节点没有可用的子节点,那么该节点不会被打印,但我还需要显示小部件占位符和 pigwidget
我想要以下格式的输出:
All Show A Effect
--------------------------
All Show C Effect
--------------------------
All Show F Effect
-------------------------
All Show I Effect
----------------------------
All Hide A Effect
---------------------------
All Hide C Effect
--------------------------
placeholder
---------------------------
pigwidget
---------------------------
对于上面我写的 XSL 是这样的:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="effectLookup" match="/InputAnimationConfigurationSchema/ConfigurationEffects/*" use="@Id" />
<xsl:template match="/">
<html>
<body>
<h2></h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Widget</th>
<th>Trigger</th>
<th>effects</th>
</tr>
<xsl:for-each select="/InputAnimationConfigurationSchema/ConfigurationMappings/ConfigurationMap">
<xsl:variable name="widgetType">
<xsl:value-of select="Widget/@Type"/>
</xsl:variable>
<xsl:variable name="triggerType">
<xsl:value-of select="Trigger/@Type"/>
</xsl:variable>
<xsl:for-each select="ConfigurationEffects/Effect">
<xsl:variable name="effectId">
<xsl:value-of select="./text()"/>
</xsl:variable>
<tr>
<td>
<xsl:value-of select="$widgetType"/>
</td>
<td>
<xsl:value-of select="$triggerType"/>
</td>
<td>
<xsl:value-of select="key('effectLookup', $effectId)/@DisplayName" />
</td>
</tr>
</xsl:for-each>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
请指导我如何实现相同的目标?