1

XSLT を使用して XML ドキュメントを HTML に変換しようとしています。

ドキュメントは外部のものであり、完全には文書化されていません。そのために、私はいくつかのノードしか知りません (したがって、処理します)。

新しいノードが追加される場合があります。

最初に不明な子ノードがあるかどうかを判断し、ある場合は単純に HTML テーブルに表示します。派手なものはありません。

私の現在のxsltスニペットは...

<xsl:if test="*[not(service or searchtext or clientreference or threshold or resultcount or results or options or error)]">
<div class="requestSupportData">
    <table class="zebra">
        <caption>Request supportive data</caption>
        <thead>
            <tr>
                <th>Element</th>
                <th>Value</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th colspan="2">
                    <a href="#top">Top</a>
                </th>
            </tr>
        </tfoot>
        <tbody>
            <xsl:for-each select="*[not(service or searchtext or clientreference or threshold or resultcount or results or options or error)]">
                <tr>
                    <th>
                        <xsl:value-of select="local-name(.)"/>
                    </th>
                    <td>
                        <xsl:value-of select="."/>
                    </td>
                </tr>
            </xsl:for-each>
        </tbody>
    </table>
</div>

ここで達成しようとしているのは、サービス、検索テキストなどと呼ばれていないノードがあることです。そのため、それらを HTML テーブルの単純な名前/値のペアとしてレンダリングします。

不要な要素を含め、何も取得していないか、すべてを取得しています。

よろしく、

リチャード。

4

1 に答える 1

3

この式:

 *[not(service or searchtext or clientreference or ...)]

「 、などの名前の要素を持たないすべての子要素」を意味します。に変更します<service><searchtext>

 *[not(self::service or self::searchtext or self::clientreference or ...)]

これは、「 、などの名前が付いていないすべての子要素」を意味します。<service><searchtext>

于 2013-05-20T17:50:25.230 に答える