虎克的博客

Enthusiasm Biogeography-Biodiversity Informatics-Data Sciences

科属种XML文档三级树状图浏览的实现

| Comments

数据库表的结构为三表:科表Family, 属表Genus, 物种表Species

查询生成XML文档的SQL代码:

—两张表链接查询科、属生成XML文件

SELECT Family.FamilyName, Genus.GenusName

FROM Family

JOIN Genus ON Family.FamilyID = Genus.FamilyID

ORDER BY Family.FamilyName, Genus.GenusName

FOR XML AUTO, ROOT(‘Taxon’)

 

 

 

 

—三张表科、属、种关联查询生成XML文件

SELECT  Family.FamilyName,

        Genus.GenusName,

        Species.AbbreviateName

FROM    Family

        INNER JOIN Genus ON Family.FamilyID = Genus.FamilyID

        INNER JOIN Species ON Genus.GenusID = Species.GenusID

        WHERE dbo.Family.FamilyName=‘Apiaceae’

        ORDER BY FamilyName,GenusName,AbbreviateName

FOR     XML AUTO,

            ROOT(‘Taxon’)

所生成的XML文档示例:

?xml version="1.0" encoding="UTF-8"?>

<Taxon>

  <Family FamilyName="Apiaceae">

    <Genus GenusName="Acronema">

      <Species AbbreviateName="Acronema alpinum" />

      <Species AbbreviateName="Acronema astrantiifolium" />

      <Species AbbreviateName="Acronema brevipedicellatum" />

      <Species AbbreviateName="Acronema chienii" />

      <Species AbbreviateName="Acronema chienii var. dissectum" />

      <Species AbbreviateName="Acronema chinense" />

      <Species AbbreviateName="Acronema chinense var. humile" />

      <Species AbbreviateName="Acronema commutatum" />

      <Species AbbreviateName="Acronema edosmioides" />

      <Species AbbreviateName="Acronema forrestii" />

      <Species AbbreviateName="Acronema gracile" />

      <Species AbbreviateName="Acronema graminifolium" />

      <Species AbbreviateName="Acronema handelii" />

      <Species AbbreviateName="Acronema hookeri" />

      <Species AbbreviateName="Acronema hookeri var. graminifolium" />

      <Species AbbreviateName="Acronema minus" />

      <Species AbbreviateName="Acronema muscicola" />

      <Species AbbreviateName="Acronema nervosum" />

      <Species AbbreviateName="Acronema paniculatum" />

      <Species AbbreviateName="Acronema schneideri" />

      <Species AbbreviateName="Acronema sichuanense" />

      <Species 
      
  



      








  



      


  
    linux
  



    

« XML编程学习笔记(一) 发表生物学编程和应用程序的期刊 »

Comments