0

単一の属性を要素に変換しようとしています。私が使用するXSLは次のとおりです。

   <xsl:template match="TextView/@*">
   <xsl:element name="{name()}">
   <xsl:value-of select="."/>
   </xsl:element>
   </xsl:template>

私のxml:

    <TextView
     android:id="@+id/ti"
     style="@style/HTxt"
     android:text="@string/ti"
     custom:attribute="name" />

上記の XSL は、すべての属性を要素に変換します。しかし、「custom:attribute」のみを変換し、他は無視したいと考えています。どうすればこれを達成できますか?前もって感謝します。

4

1 に答える 1

3

したがって、試し@*てみて@custom:attribute
ください:

<xsl:template match="TextView/@custom:attribute">
        <xsl:element name="{name()}">
            <xsl:value-of select="."/>
        </xsl:element>
</xsl:template>

ただし、注意:custom名前空間の接頭辞です。XML と同じ名前空間 URL を使用して xsl:stylesheet に追加する必要があります。何かのようなもの:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xmlns:custom="CUSTOM_URL"
    version="1.0">
于 2013-06-21T10:04:11.013 に答える