首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法为特定需求创建xslt

无法为特定需求创建xslt
EN

Stack Overflow用户
提问于 2016-08-18 11:37:30
回答 1查看 30关注 0票数 0

xslt新手。这是输入的xml。

代码语言:javascript
复制
<Response>
     <RecordNumber/>
     <id>2014-12-24</id>
     <person>            
        <gender>MALE</gender>
        <genericLocations>            
           <effective>2012-11-28</effective>
        </genericLocations>
        <genericLocations>              
           <expiration>2012-11-27</expiration>               
           <effective>2008-12-09</effective>
        </genericLocations>
        <genericLocations>
            <expiration>2008-12-08</expiration>               
           <effective>2006-01-13</effective>
        </genericLocations>
        <genericLocations>
           <expiration>2006-01-12</expiration>               
           <effective>2001-07-17</effective>
        </genericLocations>
        <genericLocations>              
           <expiration>2001-07-16</expiration>               
           <effective>1901-01-01</effective>
        </genericLocations>
      </person>
  </Response>

以下是所需的输出XML:

代码语言:javascript
复制
<Response>
     <RecordNumber/>
     <id>2014-12-24</id>
     <person>            
        <gender>MALE</gender>
        <genericLocations>            
           <effective>2012-11-28</effective>
        </genericLocations>            
      </person>
  </Response>

输出xml只需要包含一个"genericLocations“节点,该节点中的”empty“要么为空(或缺失),要么是将来的(大于今天的日期)。

任何帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

发布于 2016-08-18 15:25:43

假设XSLT2.0,您希望

代码语言:javascript
复制
<xsl:template match="person">
  <xsl:copy-of select="gender, 
     genericLocations[not(xs:date(expiration) le current-date())][1]"/>
</xsl:template>

再加上一个身份模板,可以原封不动地复制其他所有内容。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39009593

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档