Tuesday, 10 February 2015

Validating xml via xsd



I'm new to XSD, so please help. I've created an xml usinf "for xml path" in SQL Server Management Studio 2008. It looks like: enter image description here


I've red some literature, where after creating such an xml, I'm suuposed to run this: enter image description here


But it doesn't work. As I know after saving this file in xml and clicking it twice, it should open xml in browser. But it doesn't. What is wrong? primary key is ReferenceCode. I've created xml using this query:



select p.ReferenceCode
,p.LastName
,p.FirstName
,p.BirthDate
,p.BirthPlace
,(
select d.Type
,d.Series
,d.Number
,d.IssueDate
,d.IssueAuthority
from #Document d
where d.ReferenceCode = p.ReferenceCode
for xml path ('Document'),root('Documents'),Type
)
,(
select a.Type
,a.Street
from #Address a
where a.ReferenceCode = p.ReferenceCode
for xml path ('Address'),root('Addresses'),Type
)
,(
select h.Number
from #Phone h
where h.ReferenceCode = p.ReferenceCode
for xml path ('Phone'),root('Phone'),Type
)
from #Person p
for xml path ('Person'),root('Root')


Thanks in advance


No comments:

Post a Comment