我有一个an earlier post的解决方案,由Dimitre Novatchev友情提供。XSL匹配一些但不是全部
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="my:my">
<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/>
<xsl:key name="kPhysByName" match="KB_XMod_Modules" use="Physician"/>
<xsl:template match="/">
<result>
<xsl:apply-templates/>
</result>
</xsl:template>
<xsl:template match="/*/*/*[starts-with(name(), 'InfBy')]">
<xsl:variable name="vCur" select="."/>
<xsl:for-each select="document('doc2.xml')">
<xsl:variable name="vMod" select="key('kPhysByName', $vCur)"/>
<xsl:copy>
<items>
<item>
<label>
<xsl:value-of select="$vMod/Physician"/>
</label>
<value>
<xsl:value-of select="$vMod/XModID"/>
</value>
</item>
</items>
</xsl:copy>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
我现在需要在我的源XML使用额外的领域和需要的现有标签完好,但我在得到这个持续存在的问题。
<instance>
<NewTag>Hello</newTag1>
<AnotherNewTag>Everyone</AnotherNewTag>
<InfBy1>Dr Phibes</InfBy1>
<InfBy2>Dr X</InfBy2>
<InfBy3>Dr Chivago</InfBy3>
</instance>
它植入额外的标签和产出
<result xmlns:my="my:my">
HelloEveryone
<items>
<item>
<label>Dr Phibes</label>
<value>60</value>
</item>
</items>
...
我一直在尝试了很多与
<xsl:otherwise>
<xsl:copy-of select=".">
</xsl:copy-of>
</xsl:otherwise>
但作为一个xsl新手我似乎无法得到这个工作。我有一种感觉,我在吠叫错误的树!
有没有人有任何想法?
感谢,
将
XPath表达式match =“/ */*/*”怎么样? – ThomasRS 2011-03-17 16:18:35