Output once if both xml tags occur at the same time

只谈情不闲聊 提交于 2019-12-12 06:23:49

问题


If both xml tags exist I only want the output of the transform to occur once. Is that possible?

xsl

<xsl:template match="latitude | longitude">
   <generate_once>for both tags below</generate_once>
</xsl:template>

xml

<doc>
<latitude /><longitude />
</doc>

回答1:


Will this template do the trick...?

<xsl:template match="latitude | longitude[not(../latitude)]">
   <generate_once>for both tags below</generate_once>
</xsl:template>

This works by matching latitude if it exists (regardless of whether there is a longitude or not). It will only match longitude if there is no latitude though. So, in the case of both being present, only the latitude is matched.



来源:https://stackoverflow.com/questions/44375739/output-once-if-both-xml-tags-occur-at-the-same-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!