获取节点不工作的最大值 [英] get max value of a node not working

查看:17
本文介绍了获取节点不工作的最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过属性操作获取 LandLine_ExtId 基数的最大值和最小值.操作 value=del 的 Landline_ExtId 的最大值返回错误

i am trying to get max and min values of LandLine_ExtId base don the attribute action. the max value for Landline_ExtId with action value=del is returned wrong

xml 输入

<Landline_ExtId  action='add'>771534777880</Landline_ExtId>
<Landline_ExtId  action='add'>771534777881</Landline_ExtId>
<Landline_ExtId  action='add'>771534777882</Landline_ExtId>
<Landline_ExtId  action='add'>771534777883</Landline_ExtId>
<Landline_ExtId  action='add'>771534777884</Landline_ExtId>
<Landline_ExtId  action='add'>771534777885</Landline_ExtId>
<Landline_ExtId  action='add'>771534777886</Landline_ExtId>
<Landline_ExtId  action='add'>771534777887</Landline_ExtId>
<Landline_ExtId  action='add'>771534777888</Landline_ExtId>
<Landline_ExtId  action='add'>771534777889</Landline_ExtId>
<Landline_ExtId  action='del'>551534882800</Landline_ExtId>
<Landline_ExtId  action='del'>551534882801</Landline_ExtId>
<Landline_ExtId  action='del'>551534882802</Landline_ExtId>
<Landline_ExtId  action='del'>551534882803</Landline_ExtId>
<Landline_ExtId  action='del'>551534882804</Landline_ExtId>
<Landline_ExtId  action='del'>551534882805</Landline_ExtId>
<Landline_ExtId  action='del'>551534882806</Landline_ExtId>
<Landline_ExtId  action='del'>551534882807</Landline_ExtId>
<Landline_ExtId  action='del'>551534882808</Landline_ExtId>
<Landline_ExtId  action='del'>551534882809</Landline_ExtId>

           <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
    <xsl:element name="getMaxOld">
     <xsl:value-of select="/Data/Landline_ExtId[not(. &lt;      /Data/Landline_ExtId[@action='del'])][1]"/>
      </xsl:element>
     <xsl:element name="getMinOld">
    <xsl:value-of select="/Data/Landline_ExtId[not(. &gt; /Data/Landline_ExtId[@action='del'])][1]"/>
       </xsl:element>
           <xsl:element name="getMaxNew">
         <xsl:value-of select="/Data/Landline_ExtId[not(. &lt; /Data/Landline_ExtId[@action='add'])][1]"/>
       </xsl:element>
       <xsl:element name="getMinNew">
    <xsl:value-of select="/Data/Landline_ExtId[not(. &gt; /Da    ta/Landline_ExtId[@action='add'])][1]"/>
     </xsl:element>
</xsl:template>


    </xsl:stylesheet>

我得到了错误的 GetMaxOld 值.返回 771534777880 而不是 551534882809

i am getting wrong value for GetMaxOld. Instead of 551534882809 , 771534777880 is being returned

推荐答案

您在查找最小值和最大值时缺少谓词 [@action='del'],请参阅下一个:>

You are missing a predicate [@action='del'] in finding your minimum and maximum values, see next:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

    <xsl:template match="/">
        <data>
            <getMaxOld>
                <xsl:value-of select="/Data/Landline_ExtId[@action='del'][not(. &lt; /Data/Landline_ExtId[@action='del'])][1]"/>
            </getMaxOld>
            <getMinOld>
                <xsl:value-of select="/Data/Landline_ExtId[@action='del'][not(. &gt; /Data/Landline_ExtId[@action='del'])][1]"/>
            </getMinOld>
            <getMaxNew>
                <xsl:value-of select="/Data/Landline_ExtId[@action='add'][not(. &lt; /Data/Landline_ExtId[@action='add'])][1]"/>
            </getMaxNew>
            <getMinNew>
                <xsl:value-of select="/Data/Landline_ExtId[@action='add'][not(. &gt; /Data/Landline_ExtId[@action='add'])][1]"/>
            </getMinNew>
        </data>
    </xsl:template>
</xsl:stylesheet>

应用于此 XML 时:

When applied on this XML:

<?xml version="1.0" encoding="UTF-8"?>
<Data>
    <Landline_ExtId action='add'>771534777880</Landline_ExtId>
    <Landline_ExtId action='add'>771534777881</Landline_ExtId>
    <Landline_ExtId action='add'>771534777882</Landline_ExtId>
    <Landline_ExtId action='add'>771534777883</Landline_ExtId>
    <Landline_ExtId action='add'>771534777884</Landline_ExtId>
    <Landline_ExtId action='add'>771534777885</Landline_ExtId>
    <Landline_ExtId action='add'>771534777886</Landline_ExtId>
    <Landline_ExtId action='add'>771534777887</Landline_ExtId>
    <Landline_ExtId action='add'>771534777888</Landline_ExtId>
    <Landline_ExtId action='add'>771534777889</Landline_ExtId>
    <Landline_ExtId action='del'>551534882800</Landline_ExtId>
    <Landline_ExtId action='del'>551534882801</Landline_ExtId>
    <Landline_ExtId action='del'>551534882802</Landline_ExtId>
    <Landline_ExtId action='del'>551534882803</Landline_ExtId>
    <Landline_ExtId action='del'>551534882804</Landline_ExtId>
    <Landline_ExtId action='del'>551534882805</Landline_ExtId>
    <Landline_ExtId action='del'>551534882806</Landline_ExtId>
    <Landline_ExtId action='del'>551534882807</Landline_ExtId>
    <Landline_ExtId action='del'>551534882808</Landline_ExtId>
    <Landline_ExtId action='del'>551534882809</Landline_ExtId>
</Data>

它给你下一个输出:

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <getMaxOld>551534882809</getMaxOld>
    <getMinOld>551534882800</getMinOld>
    <getMaxNew>771534777889</getMaxNew>
    <getMinNew>771534777880</getMinNew>
</data>

这篇关于获取节点不工作的最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆