0
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">    
<Package ID="b7137f22-31da-4d90-971c-b6baad654c96" BusinessID="P_000137" Path="/Package/Product/Launch_Entity" xsi:type="Package_Private_Line">
    <Category_ID Product_Line_ID="63">63</Category_ID>
    <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>IF package is Private line THEN exclude Ethernet Switched Access (ESA)</Description>
            <Actions ID="d8165dda-7f8b-4c44-8400-eb081c0ec79c">
                <Then>THEN exclude Ethernet Switched Access (ESA</Then>
                <Entity>PSpec_000164</Entity><Operand ID="f74c6bf3-2718-4f8c-90e1-ead1257edc3a">
                    <Name>EXCLUDE</Name>
                </Operand></Actions>
            <Conditions ID="12dd11ea-bfe7-4ef3-b35c-f06cc90b1b6b">
                <If>IF package is Private Line</If>
                <Operand ID="8d041d93-77c7-46ac-938d-753596b8535c">
                    <Name>EXISTS</Name>
                </Operand>
                <Entity>P_000137</Entity>
            </Conditions></Rule_Statement>
    </Compatibility_Rules>
</Package>
</Root>

以上是我要转换的 XML。我需要将 Compatibility_Rules 显示为:

<attribute><name>Compatibility Rules</name><value GUID="b7137f22-31da-4d90-971c-b6baad654c96"></value>

上面的 GUID 是 Package 的 ID 属性。我不知道如何实现这一目标。

4

1 回答 1

1

选择父元素的 ID 属性:

../*/@ID

应用在 XSLT 中的模板中以Compatability_Rules使用属性值模板

<xsl:template match="Compatibility_Rules">
    <attribute>
            <name>
                <xsl:value-of select="local-name()"/>
            </name>
            <value GUID="{../*/@ID}"></value>
    </attribute>
</xsl:template>
于 2012-06-27T01:40:59.677 回答