<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>
我尝试了以下但 name() 返回规则事件的父级,即兼容性规则。
<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 完全陌生。