1
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Package ID="b7137f2>
<Compatibility_Rules ID="32fd84b4-7b9b-40e2-8265-8e2e4f856a8d">
<Rule_Event ID="992f04cb-6bd1-42bb-9578-87793dd38aca">
<Name>Entity Selection</Name>
</Rule_Event><Rule_Name>Private Line Exclusions</Rule_Name>
<Rule_Statement ID="d0cc0700-2199-4a51-af68-72dfe27d878f">
<Description>Package is Private line</Description>
</Rule_Statement>
</Compatibility_Rules>
</Package>
</Root>
我想提取属性名称“规则事件”,并显示为:检索元素名称
<attribute depth="0">
<name>Compatibility Rules</name>
<value GUID="B7137F2">
<attributes>
<attribute depth="1">
<name>Rule Event</name>
<value GUID="32FD84B4">
<attributes/>
</value>
</attribute>
</attributes>
</value>
</attribute>
我尝试以下,但名称()返回规则事件即兼容性规则的父。
<xsl:template match="Compatibility_Rules">
<attribute depth="0">
<name>
<xsl:value-of select="local-name()"/>
</name>
<value GUID="{../../*/@ID}"></value>
<attributes>
<attribute depth="1">
<name><xsl:value-of select="name()"/> </name>
</attribute>
</attributes>
</attribute>
</xsl:template>
我该如何去规则事件。我对XML和XSL完全陌生。
这有点不清楚。首先,正如你所描述的那样,你所期望的输出甚至不是完整的。你能在几句话中描述所需的效果吗? – toniedzwiedz