【发布时间】:2017-09-07 20:22:24
【问题描述】:
我的理解力很差,所以真的需要一个地方开始寻找信息。
我有 4 个 SQL 数据表。我想将它们全部输出到一个 XML 文件中。
我有一个 XML Schema 可以使用,但不知道如何使用它或应该在哪里使用它。
长期目标是拥有 30 个交接表,我们可以针对这些表运行验证脚本,然后使用给定的 XML 方案生成 1 个用于提交的 XML 文件。
我是这里的新手,边走边学,如果有任何建议可以在哪里寻找,我们将不胜感激。
示例 XML 数据
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSpy v2013 rel. 2 sp2 (http://www.altova.com)-->
-<MSDS:MSDS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:MSDS="http://www.datadictionary.nhs.uk/messages/MSDS-v1-0" xsi:schemaLocation="http://www.datadictionary.nhs.uk/messages/MSDS-v1-0 ../Schemas/MSDSMSDS_XMLSchema-v1-0.xsd">
-<MATHDRHeader>
<Version>1.0</Version>
<OrgCodeProv>5BC</OrgCodeProv>
<OrgCodeSubmitter>YEA</OrgCodeSubmitter>
<RPStartDate>2013-01-01</RPStartDate>
<RPEndDate>2013-03-12</RPEndDate>
<FileCreationDateTime>2013-03-13T13:00:27</FileCreationDateTime>
<RecordCount>1</RecordCount>
-<MAT001MothersDemographics>
<LocalPatientIdMother>112552254</LocalPatientIdMother>
<OrgCodeLocalPatientIdMother>5BC</OrgCodeLocalPatientIdMother>
<OrgCodeRes>5BC</OrgCodeRes>
<NHSNumberMother>1111111111</NHSNumberMother>
<NHSNumberStatusMother>01</NHSNumberStatusMother>
<PersonBirthDateMother>1982-01-05</PersonBirthDateMother>
<Postcode>LS1 4HY</Postcode>
<EthnicCategoryMother>99</EthnicCategoryMother>
<PersonDeathDateTimeMother>1900-01-01T00:00:00</PersonDeathDateTimeMother>
-<MAT003GPPracticeRegistration>
<LocalPatientIdMother>112552254</LocalPatientIdMother>
<OrgCodeGMPMother>4RT</OrgCodeGMPMother>
<StartDateGMPRegistration>2012-01-06</StartDateGMPRegistration>
<EndDateGMPRegistration>1900-01-01</EndDateGMPRegistration>
<OrgCodeCommissioner>6TY</OrgCodeCommissioner>
</MAT003GPPracticeRegistration>
-<MAT101BookingAppointmentDetails>
<AntenatalAppDate>2013-03-01</AntenatalAppDate>
<LocalPatientIdMother>112552254</LocalPatientIdMother>
<EDDAgreed>2013-05-01</EDDAgreed>
<EDDMethodAgreed>01</EDDMethodAgreed>
<PregnancyFirstContactDate>2013-11-11</PregnancyFirstContactDate>
<PregnancyFirstContactCareProfessionalType>060</PregnancyFirstContactCareProfessionalType>
<LastMenstrualPeriodDate>2012-10-01</LastMenstrualPeriodDate>
<PhysicalDisabilityStatusIndMother>Y</PhysicalDisabilityStatusIndMother>
<FirstLanguageEnglishIndMother>Y</FirstLanguageEnglishIndMother>
<EmploymentStatusMother>04</EmploymentStatusMother>
<SupportStatusMother>Y</SupportStatusMother>
<EmploymentStatusPartner>06</EmploymentStatusPartner>
<PreviousCaesareanSections>0</PreviousCaesareanSections>
<PreviousLiveBirths>0</PreviousLiveBirths>
<PreviousStillBirths>0</PreviousStillBirths>
<PreviousLossesLessThan24Weeks>0</PreviousLossesLessThan24Weeks>
<SubstanceUseStatus>01</SubstanceUseStatus>
<SmokingStatus>03</SmokingStatus>
<CigarettesPerDay>0</CigarettesPerDay>
<AlcoholUnitsPerWeek>0</AlcoholUnitsPerWeek>
<FolicAcidSupplement>03</FolicAcidSupplement>
<MHPredictionDetectionIndMother>N</MHPredictionDetectionIndMother>
<PersonWeight>75.0</PersonWeight>
<PersonHeight>1.45</PersonHeight>
<ComplexSocialFactorsInd>N</ComplexSocialFactorsInd>
</MAT101BookingAppointmentDetails>
</MATHDRHeader>
</MSDS:MSDS>
XDS 示例
<xs:complexType name="MSDSMAT001MothersDemographicsType">
<xs:sequence>
<xs:element name="LocalPatientIdMother" type="ST" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:appinfo>LOCAL PATIENT IDENTIFIER (MOTHER)</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="OrgCodeLocalPatientIdMother" type="ST" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:appinfo>ORGANISATION CODE (LOCAL PATIENT IDENTIFIER (MOTHER))</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="OrgCodeRes" type="ST" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:appinfo>ORGANISATION CODE (RESIDENCE RESPONSIBILITY)</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="NHSNumberMother" type="ST" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:appinfo>NHS NUMBER (MOTHER)</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="NHSNumberStatusMother" type="ST" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:appinfo>NHS NUMBER STATUS INDICATOR CODE (MOTHER)</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="PersonBirthDateMother" type="ST" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:appinfo>PERSON BIRTH DATE (MOTHER)</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Postcode" type="ST" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:appinfo>POSTCODE OF USUAL ADDRESS (MOTHER)</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="EthnicCategoryMother" type="ST" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:appinfo>ETHNIC CATEGORY (MOTHER)</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="PersonDeathDateTimeMother" type="ST" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:appinfo>PERSON DEATH DATE TIME (MOTHER)</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="MAT003GPPracticeRegistration" type="MSDSMAT003GPPracticeRegistrationType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT101BookingAppointmentDetails"
type="MSDSMAT101BookingAppointmentDetailsType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT112DatingScanProcedure" type="MSDSMAT112DatingScanProcedureType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT201BloodGroupRhesusTest" type="MSDSMAT201BloodGroupRhesusTestType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT203RubellaSusceptibilityTest"
type="MSDSMAT203RubellaSusceptibilityTestType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT205HepatitisBScreeningTest"
type="MSDSMAT205HepatitisBScreeningTestType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT210AsymptomaticBacteriuriaScreeningOffer"
type="MSDSMAT210AsymptomaticBacteriuriaScreeningOfferType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT211HaemoglobinopathyScreeningTest"
type="MSDSMAT211HaemoglobinopathyScreeningTestType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT301MaternityCarePlan" type="MSDSMAT301MaternityCarePlanType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT303DownsSyndromeScreeningTest"
type="MSDSMAT303DownsSyndromeScreeningTestType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT305FetalAnomalyScreeningTest"
type="MSDSMAT305FetalAnomalyScreeningTestType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT306AntenatalAppointment" type="MSDSMAT306AntenatalAppointmentType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT307MedicalDiag" type="MSDSMAT307MedicalDiagType" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT309MaternityObstetricDiag" type="MSDSMAT309MaternityObstetricDiagType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT310AntenatalAdmission" type="MSDSMAT310AntenatalAdmissionType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT404LabourAndDelivery" type="MSDSMAT404LabourAndDeliveryType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT408MCI" type="MSDSMAT408MCIType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="MAT501FetusOutcome" type="MSDSMAT501FetusOutcomeType" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT502BabysDemographicsAndBirthDetails"
type="MSDSMAT502BabysDemographicsAndBirthDetailsType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT602PostpartumDischarge" type="MSDSMAT602PostpartumDischargeType"
minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="MAT603PostpartumReadmission" type="MSDSMAT603PostpartumReadmissionType"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
【问题讨论】:
-
请提供更多详细信息(架构、缩减样本、预期输出),可能会发现,T-SQL 是错误的语言……还有其他可用的工具/语言吗?
-
架构长度为 77000 个字符?我听说 SSIS 是更好的方法。
-
使用
.Net,您可以-例如-从有效架构创建DataSet,然后尝试将数据加载到此架构中...在SQL Server中,架构支持相当差-数据验证 -
恐怕数据来源于 SQL 表,正如我所说的目标是将结果集输出到 XML 文件中
-
我的理解:有一些带有数据的数据库表,您想将它们导出为 XML(文件)。当您使用模式来获得这种轻松时,您希望某种自动化......到目前为止正确吗?每个表一个 XML 还是一个大包含所有内容怪物?
标签: sql-server xml validation sql-server-2012 schema