2017-11-14 11 views
0

入力:私がしようとxsltは子属性を親に移動し、最初の行を削除します。

<Conductor Tag="A111K" Type="Normal" Length="7481" Length_Status="Real" Gauge="0.5" Wire_Type="08NtyH" Class="" Segregation="2A" TemperatureZone="20" Net="163K" Description="" Material="Undefined" MaterialType="Copper" ExternalDiameter="8.8" ProvidedWithEquipment="No" Color="BU" TagType="Standard" WireOrder="0" SourceType="Automatic" ManualAssignation="No" Resistivity="0" XDirectionLength="5497"> 
         <UserAttribute AttributeName="NeoNetTAG" AttributeValue="blabla_018" /> 
         <UserAttribute AttributeName="NeoWireTAG" AttributeValue="xxxxxxx_02" /> 
         <MFConductorExtremityFrom/> 
    </Conductor> 

が出力

<Conductor AttributeValue="xxxxxxx_02" Tag="A111K" Type="Normal" Length="7481" Length_Status="Real" Gauge="0.5" Wire_Type="08NtyH" Class="" Segregation="2A" TemperatureZone="20" Net="163K" Description="" Material="Undefined" MaterialType="Copper" ExternalDiameter="8.8" ProvidedWithEquipment="No" Color="BU" TagType="Standard" WireOrder="0" SourceType="Automatic" ManualAssignation="No" Resistivity="0" XDirectionLength="5497"> 
        <MFConductorExtremityFrom/> 
</Conductor> 

:XSLTをだけの両方を削除:(

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/> 

    <xsl:strip-space elements="*"/> 

    <xsl:template match="Conductor"> 
    <xsl:copy> 
     <!-- 
     Apply the attributes of the current node and the attributes of all 
     following siblings (in this case, <address> and <phone>) 
     --> 
     <xsl:apply-templates select="@* | following-sibling::*/@*"/> 
    </xsl:copy> 
    </xsl:template> 

    <!-- Drop the <address> and <phone> elements --> 
    <xsl:template match="AttributeValue"/> 

    <!-- 
    Identity transform: copy attributes and elements from input document to output 
    document as is 
    --> 
    <xsl:template match="@* | node()"> 
    <xsl:copy> 
     <xsl:apply-templates select="@* | node()"/> 
    </xsl:copy> 
    </xsl:template> 
</xsl:stylesheet> 

今ながら、私はこのαでてきた - XSLTを持っています主に作業して、不要なノードや属性を削除しましたが、その一部が私を投げています。 助けてください:(

+0

このXSLTを試してみてください。子要素から 'AttributeValue'属性をコピーしているようですが、なぜ' AttributeName'ではないのでしょうか?また、 'MFConductorExtremityFrom'ではなく、なぜ子要素' UserAttribute'が削除されていますか?ありがとう –

+0

このxsltの目標は、あなたの興味に感謝します:remove: AttributeValue = "xxxxxxx_02"のみを<導体に接続します。 MFConductorExtremityより多くの属性があり、それを残す必要があります。 – aliciavika

答えて

0

私はあなたの正確なロジックのわからないようしたい式が、これは、...

<xsl:apply-templates 
    select="@*|UserAttribute[@AttributeName='NeoWireTAG']/@AttributeValue"/> 

それとも、このだと思います....

<xsl:apply-templates select="@*|UserAttribute[last()]/@AttributeValue"/> 

ます。また、テンプレートが必要ですUserAttributeノードを削除します。

<xsl:template match="UserAttribute"/> 

あなたは、より詳細にロジックを説明でき

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/> 

    <xsl:strip-space elements="*"/> 

    <xsl:template match="Conductor"> 
    <xsl:copy> 
     <xsl:apply-templates select="@*|UserAttribute[last()]/@AttributeValue"/> 
     <xsl:apply-templates /> 
    </xsl:copy> 
    </xsl:template> 

    <xsl:template match="UserAttribute"/> 

    <xsl:template match="@* | node()"> 
    <xsl:copy> 
     <xsl:apply-templates select="@* | node()"/> 
    </xsl:copy> 
    </xsl:template> 
</xsl:stylesheet> 
+0

ありがとう、ありがとう非常に:) – aliciavika

関連する問題