こんにちは、質問があります。私は XSLT に非常に慣れていないので、これは初歩的な質問かもしれません。これは私の xml 構造です。
<FAQ>
<!--About Us-->
<Query Section="About Us">
<Question>How do I contact Support?</Question>
<Answer>
You can connect with us on Twitter or Facebook.
</Answer>
</Query>
<Query Section="About Us">
<Question>Who we are?</Question>
<Answer>Will discus it later</Answer>
</Query>
<Query Section="Another section">
<Question>any question?</Question>
<Answer>answer</Answer>
</Query>
</FAQ>
これが私のXSLTです
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
</head>
<body>
<h2>FAQS</h2>
<div border="1">
<xsl:for-each select="//*[@Section]">
<xsl:sort select="@Section"/>
<ul>
<li style="color:blue;cursor:pointer" class="Question">
<xsl:value-of select="Question"/>
</li>
<li style="display:none" class="answer">
<xsl:value-of select="Answer"/>
</li>
</ul>
</xsl:for-each>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
期待どおりにすべてを取得していますが、このようなものを取得しているため、ヘッダーが繰り返されています
- 私たちに関しては
- サポートへの連絡方法
答え
私たちに関しては
- 私たちは誰ですか?
答え
別のセクション
- 質問
- 答え
しかし、私はこのようなものが欲しい
- 私たちに関しては
- サポートへの連絡方法
答え
私たちは誰ですか?
答え
別のセクション
質問
- 答え
私たちについての見出しは一度しか来ないことに注意してください:) すべてのことをうまく説明できたことを願っています