下面是我的XML文件 - 下面單個XSLT文件能解決這個問題嗎?或者?
<CVs>
<CV>
<Name>ABC</Name>
<Address></Address>
<Introduction></Introduction>
<CompSkills>Java, XSLT, XPATH, XML, Oracle, VB.NET</CompSkills>
<Experience>
<Profile></Profile>
<Duration></Duration>
<Info></Info>
</Experience>
<Experience>
<Profile></Profile>
<Duration></Duration>
<Info></Info>
</Experience>
<Experience>
<Profile></Profile>
<Duration></Duration>
<Info></Info>
</Experience>
<CV>
<CV>
<Name>XYZ</Name>
<Address></Address>
<Introduction></Introduction>
<CompSkills>Java, XSLT, XPATH, XML, JSP, HTML</CompSkills>
<Experience>
<Profile></Profile>
<Duration></Duration>
<Info></Info>
</Experience>
<Experience>
<Profile></Profile>
<Duration></Duration>
<Info></Info>
</Experience>
<Experience>
<Profile></Profile>
<Duration></Duration>
<Info></Info>
</Experience>
<CV>
</CVs>
是XSLT文件 - 簡短版本,以獲得一個想法
<xsl:template match="Name">
<table align='center' width='800' style="font-family:tahoma; font-size:13pt;">
<tr><td>
<xsl:apply-templates/>
</td></tr>
</table>
</xsl:template>
<xsl:template match="Experience">
<table align='center' width='800' style="font-family:tahoma; font-size:13pt;">
<tr><td>
<xsl:apply-templates/>
</td></tr>
</table>
</xsl:template>
我使用Java作爲前端。要以HTML格式顯示輸出,我有一個XSLT文件。這個XSLT文件是一個標準的文件,即;它顯示所有的簡歷。
現在我要做的就是用一個列表框與所有候選人的名字和特定名稱點擊時,只有他的簡歷應該得到顯示。我編寫了Java部分,將候選人的名字顯示在列表框中。現在,在以HTML格式顯示所選候選人的簡歷時遇到了一些麻煩。
當前的XSLT文件顯示所有CV。所以我需要另一個XSLT文件,它使用從程序傳遞的參數並顯示其細節。如果是的話,那麼有關如何做到這一點的幫助......?
預先感謝約翰 -
好問題,+1。您需要將所選名稱作爲全局參數傳遞給變換 - 然後執行想要的變換很容易。 –
Dimitre-非常感謝您的回答。你的意思是我必須首先將所需匹配提取到XML輸出中,然後將此文件傳遞給XSLT文件以獲取HTML輸出。再次感謝您的答覆。 :) – John
@_John:不,我的意思是說在調用轉換的代碼中,您必須設置一個帶有想要的CV名稱(或*)的參數。我不知道你使用的是什麼特定的Java XSLT處理器。我通常使用.NET的XslCompiledTransform,這裏描述瞭如何爲轉換設置一個外部參數:http://msdn.microsoft.com/en-us/library/system.xml.xsl.xsltargumentlist.addparam.aspx For撒克遜人,看看薩克森文檔中的這些示例應用程序:http://www.saxonica.com/documentation9.2/samples/intro.html –