Monday, March 26, 2012

newbie question

The query:
Select FirstName, LastName
from AdventureWorks.Person.Contact PC
, AdventureWorks.HumanResources.Employee HRE
Where PC.ContactId = HRE.ContactId
AND LastName like 'Gilbert'
FOR XML auto, xmldata
The results:
<?xml version="1.0" encoding="UTF-8"?>
<Schema name="Schema1" xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:datatypes">
<ElementType name="PC" content="empty" model="closed">
<AttributeType name="FirstName" dt:type="string" />
<AttributeType name="LastName" dt:type="string" />
<attribute type="FirstName" />
<attribute type="LastName" />
</ElementType>
</Schema>
<PC xmlns="x-schema:#Schema1" FirstName="Guy" LastName="Gilbert" />
Action:
Paste results into Altova XML Spy xml schema file type
or sml document file type
The Error:
File not well formatted.
It seems to be two document elements issue.
Pohwan Han. Seoul. Have a nice day.
"mj" <mj@.discussions.microsoft.com> wrote in message
news:D479F5A7-235B-46D7-9E63-DA99F19964B1@.microsoft.com...
> The query:
> Select FirstName, LastName
> from AdventureWorks.Person.Contact PC
> , AdventureWorks.HumanResources.Employee HRE
> Where PC.ContactId = HRE.ContactId
> AND LastName like 'Gilbert'
> FOR XML auto, xmldata
> The results:
> <?xml version="1.0" encoding="UTF-8"?>
>
> <Schema name="Schema1" xmlns="urn:schemas-microsoft-com:xml-data"
> xmlns:dt="urn:schemas-microsoft-com:datatypes">
> <ElementType name="PC" content="empty" model="closed">
> <AttributeType name="FirstName" dt:type="string" />
> <AttributeType name="LastName" dt:type="string" />
> <attribute type="FirstName" />
> <attribute type="LastName" />
> </ElementType>
> </Schema>
> <PC xmlns="x-schema:#Schema1" FirstName="Guy" LastName="Gilbert" />
> Action:
> Paste results into Altova XML Spy xml schema file type
> or sml document file type
> The Error:
> File not well formatted.
>
>
|||Woud it be possible to expand a littleon you're response please?
"Han" wrote:

> It seems to be two document elements issue.
> --
> Pohwan Han. Seoul. Have a nice day.
> "mj" <mj@.discussions.microsoft.com> wrote in message
> news:D479F5A7-235B-46D7-9E63-DA99F19964B1@.microsoft.com...
>
|||A FOR XML query returns fragments and not whole documents. You may want to
specify the root property in the provider to get the document well formed
with a single root element.
Best regards
Michael
"mj" <mj@.discussions.microsoft.com> wrote in message
news:945BDD2C-918B-4D0E-A6E2-709A6190D32B@.microsoft.com...[vbcol=seagreen]
> Woud it be possible to expand a littleon you're response please?
> "Han" wrote:

No comments:

Post a Comment