新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> DTD, XML Schema(XMLS), RELAX NG
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 DTD/XML Schema 』 → [原创]关于xsd定义函数规则的问题 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 4737 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: [原创]关于xsd定义函数规则的问题 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     zhaoyta 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:4
      积分:79
      门派:XML.ORG.CN
      注册:2007/11/20

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给zhaoyta发送一个短消息 把zhaoyta加入好友 查看zhaoyta的个人资料 搜索zhaoyta在『 DTD/XML Schema 』的所有贴子 引用回复这个贴子 回复这个贴子 查看zhaoyta的博客楼主
    发贴心情 [原创]关于xsd定义函数规则的问题

    各位好,CREATE FUNCTION [dbo].[fn_ScoreDerivedFeatureMiningModel](
      @D varchar(255),
      @VENDOR_LEAD_SOURCE varchar(255),
      @PURCHASE_TIMEFRAME varchar(255),
      @ORIGINAL_REQUESTED_MODEL varchar(255),
      @REQUESTED_MODEL_SEGMENTA2 varchar(255),
      @ORIGINAL_REQUESTED_MAKE varchar(255))
      RETURNS INT
    AS
    BEGIN
      DECLARE @score INT
      IF @D <= '2007-03-01' SET @score = 10000
      ELSE IF @VENDOR_LEAD_SOURCE = 'EPDN'  SET @score = 899
           ELSE IF @PURCHASE_TIMEFRAME = '48 hours to 1 week' SET @score = 879
                ELSE  IF @ORIGINAL_REQUESTED_MODEL = 'camry' SET @score = 674
                      ELSE IF @PURCHASE_TIMEFRAME = 'Week' SET @score = 596
                           ELSE IF @REQUESTED_MODEL_SEGMENTA2 <> ' '
                                  IF @REQUESTED_MODEL_SEGMENTA2 = 'HYBRID' SET @score = 621
                                  ELSE IF @VENDOR_LEAD_SOURCE <> 'GMBP'
                                         IF @ORIGINAL_REQUESTED_MAKE = 'toyota' SET @score = 552
                                         ELSE SET @score = 0   
                                       ELSE SET @score = 0
                                ELSE SET @score = 0
      RETURN @score
    END

    在sql有这么一段规则,返回分数,

    现在要改成用xml实现这段规则

    xsd文件已经定义好

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
     <xs:element name="DecisionTree">
      <xs:annotation>
       <xs:documentation>Decision Tree Model XML Representation</xs:documentation>
      </xs:annotation>
      <xs:complexType>
       <xs:sequence>
        <xs:element name="Node">
         <xs:complexType>
          <xs:sequence>
           <xs:element name="Node" type="NodeType" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="score" type="xs:decimal" use="required" fixed="-1"/>
         </xs:complexType>
        </xs:element>
       </xs:sequence>
       <xs:attribute name="type" type="xs:string" use="required"/>
       <xs:attribute name="target" type="xs:string" use="required"/>
       <xs:attribute name="version" type="xs:string" use="required"/>
      </xs:complexType>
     </xs:element>
     <xs:complexType name="NodeType">
      <xs:sequence>
       <xs:choice>
        <xs:element name="predicate" type="SamplePredicateType"/>
        <xs:element name="compound-predicate" type="CompoundPredicateType"/>
       </xs:choice>
       <xs:element name="Node" type="NodeType" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute name="score" type="xs:decimal" use="required"/>
     </xs:complexType>
     <xs:complexType name="CompoundPredicateType">
      <xs:sequence>
       <xs:element name="predicate" type="SamplePredicateType" minOccurs="2" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute name="op" type="operator" use="required"/>
     </xs:complexType>
     <xs:complexType name="SamplePredicateType">
      <xs:sequence>
       <xs:element name="simple-attribute">
        <xs:complexType>
         <xs:attribute name="name" type="xs:string" use="required"/>
        </xs:complexType>
       </xs:element>
      </xs:sequence>
      <xs:attribute name="op" type="operator" use="required"/>
      <xs:attribute name="value" type="xs:string" use="required"/>
     </xs:complexType>
     <xs:simpleType name="operator">
            <xs:restriction base="xs:string">
            <xs:enumeration value="lt"/>
            <xs:enumeration value="le"/>
            <xs:enumeration value="eq"/>
            <xs:enumeration value="gt"/>
            <xs:enumeration value="ge"/>
            <xs:enumeration value="ne"/>
            <xs:enumeration value="and"/>
            <xs:enumeration value="or"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:schema>

    请达人给点思路  谢谢


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/11/20 14:32:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 DTD/XML Schema 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/4/27 20:42:15

    本主题贴数1,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    7,703.125ms