0
죄송합니다. 여기에 완전한 xquery 멍청한 놈이 있습니다. 나는 "trmt : drugTreatment"요소가있는 경우에만 다음 XML 문서에서 복용량, 약물 이름 및 진단을 반환하는 쿼리를 작성하려고합니다.전체 xml 메타 데이터를 반환하는 XQuery
<?xml version="1.0" encoding="UTF-8"?>
<clin:Clinic
xmlns:cids="http://www.example.org/schema/hosptial/clinicIds"
xmlns:clin="http://www.example.org/schema/hospital/clinic"
xmlns:pat="http://www.example.org/schema/hospital/patient"
xmlns:prov="http://www.example.org/schema/hospital/provider"
xmlns:trmt="http://www.example.org/schema/hospital/treatment"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/schema/hospital/clinic
Clinic.xsd ">
<clin:Patient>
<pat:patient-id>0001</pat:patient-id>
<pat:patientName>Thomas Edison</pat:patientName>
<pat:dob>1991-01-01</pat:dob>
<pat:treatments>
<pat:treatment>
<trmt:providerId>001</trmt:providerId>
<trmt:diagnosis>Heart</trmt:diagnosis>
<trmt:drugTreatment>
<trmt:dosage>12.5mg</trmt:dosage>
<trmt:drugName>heart_med</trmt:drugName>
</trmt:drugTreatment>
</pat:treatment>
</pat:treatments>
</clin:Patient>
<clin:Provider>
<prov:provider-id>001</prov:provider-id>
<prov:providerName>XYZ</prov:providerName>
<prov:specialization>Cardiology</prov:specialization>
</clin:Provider>
</clin:Clinic>
다음은 제 간단한 xquery이며 설명 된대로 기본적으로 복용량, 약물 및 진단을 반환하기로되어 있습니다. 내가 쿼리를 실행할 때, 나는 얻는 결과
쿼리
for $t in $clinData//clin:Patient
where some $x in $t/pat:patient-id
satisfies $t/pat:patient-id = $patient-id
return <Treatment>
<Drug>
{$t//treatment:drugName}
</Drug>
<Dosage>
{$t//treatment:dosage}
</Dosage>
<Dignosis>
{$t//treatment:diagnosis}
</Dignosis>
</Treatment>
결과에 대한 전체 메타 데이터는
<?xml version="1.0" encoding="UTF-8"?>
<Treatment><Drug>heart_med</Drug><Dosage><trmt:dosage
xmlns:cids="http://www.example.org/schema/hosptial/clinicIds"
xmlns:clin="http://www.example.org/schema/hospital/clinic"
xmlns:pat="http://www.example.org/schema/hospital/patient"
xmlns:prov="http://www.example.org/schema/hospital/provider"
xmlns:trmt="http://www.example.org/schema/hospital/treatment"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">12.5mg</trmt:dosage></Dosage><Dignosis><trmt:diagnosis
xmlns:cids="http://www.example.org/schema/hosptial/clinicIds"
xmlns:clin="http://www.example.org/schema/hospital/clinic"
xmlns:pat="http://www.example.org/schema/hospital/patient"
xmlns:prov="http://www.example.org/schema/hospital/provider"
xmlns:trmt="http://www.example.org/schema/hospital/treatment"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">Heart</trmt:diagnosis></Dignosis></Treatment>
내가 잘못 여기서 뭐하는거야?
where some $x in $t/pat:patient-id
satisfies $t/pat:patient-id = $patient-id
(순서의 모든 항목 중 하나가 조건을 만족시킬 것, 또는 없음이된다는 것을 의미합니다) $에 대한 참조 X를하지 않는다 : 여기에 "만족"절 때문에