Мне нужно создать запрос из xml-файла, который содержит 4 пространства имен, но ни у одного из них нет уникального идентификатора.например.xmlns: fb
Я перечислил их ниже:
xmlns="http://xxx/pie/svc/frs/FindRegistration/2.0.0"
xmlns="http://xxx/pie/xsd/frs/FindRegistrationMessages/2.0.0"
xmlns="http://xxx/pie/xsd/common/CommonCoreElements/2.0.0"
xmlns="http://xxx/pie/xsd/frs/PractitionerRegistrationElements/2.0.0"
Если я удаляю все пространства имен (через Visual Studio) из документа, я могу получить данные в порядке, но мне нужно сохранитьпространства имен целы.
<FindRegistrationsResponse xmlns="http://xxx/pie/svc/frs/FindRegistration/2.0.0">
<AuditDetails xmlns="http://xxx/pie/xsd/frs/FindRegistrationMessages/2.0.0">
<QueryIdentifier xmlns="http://xxx/pie/xsd/common/CommonCoreElements/2.0.0">8901823</QueryIdentifier>
<PractitionerCount xmlns="http://xxx/pie/xsd/common/CommonCoreElements/2.0.0">134140</PractitionerCount>
<ServiceMessagesCount xmlns="http://xxx/pie/xsd/common/CommonCoreElements/2.0.0">2</ServiceMessagesCount>
<TotalRecordsSearched xmlns="http://xxx/pie/xsd/common/CommonCoreElements/2.0.0">134142</TotalRecordsSearched>
<TotalNumberOfRegistration xmlns="http://xxx/pie/xsd/common/CommonCoreElements/2.0.0">257034</TotalNumberOfRegistration>
<SnapshotDate xmlns="http://xxx/pie/xsd/common/CommonCoreElements/2.0.0">2018-06-29</SnapshotDate>
</AuditDetails>
<ProfessionNumberReplay ProfessionNumber="MED0000xxxxx" xmlns="http://xxx/pie/xsd/frs/FindRegistrationMessages/2.0.0">
<Practitioner>
<PractitionerIdentifier xmlns="http://xxx/pie/xsd/frs/PractitionerRegistrationElements/2.0.0">xxxxxxxx</PractitionerIdentifier>
<PractitionerName NameEditDate="2010-07-03T14:14:35.377" xmlns="http://xxx/pie/xsd/frs/PractitionerRegistrationElements/2.0.0">
<NameTitle>Dr</NameTitle>
<FamilyName>Smith</FamilyName>
<GivenName>John</GivenName>
<MiddleName />
</PractitionerName>
<Demographics xmlns="http://xxx/pie/xsd/frs/PractitionerRegistrationElements/2.0.0">
<Gender>GenderName</Gender>
</Demographics>
<Qualification QualificationEditDate="2016-08-10T19:35:54.067" xmlns="http://xxx/pie/xsd/frs/PractitionerRegistrationElements/2.0.0">
<QualificationTitle>Bachelor of Medicine / Bachelor of Surgery </QualificationTitle>
<AwardingInstitution>University of xxx</AwardingInstitution>
<CountryQualificationObtained>Country Name</CountryQualificationObtained>
<YearOfQualification>1999</YearOfQualification>
</Qualification>
<Address AddressEditDate="2010-07-03T14:15:48.607" xmlns="http://xxx/pie/xsd/frs/PractitionerRegistrationElements/2.0.0">
<AustralianAddress>
<AustralianLocality>SUBURB NAME</AustralianLocality>
<AustralianPostcode>2000</AustralianPostcode>
<AustralianState>NSW</AustralianState>
<Country>Australia</Country>
</AustralianAddress>
</Address>
<Profession xmlns="http://xxx/pie/xsd/frs/PractitionerRegistrationElements/2.0.0">
<ProfessionNumber>MED0000xxxxx</ProfessionNumber>
<Profession>Medical Practitioner</Profession>
<ProfessionStartDate>1999-05-10T00:00:00</ProfessionStartDate>
<Registration>
<RecordNumber>001</RecordNumber>
<RegistrationType>Limited (Public Interest - Occasional Practice)</RegistrationType>
<RegistrationStatus>Unregistered</RegistrationStatus>
<RegistrationSubStatus>Withdrawn</RegistrationSubStatus>
<RegistrationToDate>2013-09-30T00:00:00</RegistrationToDate>
<InitialRegistrationDate>1965-05-10T00:00:00</InitialRegistrationDate>
</Registration>
<Condition ConditionEditDate="2012-10-22T14:00:10.5">
<ConditionType>Registration</ConditionType>
<ConditionDetail>text here</ConditionDetail>
</Condition>
</Profession>
</Practitioner>
</ProfessionNumberReplay>
</FindRegistrationsResponse>
Это код T-SQL, который я пробовал:
DECLARE @XML AS XML, @hDoc AS INT, @SQL NVARCHAR (MAX)
SELECT @XML = XMLData FROM AHPRA_XML
EXEC sp_xml_preparedocument @hDoc OUTPUT, @XML
;WITH XMLNAMESPACES('http://xxx/pie/svc/frs/FindRegistration/2.0.0',
'http://xxx/pie/xsd/frs/FindRegistrationMessages/2.0.0',
'http://xxx/pie/xsd/common/CommonCoreElements/2.0.0',
'http://xxx/pie/xsd/frs/PractitionerRegistrationElements/2.0.0')
SELECT DISTINCT ProfessionNumber, NameTitle, GivenName, MiddleName, FamilyName, Gender
FROM OPENXML(@hDoc, 'FindRegistrationsResponse/ProfessionNumberReplay/Practitioner')
WITH
(
ProfessionNumber [varchar](50) '../@ProfessionNumber',
NameTitle [varchar](20) 'PractitionerName/NameTitle',
GivenName [varchar](100) 'PractitionerName/GivenName',
MiddleName [varchar](100) 'PractitionerName/MiddleName',
FamilyName [varchar](100) 'PractitionerName/FamilyName',
Gender [varchar](10) 'Demographics/Gender'
)
EXEC sp_xml_removedocument @hDoc
GO