可扩展标记语言文件检索方法

文档序号:4482572阅读:112来源:国知局
专利名称:可扩展标记语言文件检索方法
技术领域
本发明涉及可扩展标记语言领域,尤指一种可扩展标记语言文件导出方法。
背景技术
随着Internet的迅猛发展,xml(Extensible Markup Language,可扩展标记语言)作为Internet上数据表示的新标准,以其具有的自描述性、灵活性、扩展性和平台无关性等优势,正在被广泛的应用于各种Web应用中。
近年来许多研究工作致力于将数据库技术应用于xml文件的处理上。利用数据库成熟的技术来存储xml文件。目前主流的xml数据库形式是利用关系数据库来存储xml文件,例如Oracle9i、SQL Server 2000等关系数据库。
利用关系数据库存储xml文件后,如何能够高效地将xml文件的元素检索出来一直受到业界的强烈关注。

发明内容
本发明要解决的问题是提供一种能够高效检索可扩展标记语言文件元素的可扩展标记语言文件检索方法。
为了解决上述问题,本发明可扩展标记语言文件检索方法,用于对存储在关系数据库表中的可扩展标记语言文件进行检索,关系数据库系统表中存放系统信息,关系数据库表中存放可扩展标记语言文件元素,关系数据库系统表之模式表中存放名称空间与其对应的映射文件,包括下述步骤1)通过待检索元素的全局名字以获取该元素的名称空间,所述全局名字中有一部分用于表示名称空间;2)通过名称空间以获取可扩展标记语言文件的映射文件;3)通过映射文件找到待检索元素及其子元素的类型,从而获取与其相应的所有关系数据库表;4)通过关系数据库表中取得待检索元素。
所述步骤4)又进一步细分为下述步骤40)从关系数据库表中选出所有符合条件的记录,并根据映射文件构造可扩展标记语言元素节点;41)将符合条件的多个元素汇集成一个结果集返回。
与现有技术相比,本发明可扩展标记语言文件检索方法的有益效果是由于根据待检索元素的全局名字以获得名称空间,根据名称空间获得该名称空间的映射文件,根据映射文件可找到与待检索元素相关的数据库表,即可检索出待检索元素,而不必考虑多表连接等问题,从而可实现对xml文件元素的高效查询。


图1是本发明可扩展标记语言文件检索方法流程图;图2是图1中步骤1)进一步划分的流程图;图3是实施例中四个模式的依赖关系示意图。
具体实施例方式
在介绍本发明可扩展标记语言文件检索方法的技术方案之前,先将xml文件存入关系数据库表中,然后再采用本发明可扩展标记语言文件检索方法对存入关系数据库表中的xml文件的元素进行检索。
本例的xml文件有四个模式。
模式一company.xsd<?xml version=″1.0″encoding=″UTF-8″?><xsschema targetNamespace=″http://org.xmldb.company″xmlnsxs=″http://www.w3.org/2001/XMLSchema″xmlns=″http://org.xmldb.company″xmlnsper=″http://org.xmldb.personnel″elementFormDefault=″qualified″attributeFormDefault=″unqualified″>;依赖模式personal.xsd<xsimport namespace=″http://org.xmldb.personnel″schemaLocation=″personal.xsd″/>
<xselement name=″company″>
<xsannotation>
<xsdocumentation>Comment describing your root element</xsdocumentation>
</xsannotation>
<xscomplexType>
<xssequence>
<xselement name=″employee″type=″employee″/>
<xselement name=″department″>
<xscomplexType>
<xssequence>
<xselement name=″manager″>
<xscomplexType>
<xssequence>
<xselement name=″rank″type=″xsstring″/>
<xselement ref=″perperson″/>
</xssequence>
</xscomplexType>
</xselement>
<xselement name=″name″type=″xsstring″/>
</xssequence>
</xscomplexType>
</xselement>
</xssequence>
</xscomplexType></xselement><xscomplexType name=″employee″>
<xssequence>
<xselement ref=″perperson″maxOccurs=″unbounded″/>
</xssequence></xscomplexType></xsschema>
模式二government.xsd<?xml version=″1.0″encoding=″UTF-8″?><xsschema targetNamespace=″http://org.xmldb.government″xmlnsxs=″http://www.w3.org/2001/XMLSchema″xmlnsper=″http://org.xmldb.personnel″xmlns=″http://org.xmldb.govemment″elementFormDefault=″qualified″attributeFormDefault=″unqualified″>;依赖模式personal.xsd<xsimport namespace=″http://org.xmldb.personnel″schemaLocation=″personal.xsd″/><xselement name=″govemment″>
<xsannotation>
<xsdocumentation>Comment describing your root element</xsdocumentation>
</xsannotation>
<xscomplexType>
<xssequence>
<xselement name=″officers″>
<xscomplexType>
<xssequence>
<xselement ref=″perperson″maxOccurs=″unbounded″/>
</xssequence>
</xscomplexType>
</xselement>
<xselement name=″name″type=″xsstring″/>
<xselement name=″affiliated″type=″xsstring″/>
</xssequence>
</xscomplexType>
</xselement></xsschema>
模式三personal.xsd<?xml version=″1.0″encoding=″UTF-8″?><xsschema targetNamespace=″http://org.xmldb.personnel″xmlnsxs=″http://www.w3.org/2001/XMLSchema″xmlns=″http://org.xmldb.personnel″xmlnsaddr=″http://org.xmldb.address″elementFormDefault=″qualified″>;依赖模式address.xsd<xsimport namespace=″http://org.xmldb.address″schemaLocation=″address.xs″/>;模式定义的全局元素<xselement name=″personnel″>;模式定义的复杂类型<xscomplexType>
<xssequence>
<xselement ref=″person″maxOccurs=″unbounded″/>
</xssequence>
</xscomplexType>
<xsunique name=″uniquel″>
<xsselector xpath=″person″/>
<xsfield xpath=″name/given″/>
<xsfield xpath=″name/family″/>
</xsunique>
<xskey name=″empid″>
<xsselector xpath=″person″/>
<xsfield xpath=″@id″/>
</xskey>
<xskeyref name=″keyrefl″refer=″empid″>
<xsselector xpath=″person″/>
<xsfield xpath=″link/@manager″/>
</xskeyref></xselement>;模式定义的全局元素<xselement name=″person″>;模式定义的复杂类型<xscomplexType>
<xssequence>
<xselement ref=″name″/>;Schema定义的重复多次的简单类型元素<xselement ref=″email″minOccurs=″0″maxOccurs=″unbounded″/>
<xselement ref=″url″minOccurs=″0″maxOccurs=″unbounded″/>
<xselement name=″addresses″>;模式定义的复杂类型<xscomplexType>
<xssequence maxOccurs=″unbounded″>
<xselement ref=″addraddress″/>
</xssequence>
</xscomplexType>
</xselement>
</xssequence>
<xsattribute name=″id″type=″xsID″use=″required″/>
<xsattribute name=″note″type=″xsstring″/>
<xsattribute name=″contr″default=″false″>
<xssimpleType>
<xsrestriction base=″xsstring″>
<xsenumeration value=″true″/>
<xsenumeration value=″false″/>
</xsrestriction>
</xssimpleType>
</xsattribute>
<xsattribute name=″salary″type=″xsinteger″/>
</xscomplexType></xselement>;模式定义的全局元素<xselement name=″name″>;模式定义的复杂类型<xscomplexType>
<xsall>
<xselement ref=″family″/>
<xselementref=″given″/>
</xsall>
</xscomplexType></xselement>;模式定义的全局元素<xsclement name=″family″type=″xsstring″/>;模式定义的全局元素<xselement name=″given″type=″xsstring″/>;模式定义的全局元素<xselement name=″email″type=″xsstring″/>;模式定义的全局元素<xselement name=″url″>;模式定义的复杂类型<xscomplexType>
<xsattribute name=″href″type=″xsstring″default=″http://″/>
</xscomplexType></xselement></xsschema>
模式四address.xsd<?xml version=″1.0″encoding=″UTF-8″?><xsschema targetNamespace=″http://org.xmldb.address″xmlnsxs=″http://www.w3.org/2001/XMLSchema″xmlns=″http://org.xmldb.address″elementFormDefault=″qualified″attributeFormDefault=″unqualified″>;Schema所定义的全局元素address<xselement name=″address″>
<xsannotation>
<xsdocumentation>Comment descrlbing your root element</xsdocumentation>
</xsannotation>;Schema所定义的局部复杂类型<xscomplexType>
<xssequence>;Schema所定义的复杂类型中定义的局部元素<xselement name=″tel″type=″xsstring″/>
<xselement name=″postcode″type=″xsstring″/>
<xselement name=″street″type=″xsstring″/>
</xssequence>
</xscomplexType>
</xselement></xsschema>
首先,建立数据库系统表文档实例表(docInstance)、文档集合表(collection)、复杂类型表(complexType)、模式表(schema)、模式引用关系表(schemacrossref)和全局元素表(docRoot)。
Schemacrossref,用于存放可扩展标记语言文件模式间的依赖关系,包括字段名称空间(namespace)和名称空间引用(refednamespace);Schema,用于存放可扩展标记语言文件模式与其对应的映射文件的对应关系,包括字段名称空间(namespace)、名字(name)、模式内容(text)和映射文件名(mapping);DocInstance,用于存放可扩展标记语言文件存储标识,包括字段文档实例标识(id)、名字(name)、文档集合表外键(collectionId(FK))和文档原始内容(text);complexType,用于记录数据库导入的模式所生成的数据库表(id为生成的表名),包括字段复杂类型标识(id)、名字(name)、名称空间表外键(namespace(FK))和类型(type);docRoot,用于保存数据库导入的模式所定义的全局元素,包括字段全局元素标识(id)、名字(name)和名称空间(namespace(FK));Collection,用于存放一类xml文件的集合,包括字段文件标识(id)、名字(name)和全局元素表外键(docrootid(FK))。
然后,使用通用的解析器将schema作为普通的xml文件进行解析,分析其中的xsimport元素,将xml schema间的依赖(import)关系存入数据库系统表Schemacrossref中。在导入某个具体的模式时,由于其可能依赖其它的模式,如果这些依赖的模式没有导入到schemacrossref中,则将其一并导入。
如图3所示,上述四个模式的依赖关系为company.xsd和government.xsd均依赖personal.xsd,personal.xsd依赖address.xsd。
导入government.xsd后表Schemacrossref的存储结果为

然后导入company.xsd后表Schemacrossref的存储结果为


下面本例采用schema解析器,例如apach xerces,获取符合w3c规范的schema对象模型,再根据schema对象模型获取其所引用的名称空间,本例中company.xsd所获得的schema对象所引用的名称空间有三个,分别是http://org.xmldb.companyhttp://org.xmldb.personnelhttp://org.xmldb.address再为每一个名称空间创建一个映射文件,分别是mapping-company.xml、mapping-personal.xml和mapping-address.xml。本例将模式与映射文件的对应关系存放在数据库系统表schema中,存储后表schema结果为

下面描述模式三personal.xsd生成映射文件mapping-personal.xml的过程。
在该过程之前先采用下述方法对personal.xsd中的类型和元素进行命名将全局元素命名为“{element}{+目标名称空间+}+元素的名称属性值”;将全局复杂类型命名为“{type}{+目标名称空间+}+复杂类型的名称属性值”;将局部元素命名为“包含该局部元素的复杂类型的全局名字+“/”+该局部元素的名称属性值”;将局部复杂类型命名为该局部复杂类型的父元素的全局名字;将简单类型命名为其基础类型的全局名字。
故该模式定义的所有全局元素及其全局名字如下personnel{element}{http://org.xmldb.personnel}personelperson{element}{http://org.xmldb.personnel}personname{element}{http://org.xmldb.personnel}namefamily{element}{http://org.xmldb.personnel}familygiven{element}{http://org.xmldb.personnel}givenemail{element}{http://org.xmldb.personnel}emailurl{element}{http://org.xmldb.personnel}url五个复杂类型的全局名字为{element}{http://org.xmldb.personnel}personel{element}{http://org.xmldb.personnel}person{element}{http://org.xmldb.personnel}name
{element}{http://org.xmldb.personnel}url{element}{http://org.xmldb.personnel}person/addresses局部简单类型的全局名字为{type}{http://www.w3.org/2001/XMLSchema}String该模式的元素和类型有了全局名字后,即能够区分不同的类型和元素,映射文件mapping-personal.xml的过程如下获取personal.xsd中的全部全局元素和复杂类型。
所获得的全局元素为personnel,person,name,family,given,email,url所获得的复杂类型为{element}{http://org.xmldb.personnel}personnel{element}{http://org.xmldb.personnel}person{element}{http://org.xmldb.personnel}name{element}{http://org.xmldb.personnel}url{element}{http://org.xmldb.personnel}person/addresses然后对每一个全局元素生成一个XmlMappingElement节点并设置其相应的属性。再生成XmlMappingElements节点,该节点包含所有生成的XmlMappingElement节点。本例为;xml元素集合节点<XmlMappingElements>;全局元素person<XmlMappingElementname=″{element}{http://org.xmldb.personnel}person″localName=″person″elementType=″complex″type=″{element}{http://org.xmldb.personnel}person″id=″F8522164_DC8A_498E_888E_D7ACF6291D39″/>;全局元素personnel<XmlMappingElementname=″{element}{http://org.xmldb.personnel}personnel″localName=″personnel″elementType=″complex″type=″{element}{http://org.xmldb.personnel}personnel″id=″DB1D8AEA_A320_4203_BC3F_B2FE7D4AE326″/>;全局元素url<XmlMappingElementname=″{element}{http://org.xmldb.personnel}url″localName=″url″elementType=″complex″type=″{element}{http://org.xmldb.personnel}url″id=″2E1E9830_AB88_4DC8_8B72_A3DE735CA329″/>;全局元素family<XmlMappingElementname=″{element}{http://org.xmldb.personnel}family″localName=″family″elementType=″simple″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″3DC9DBB9_9E7E_4CF4_BDA8_A0AF486E5364″/>;全局元素name<XmlMappingElementname=″{element}{http://org.xmldb.personnel}name″localName=″name″elementType=″complex″type=″{element}{http://org.xmldb.personnel}name″id=″5F8ECF2E_82E5_48E7_BD5D_C21FAC8CC297″/>;全局元素given<XmlMappingElementname=″{element}{http://org.xmldb.personnel}given″localName=″given″elementType=″simple″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″11B6ACF7_CC08_415C_8650_FB5730BE0137″/>;全局元素email<XmlMappingElementname=″{element}{http://org.xmldb.personnel}email″localName=″email″elementType=″simple″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″CAAAF143_2956_454D_8AF3_8E59F56BBA4E″/>
</XmlMappingElements>
最后将每一个复杂类型生成XmlMappingType节点并设置相应属性,还要找出每一个复杂类型所包含的所有子元素(包括属性)。对每一个子元素生成XmlMappingElement节点,并将其放入其所属的复杂类型的XmlMappingType节点中。再生成XmlMappingTypes节点,该节点包含所有生成的XmlMappingType节点。
Personal.xsd生成的映射文件中XmlMappingTypes和XmlMappingType为;xml类型集合节点<XmlMappingTypes>;复杂类型{element}{http://org.xmldb.personnel}personnel<xmlMappingType id=″94737D4C_F969_48FF_A4A1_823FA8647BAD″name=″{element}{http://org.xmldb.personnel}personnel″namespace=″http://org.xmldb.personnel″>;子元素person<XmlMappingElementname=″{element}{http://org.xmldb.personnel}person″localName=″person″elementType=″complex″type=″{element}{http://org.xmldb.personnel}person″id=″F8522164_DC8A_498E_888E_D7ACF6291D39″/>
</XmlMappingType>;复杂类型{element}{http://org.xmldb.personnel}person<XmlMappingType id=″D62E1F94_35CA_4362_BB4E_DC39C58EACA3″name=″{element}{http://org.xmldb.personnel}person″namespace=″http://org.xmldb.personnel″>;子元素id<XmlMappingElement name=″id″localName=″id″elementType=″attribute″
type=″{type}{http://www.w3.org/2001/XMLSchema}ID″id=″81195F3E_ED21_44C6_A0D5_F4F0E44BC159″/>;子元素note<XmlMappingElement name=″note″localName=″note″elementType=″attribute″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″7AA4C149_DB7A_4F75_91DF_B01EF4B5B40D″/>;子元素contr<XmlMappingElement name=″contr″localName=″contr″elementType=″attribute″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″11C9845E_B1BF_4BFC_A1D0_CD6D89F50F41″/>;子元素salary<XmlMappingElement name=″salary″localName=″salary″elementType=″attribute″type=″{type}{http://www.w3.org/2001/XMLSchema}integer″id=″34009506_9DC1_4468_A654_E66BFFE49FCD″/>;子元素name<XmlMappingElementname=″{element}{http://org.xmldb.personnel}name″localName=″name″elementType=″complex″type=″{element}{http://org.xmldb.personel}name″id=″5F8ECF2E_82E5_48E7_BD5D_C21FAC8CC297″/>;子元素email<XmlMappingElementname=″{element}{http://org.xmldb.personnel}email″localName=″email″elementType=″simple″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″CAAAF143_2956_454D_8AF3_8E59F56BBA4E″minOccurs=″0″maxOccurs=″100000″/>;子元素url<XmlMappingElementname=″{element}{http://org.xmldb.personnel}url″localName=″url″elementType=″complex″type=″{element}{http://org.xmldb.personnel}url″id=″2E1E9830_AB88_4DC8_8B72_A3DE735CA329″/>;子元素addresses<XmlMappingElementname=″{element}{http://org.xmldb.personnel}person/addresses″localName=″addresses″elementType=″complex″type=″{element}{http://org.xmldb.personnel}person/addresses″id=″1D2AA93A_0DEF_4924_A88F_C433515B20F6″/>
</XmlMappingType>;复杂类型{element}{http://org.xmldb.personnel}name<XmlMappingType id=″45E5901B_C36F_4F9E_8888_ADB29B816770″name=″{element}{http://org.xmldb.personnel}name″namespace=″http://org.xmldb.personnel″>;子元素family<XmlMappingElementnams=″{element}{http://org.xmldb.personnel}family″localName=″family″elementType=″simple″type=″{type}{http://www.w3.org/2001/XMLSchsma}string″id=″3DC9DBB9_9E7E_4CF4_BDA8_A0AF486E5364″minOccurs=″1″maxOccurs=″1″/>;子元素given<XmlMappingElementname=″{element}{http://org.xmldb.personnel}given″localName=″given″elementType=″simple″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″11B6ACF7_CC08_415C_8650_FB5730BE0137″minOccurs=″1″maxOccurs=″1″/>
</XmlMappingType>;复杂类型{element}{http://org.xmldb.personnel}url<XmlMappingType id=″22F2B421_815E_4E95_9D49_C67FA72D5265″name=″{element}{http://org.xmldb.personnel}url″namespace=″http://org.xmldb.personnel″>;子元素href<XmlMappingElement name=″href″localName=″href″elementType=″attribute″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″5ACA5FFB_8E8A_4E9A_A17F_86FFCD1EE1E</XmlMappingType>;复杂类型{element}{http://org.xmldb.personnel}person/addresses<XmlMappingType id=″3E043791_8941_471A_A95D_A3DC796BBD5C″name=″{element}{http://org.xmldb.personnel}person/addresses″namespace=″http://org.xmldb.personnel″>;子元素address<XmlMappingElementname=″{element}{http://org.xmldb.address}address″localName=″address″elementType=″complex″type=″{element}{http://org.xmldb.address}address″id=″35CEl14E_D191_4534_A321_9BA88F9CB0BF″/>
</XmlMappingType>
</XmlMappingTypes>
同理,address.xsd生成的映射文件mapping-address.xml为<XmlMapping>
<XmlMappingTypes>
<XmlMappingType id=″35CE114E_D191_4534_A321_9BA88F9CB0BF″name=″{element}{http://org.xmldb.address}address″namespace=″http://org.xmldb.address″>
<XmlMappingElement name=″{element}{http://org.xmldb.address}address/tel″localName=″tel″elementType=″simple″type=″{type}{http://www.w3.org/2001/XMLSchema}string″
id=″212928B8_D160_4134_B8F3_C506103FFB82″minOccurs=″1″maxOccurs=″1″/>
<XmlMappingElement name=″{elemsnt}{http://org.xmldb.address}address/postcode″localName=″postcode″elementType=″simple″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″46BFC031_7FA7_48ED_A73E_E82184BB67B5″minOccurs=″1″maxOccurs=″1″/>
<xmlMappingElement name=″{element}{http://org.xmldb.address}address/street″localName=″street″elementType=″simple″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″AD2EEE92_A353_4127_AEC1_84B5851F1E98″minOccurs=″1″maxOccurs=″1″/>
</XmlMappingType>
</XmlMappingTypes>
<XmlMappingElements>
<XmlMappingElement name=″{element}{http://org.xmldb.address}address″localName=″address″elementType=″complex″type=″{element}{http://org.xmldb.address}address″id=″0430D375_32FE_4072_B254_C71C664456B3″/>
</XmlMappingElements></XmlMapping>
下面根据映射文件mapping-personal.xml生成关系数据库表。
首先对于mapping-personal.xml中的每一个XmlMappingType生成一张表,为了使表名唯一,本例采用XmlMappingType中的id作为该表的表名;其次将XmlMappingType所包含的所有属性和出现小于等于一次的简单类型元素作为该表的字段;再者对于出现不止一次的简单类型元素生成一张子表,其表名为XmlMappingElement的id;最后,对所有生成的表都建立公共字段uuid_id,uuid_name,uuid_docid,uuid_parented,uuid_order。
注对于一个复杂类型元素只生成一张表,不管该复杂类型是由哪个xmlschema所引用。这样使生成的表不依赖于引用复杂类型的xml schema,而只依赖于定义该复杂类型元素的xml schema。因而使所有相同类型的元素都会存储在一起。
对于mapping-personal.xml中有五个XmlMappingType元素,同时简单类型元素{element}{http://org.xmldb.personnel}email的最大出现次数大于1,故应生成六张表,将生成表的情况存放在数据库系统表complextype中为


其中每张表都包含如下公共字段(其中AB8E7A48_544A_48E3_8E4C_81268F986E10为本例指定的UUID)

对于每张表除了包含上述公共字段外,还包含了schema定义的所属类型的所有属性和简单类型元素的字段。
表94737D4C_F969_48FF_A4A1_823FA8647BAD({element}{http://org.xmldb.personnel}personnel)包含的字段为

表D62E1F94_35CA_4362_BB4E_DC39C58EACA3({element}{http://org.xmldb.personnel}person)包含的字段为

表CAAAF143_2956_454D_8AF3_8E59F56BBA4E({element}{http://org.xmldb.personnel}person/email)包含的字段为

法快速诊断盒检测孔中,5min后开始观察结果,20min观察终止。结果报告出现1条红色(质控)沉淀线,为鼠疫耶尔森氏菌血清学诊断阴性,即无鼠疫耶尔森氏菌感染;出现2条红色(质控和对照)沉淀线,为鼠疫耶尔森氏菌血清学诊断阳性,即有鼠疫耶尔森氏菌感染。
2.2、鼠疫间接血凝法测定药盒检测临床血清标本为常量法血凝试验,按试剂盒说明书操作。
取血凝用小试管或反应板,按序加入稀释剂,第1管0.9ml,第2管以下各加0.5ml至最终管。将被检血清经56℃ 30min灭活后,取0.1ml加入第1管(1∶10稀释)混匀后,取0.5ml移入第2管,以下依次类推,做2倍连续稀释至终管,终管弃去0.5ml。每管分别加入2.5%F1抗原致敏血球悬液1滴(约0.05ml)。同时设阴性对照稀释的被检血清0.5ml加2.5%阴性血球1滴;阳性对照稀释的阳性参考血清加入2.5%F1抗原致敏血球悬液1滴;空白对照稀释剂0.5ml加2.5%F1抗原致敏血球悬液1滴。
将上述各管充分摇匀后,置于37℃或室温中3-4h,待血球沉淀后,观察结果(++++)凝集紧密,凝集物布满管底,有卷边现象或抗体过多则凝集疏散花团状;(+++)凝集较紧密,凝集物布满管底呈伞状,无卷边;(++)血球不完全凝集,管底呈整齐的圆圈,圈内外有明显血球凝集;(+)血球沉积管底呈纽扣状,周围有极少量凝集血球;(-)血球无凝集沉积管底,呈整齐的圆圈或圆点状。
2.3、结果与讨论鼠疫胶体金法快速诊断免疫层析试纸与间接血凝法实验室比较结果如下

灵敏度=[A/(A+C)]×100%=[294/(294+6)]×100%=98%特异性=[D/(B+D)]×100%=[300/(0+300)]×100%=100%
下面以实例personal.xml为例来描述将元素值存入关系数据库表的过程。
实例Personal.xml为<?xml version=″1.0″encoding=″UTF-8″?>;名称空间为http://org.xmldb.personnel<personnel xmlns=http://org.xmldb.personnel xmlnsxsi=″http://www.w3.org/2001/XMLSchema-instance″xsischemaLocation=″http://org.xmldb.personnel personal.xsd″xmlnsaddr=″http://org.xmldb.address″><person id=″idl″salary=″500″>
<name>
<family>张</family>
<given>三</given>
</name>
<email>a@a.com</email>
<addresses>
<addraddress>
<addrtel>1234567</addrtel>
<addrpostcode>100005</addrpostcode>
<addrstreet>科学院</addrstreet>
</addraddress>
</addresses></person><person id=″id2″salary=″500″>
<name>
<family>李</family>
<given>四</given>
</name>
<email>b@b.com</email>
<email>c@c.com</email>
<addresses>
<addraddress>
<addrtel>789898</addrtel>
<addrpostcode>100006</addrpostcode>
<addrstreet>北京大学</addrstreet>
</addraddress>
</addresses></person></personnel>
首先,解析可扩展标记语言文件以获得文档对象模型(dom树);其次,递归处理dom树的各层节点及节点的属性,并对每一个节点重复下述过程利用mapping文件找到该节点的“elementType”和“type”,若elementType为简单类型(simple)且出现次数小于等于一,将该节点值插入父节点表中的对应字段,若elementType为简单类型(simple)且出现次数不止一次,将节点值插入该节点对应的表中;若elementType为复杂类型(complex),将节点值插入该节点的复杂类型元素所对应的表中,同时分析节点的属性,将所有属性值插入表中对应字段。
将符合personal.xsd定义的xml实例文档personal.xml存储在关系数据库表中的结果为(为方便起见,在本文中将公共字段的“AB8E7A48_544A_48E3_8E4C_81268F986E10”省略,只保留“_”,同时由于所有此文档相关记录的字段“AB8E7A48_544A_48E3_8E4C_81268F986E10_INSTANCEID”值相同,这里不予列出)
表94737D4C_F969_48FF_A4A1_823FA8647BAD({element}{http://org.xmidb.personnel}personnel)存储结果为

表D62E1F94_35CA_4362_BB4E_DC39C58EACA3({element}{http://org.xmldb.personnel}person)存储结果为

表CAAAF143_2956_454D_8AF3_8E59F56BBA4E({element}{http://org.xmldb.personnel}person/email)存储结果为

表45E5901B_C36F_4F9E_8888_ADB29B816770({element}{http://org.xmldb.personnel}name)存储结果为

表22F2B421_815E_4E95_9D49_C67FA72D5265({element}{http://org.xmldb.personnel}url)的记录为空。
表3E043791_8941_471A_A95D_A3DC796BBD5C({element}{http://org.xmldb.personnel}person/addresses)的存储结果为

由于“personal.xsd”中引入了schema“address.xsd”,所以“personal.xml”文档中元素“addraddress”的信息会插入导入“address.xsd”时所创建的“{element}{http://org.xmldb.address}address”表35CE114E_D191_4534_A321_9BA88F9CB0BF中,其结果如下

下面以查询模式“address.xsd”定义的xml元素address为例来详述本发明可扩展标记语言文件检索方法的技术方案。
如图1所示,可扩展标记语言文件检索方法,用于对存储在关系数据库表中的可扩展标记语言文件进行检索,关系数据库系统表中存放系统信息,关系数据库表中存放可扩展标记语言文件元素,关系数据库系统表之模式表中存放名称空间与其对应的映射文件,包括下述步骤1)通过待检索元素的全局名字以获取该元素的名称空间(namespace),所述全局名字中有一部分用于表示名称空间,也即全局名字的第二个{}中的内容;2)通过名称空间以获取可扩展标记语言文件的映射文件,即通过模式表(schema)即可得到映射文件;3)通过映射文件找到待检索元素及其子元素的类型(type),从而获取与其相应的所有关系数据库表;4)通过关系数据库表中取得待检索元素。
如图2所示,所述步骤4)又进一步细分为下述步骤40)从关系数据库表中选出所有符合条件的记录,并根据映射文件构造可扩展标记语言元素节点;41)将符合条件的多个元素汇集成一个结果集返回。
首先,由于全局元素address的全局名字为{element}{http://org.xmldb.address}address读取该全局名字的第二个{}中的内容获得元素address的名称空间为http://org.xmldb.address根据此名称空间查询关系数据库系统表“schema”中的记录,找出该namespace的映射文件mapping-address.xml。<XmlMapping>
<XmlMappingTypes>
<XmlMappingType id=″35CE114E_D191_4534_A321_9BA88F9CB0BF″name=″{element}{http://org.xmldb.address}address″namespace=″http://org.xmldb.address″>
<XmlMappingElement name=″{element}{http://org.xmldb.address}address/tel″localName=″tel″elementType=″simple″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″212928B8_D160_4134_B8F3_C506103FFB82″minOccurs=″1″maxOccurs=″1″/>
<XmlMappingElement name=″{element}{http://org.xmldb.address}address/postcode″localName=″postcode″elementType=″simple″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″46BFC031_7FA7_48ED_A73E_E82184BB67B5″minOccurs=″1″maxOccurs=″1″/>
<XmlMappingElement name=″{element}{http://org.xmldb.address}address/street″localName=″street″elementType=″simple″type=″{type}{http://www.w3.org/2001/XMLSchema}string″id=″AD2EEE92_A353_4127_AEC1_84B5851F1E98″
minOccurs=″1″maxOccurs=″1″/>
</XmlMappingType>
</XmlMappingTypes>;全局名字为{element}{http://org.xmldb.address}address的节点<XmlMappingElements>
<XmlMappingElement name=″{element}{http://org.xmldb.address}address″localName=″address″elementType=″complex″type=″{element}{http://org.xmldb.address}address″id=″0430D375_32FE_4072_B254_C71C664456B3″/>
</XmlMappingElements></XmlMapping>
首先,在该映射文件中查找全局名字为{element}{http://org.xmldb.address}address的XmlMappingElement节点,读取XmlMappingElement节点的type属性值为{element}{http://org.xmldb.address}address;其次,根据type属性值找到mapping中相应的XmlMappingType节点,即为该address元素的类型,读取XmlMappingType节点的id属性值为35CE114E_D191_4534_A321_9BA88F9CB0BF,此属性值为存储XML元素address的数据库表名;然后,读取数据库表35CE114E_D191_4534_A321_9BA88F9CB0BF的记录如下

根据该映射文件的XmlMappingType节点信息,可知address节点包含3个子节点tel、postcode、street,分别对应数据库表中的三个字段,读取相应字段值使用DOM解析器构造address的子节点,例如表中第一条记录构造的结果为<ns1tel>1234567</ns1tel>
<ns1postcode>100005</ns1postcode>
<ns1street>科学院</ns1street>
然后再构造address元素节点,表中第一条记录构造的结果为<ns1address>
<ns1tel>1234567</ns1tel>
<ns1postcode>100005</ns1postcode>
<ns1street>科学院</ns1street>
</ns1address>
最后将符合条件(如果要查询postcode大于100007的address,表中的两条记录都符合查询要求)的记录所生成的所有address元素节点放入DOM解析器构造的父元素节点<resultset></resultset>中,并将DOM树序列化成字符串,将查询结果作为一个大的结果集返回,结果如下<resultset xmlnsns1=″http://org.xmldb.address″>
<ns1address>
<ns1tel>1234567</ns1tel>
<ns1postcode>100005</ns1postcode>
<ns1street>科学院</ns1street>
</ns1address>
<ns1address>
<ns1tel>789898</ns1tel>
<ns1postcode>100006</ns1postcode>
<ns1street>北京大学</ns1street>
</ns1address></resultset>
以上所述仅是本发明可扩展标记语言文件检索方法的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明可扩展标记语言文件检索方法原理的前提下,还可以作出若干改进和润饰,这些改进和润饰也应视为本发明可扩展标记语言文件检索方法的保护范围。
权利要求
1.一种可扩展标记语言文件检索方法,用于对存储在关系数据库表中的可扩展标记语言文件进行检索,关系数据库系统表中存放系统信息,关系数据库表中存放可扩展标记语言文件元素,关系数据库系统表之模式表中存放名称空间与其对应的映射文件,其特征在于,包括下述步骤1)通过待检索元素的全局名字以获取该元素的名称空间,所述全局名字中有一部分用于表示名称空间;2)通过名称空间以获取可扩展标记语言文件的映射文件;3)通过映射文件找到待检索元素及其子元素的类型,从而获取与其相应的所有关系数据库表;4)通过关系数据库表中取得待检索元素。
2.如权利要求1所述的可扩展标记语言文件检索方法,其特征在于,所述步骤4)又进一步细分为下述步骤40)从关系数据库表中选出所有符合条件的记录,并根据映射文件构造可扩展标记语言元素节点;41)将符合条件的多个元素汇集成一个结果集返回。
全文摘要
本发明公开了一种可扩展标记语言文件检索方法,包括步骤通过待检索元素的全局名字以获取该元素的名称空间;通过名称空间以获取可扩展标记语言文件的映射文件;通过映射文件找到待检索元素及其子元素的类型,从而获取与其相应的所有数据库表。采用本发明可扩展标记语言文件检索方法能够实现对存储在关系数据库表中的可扩展标记语言文件元素高效检索。
文档编号G06F17/30GK1632797SQ20041010275
公开日2005年6月29日 申请日期2004年12月27日 优先权日2004年12月27日
发明者李安渝, 严兵, 傅朝霞, 秦良娟, 丁蔚, 耿建光, 秦怀平, 董胜涛 申请人:中国科学院软件研究所, 神州数码软件有限公司
网友询问留言 已有0条留言
  • 还没有人留言评论。精彩留言会获得点赞!
1