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

    >> Oracle, SQL Server与XML,XML在数据挖掘中的应用, PMML.
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - 高级XML应用『 XML 与 数据库 』 → 菜鸟求助From Databases to XML [原创][求助] 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 4830 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 菜鸟求助From Databases to XML [原创][求助] 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     cacaca2007 美女呀,离线,快来找我吧!
      
      
      等级:大一新生
      文章:0
      积分:52
      门派:XML.ORG.CN
      注册:2007/3/18

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给cacaca2007发送一个短消息 把cacaca2007加入好友 查看cacaca2007的个人资料 搜索cacaca2007在『 XML 与 数据库 』的所有贴子 引用回复这个贴子 回复这个贴子 查看cacaca2007的博客楼主
    发贴心情 菜鸟求助From Databases to XML [原创][求助]

    各位高手,我是学it管理方面的,从没有用过java,可是老师一开学就要直接做作业,就是现学也来不及了啊,恳请哪位好心的人帮帮忙啊,非常感谢。
    另,有些过分但是还得说啊:要明天交呢,急死我了,555~~~

    From Databases to XML
    XML is becoming more and more the designated format for information exchange. As most of the currently stored information resides in databases, a way to convert it from the relational data model to a XML format is required.
    In this problem we present a transformation rule suitable for a restricted subset of relational databases, namely
    • a database is defined by a set of table headers like R(#A, B, C) where R is the name of the table, and #A, B and C the names of the columns;
    • a column with a name starting by "#" is the key of the corresponding table, which is different in every table line and is thus used to identify the lines;
    • a column B in a table R, other than the key, can either be a simple attribute or a reference to a table S if the name of the column B is mentioned in the key #B of table S, meaning that the table R depends on table S0;
    • there is exactly one table that does not depend on any other;
    • each table contains at most one reference;
    • a table may reference itself;
    • the lines in each table are represented in the same form of the table header, but with the specific values for the line instead of the names of the columns.


    An example is of a database with three tables, R, S and T, and the corresponding XML translation is as follows:
    ------------------- ------------------------
    | S(#C,A,D) | | <DB> |
    | R(#A,B) | | <R #A="a1" B="b1"> |
    | T(E,A) | | <S #C="c2" D="d3"> |
    | data | | </S> |
    | T(e1,a2) | | <S #C="c3" D="d1"> |
    | S(c3,a1,d1) | | </S> |
    | S(c1,a2,d2) | | </R> |
    | S(c2,a1,d3) | | <R #A="a2" B="b2"> |
    | R(a1,b1) | | <S #C="c1" D="d2"> |
    | R(a2,b2) | | </S> |
    ------------------- | <T E="e1"> |
    | </T> |
    | </R> |
    | </DB> |
    ------------------------
    The translation to XML is done according to the following rules:
    • there is a main element called DB;
    • an element called X starts with a tag called <X> and ends with a tag called </X>;
    • each line in a table R(#A, B) is represented by an element called R and the columns which are not references to tables are represented by a pair "column_name=value" inside the opening tag <R #A="a1" B= "b1"> ... </R>;
    • columns that are references are not explicitly represented but only implicitly by including the element of the corresponding line inside the element of the referred line, that is, between the opening and closing tags of the element as shown in the example.
    Problem
    Given a database dump, produce a XML translation for it according to the rules above. In case there are several direct sub-elements for the same element, order them first by the element name itself then by the first argument, second argument, etc.
    In the example above, both T and S include a reference to R, via the column A. The translations of the S and T data-lines are embedded in the translation for the corresponding R line, the S data-lines before the T data-lines.
    Input
    The input will contain several test cases, each of them as described below. Consecutive test cases are separated by a single blank line.
    The input is a sequence of text lines. The first lines contain table headers, in no particular order, followed by a line with the word "data" and then the remainin lines, one for each table data-line. The input is guaranteed to obey the rules mentioned above, namely, there is exactly one table header with no references to other tables and the other tables have at most one reference.
    Output
    For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.
    The output is the corresponding XML translation following the rules defined above. It should have just one tag in each line, left justified. Use single spaces to separate attributes inside tags and no extra spaces, for instance around "=".
    Sample Input
    S(#C,A,D)
    R(#A,B)
    T(E,A)
    data
    T(e1,a2)
    S(c3,a1,d1)
    S(c1,a2,d2)
    S(c2,a1,d3)
    R(a1,b1)
    R(a2,b2)
    Sample Output
    <DB>
    <R #A="a1" B="b1">
    <S #C="c2" D="d3">
    </S>
    <S #C="c3" D="d1">
    </S>
    </R>
    <R #A="a2" B="b2">
    <S #C="c1" D="d2">
    </S>
    <T E="e1">
    </T>
    </R>
    </DB>


    1).Write complete Liskov style for the classes you work out.
    2). Finish coding.
    3). Write some test cases for the problem.


       收藏   分享  
    顶(0)
      




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

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

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