zoukankan      html  css  js  c++  java
  • Xml 在无限分类中的运用

    一直考虑 关系型数据库 中实现无限分类的高效办法
    尝试过 编码法 但发现限制颇多最终放弃了
    也尝试过一般论坛使用的分类方法 但总觉得维护不是很方便
    至于更高级的分类算法 限于自身数学水平有限 也就不考虑

    而然想到 用 Xml 存储结构 数据库记录数据和结果
    Xml 存储树型结构有着与身具来的优越性 而且这样维护 比较简单, 也不要用递归

    xml 存储结构后 用 Xsl 格式化 直接得到适合数据库用的平行分类数据
    然后直接入库就可以了
    但还是一个小问题 就是分类一多 更新的条目就比较多了
    但也可以通过判断 把更新控制在 1-2 个大类下
    这样相对来说 更新条目会少点

    以下是简单示例 至于 Xsl 卖个关子 保密下

    Xml 分类结构文件

    <?xml version="1.0" encoding="utf-8"?>
    <Categorys>
      
    <Category ID="1" RootID="1">
        
    <Category ID="3" RootID="1">
          
    <Category ID="4" RootID="1">
            
    <Category ID="7" RootID="1" />
          
    </Category>
        
    </Category>
        
    <Category ID="5" RootID="1">
          
    <Category ID="6" RootID="1">
            
    <Category ID="8" RootID="1" />
          
    </Category>
        
    </Category>
      
    </Category>
      
    <Category ID="2" RootID="2" />
    </Categorys>

    Xml 分类运算结果文件
    <Categorys>
        
    <Category ID="1" RootID="1" ParentID="0" Depth="0" ChildCount="6" ParentList="" ChildList="3,5" Sort="1"/>
        
    <Category ID="3" RootID="1" ParentID="1" Depth="1" ChildCount="2" ParentList="1" ChildList="4" Sort="2"/>
        
    <Category ID="4" RootID="1" ParentID="3" Depth="2" ChildCount="1" ParentList="1,3" ChildList="7" Sort="3"/>
        
    <Category ID="7" RootID="1" ParentID="4" Depth="3" ChildCount="0" ParentList="1,3,4" ChildList="" Sort="4"/>
        
    <Category ID="5" RootID="1" ParentID="1" Depth="1" ChildCount="2" ParentList="1" ChildList="6" Sort="5"/>
        
    <Category ID="6" RootID="1" ParentID="5" Depth="2" ChildCount="1" ParentList="1,5" ChildList="8" Sort="6"/>
        
    <Category ID="8" RootID="1" ParentID="6" Depth="3" ChildCount="0" ParentList="1,5,6" ChildList="" Sort="7"/>
        
    <Category ID="2" RootID="2" ParentID="0" Depth="0" ChildCount="0" ParentList="" ChildList="" Sort="8"/>
    </Categorys>
  • 相关阅读:
    Spring Boot教程(三十)使用Spring-data-jpa(1)
    Spring Boot教程(二十九)使用JdbcTemplate操作数据库
    Spring Boot教程(二十八)通过JdbcTemplate编写数据访问
    Spring Boot教程(二十七)整合Spring Security
    Spring Boot教程(二十六)使用Spring Security安全控制
    Spring Boot教程(二十五)返回JSON格式
    gl 绘制多边形的函数解析 分类: OpenGL(转)
    OpenGL超级宝典笔记——画三角形(转)
    OpenGL_Qt学习笔记之_03(平面图形的着色和旋转)(转)
    OpenGL超级宝典笔记——贝塞尔曲线和曲面(转)
  • 原文地址:https://www.cnblogs.com/slightboy/p/404752.html
Copyright © 2011-2022 走看看