Java 一个XSLT文件能否解决这个问题-continuation。。?
这个问题与我的这个职位有关- 下面是我的XML文件-Java 一个XSLT文件能否解决这个问题-continuation。。?,java,xml,xslt,xpath,Java,Xml,Xslt,Xpath,这个问题与我的这个职位有关- 下面是我的XML文件- <CVs> <CV> <Name>ABC</Name> <Address></Address> <Introduction></Introduction> <CompSkills>Java, XSLT, XPATH, XML, Oracle, VB.NET</CompSkills> <Experi
<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>
基础知识
Java、XSLT、XPATH、XML、Oracle、VB.NET
XYZ
Java、XSLT、XPATH、XML、JSP、HTML
下面是我的XSLT文件-(Dimitre给出了这个答案,但现在是我的;)
上面的XSLT将提取从Java传递的匹配的
现在我需要知道如何修改这个XSLT,如果我将Oracle作为参数传递,那么
那些在
中拥有Oracle的人将被列入名单。Oracle将是CompSkills之一
提前感谢-JohnXPath 1.0,简易方法:函数,例如:
<xsl:if test="contains(CompSkills, $pSkill)">
您可以使用
contains()
完成此操作
如果名称
与pName
参数匹配,或者CompSkills
包含pSkill
参数,则样式表的此修改版本将拉取CV
<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:param name="pSkill" select="'Oracle'"/>
<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='*' or
contains(CompSkills,$pSkill)">
<xsl:call-template name="identity"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
除了名称
之外,您是否希望获得带有“Oracle”的简历
,或者不想要名称
?@DevNull-:)这两种答案都是一种优势。:)非常感谢-JohnI修改了我的答案,使之与技能或名称匹配。希望这有帮助。@DevNull-非常感谢亲爱的…:)-约翰
<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:param name="pSkill" select="'Oracle'"/>
<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='*' or
contains(CompSkills,$pSkill)">
<xsl:call-template name="identity"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>