MySQLクエリブラウザを使用したXMLプロデュースがあります。XSLTを適用して結果をWordテーブルに出力しようとしています。レコードごとに1つのテーブル。
これが私のXMLのサンプルです
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ROOT SYSTEM "Nessus.dtd">
<ROOT>
<row>
<field name="Niveau">Critique</field>
<field name="Name">Apache 2.2 < 2.2.15 Multiple Vulnerabilities</field>
</row>
<row>
<field name="Niveau">Critique</field>
<field name="VulnName">Microsoft Windows 2000 Unsupported Installation Detection</field>
</row>
<row>
<field name="Niveau">Haute</field>
<field name="VulnName">CGI Generic SQL Injection</field>
</row>
</ROOT>
XLSTの場合、私はfor-eachselectを実行する必要があることをすでに知っています
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="ROOT/row">
Niveau : <xsl:value-of select="????"/>
Name : <xsl:value-of select="????"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
このループを実行すると、ファイルと同じ数の空のテーブルが<row></row>
表示されます。
しかし、私は正しい「select-ofselect=」を作成する方法を見つけていません。私は運がなくて次のことを試みました。
<xsl:value-of select="@name"/>
<xsl:value-of select="name"/>
<xsl:value-of select="@row/name"/>
<xsl:value-of select="row/@name"/>
<xsl:value-of select="@ROOT/row/name"/>
そして、私が思い出せない他のいくつか。結果のファイルで値を取得するためにリクエストを作成するために何が必要か考えてみてください。
私はちょうど試しました:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="ROOT/row">
Niveau : <xsl:value-of select="field/@Niveau"/>
Name : <xsl:value-of select="field/@name"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
そしてそれはこれを出力します:
NIVEAU :
NAME : name
NIVEAU :
NAME : Niveau
NIVEAU :
NAME : Niveau
私はこの出力が欲しいです:
NIVEAU : Critique
NAME : Apache 2.2 < 2.2.15 Multiple Vulnerabilities
NIVEAU : Critique
NAME : Microsoft Windows 2000 Unsupported Installation Detection
NIVEAU : Haute
NAME : CGI Generic SQL Injection
どんな助けでもいただければ幸いです。
ありがとうございました。
アップデート
今このXSLTで
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>
<xsl:template match="row">
<xsl:text>NIVEAU : </xsl:text>
<xsl:value-of select="field[@name = 'Niveau']"/>
<xsl:text>
</xsl:text>
<xsl:text>NAME : </xsl:text>
<xsl:value-of select="field[@name = 'Name']"/>
<xsl:text>

</xsl:text>
</xsl:template>
</xsl:stylesheet>
私はこの出力を取得します:
<?xml version="1.0"?>
NIVEAU :
NAME : Apache 2.2 < 2.2.15 Multiple Vulnerabilities
NIVEAU : Critique
NAME : Microsoft Windows 2000 Unsupported Installation Detection
NIVEAU : Haute
NAME : CGI Generic SQL Injection
ご覧のとおり、最初のフィールドは空です。私は正直にそれと一緒に住んで手動でそれを埋めることができましたが、なぜこれが起こっているのかを理解できれば私はとても幸せです:)
アップデート
使用<xsl:value-of select="field[@name = 'foo']"/>
することで、私が望んでいた価値が得られました。MS Wordテンプレート内で(私にとって)使いやすかったので、for-eachを保持しました。