這個問題與這個職位我的連接 - Will a Single XSLT file solve this issue..or...?單個XSLT文件能否解決此問題 - 延續..?
下面是我的XML文件 -
<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>
下面是我的XSLT文件 - (以及Dimitre給了這個答案,但現在它);))
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="pName" select="'XYZ'"/>
<xsl:template match="node()|@*" name="identity">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="CV">
<xsl:if test="$pName = Name or $pName='*'">
<xsl:call-template name="identity"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
上述XSLT將提取匹配從Java傳遞的。
現在我需要知道我可以修改這個XSLT,所以如果我通過甲骨文作爲參數,然後 那些誰在<CompSkills>
有甲骨文將可以上市。將Oracle CompSkills之一..
預先感謝約翰 -
除了'Name'或者'Name'之外,你還想獲得帶有「Oracle」的CV嗎? –
@ DevNull- :)兩者的答案將是一個優勢。 :)非常感謝 - 約翰 – John
我修改了我的答案,以便它匹配技能或名稱。希望這可以幫助。 –