Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 XML schema collection

Author  Topic 

medtech26
Posting Yak Master

169 Posts

Posted - 2009-03-09 : 16:59:38
Hello,

Is there any way to import a remote schema (http://.../schema.xsd) to SQL as schema collection?

I have this huge schema from 3rd party, on top of being huge it brakes into many smaller ones using "include" statement (witch apparently doesn't supported by SQL 2005 XML schema collection).

Also, can I create a table with XML data and append values prior to creating related schema?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-10 : 03:15:21
see this

http://msdn.microsoft.com/en-us/library/ms191184.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-10 : 14:20:05
you can. however if it doesnt follow the schema, you wont be able to link it to schema. use SELECT ...INTO....FOR XML for creating table
Go to Top of Page

medtech26
Posting Yak Master

169 Posts

Posted - 2009-03-10 : 14:22:45
Hi visakh16 and thanks for your input, however, I have no problems importing data from XML files (at least as far as I know, didn't got there yet). The only problems as of now occur when trying different ways to import the schema for related XML files (I have over 4K XML file using the same schema(s)). No matter what I try I keep getting an error message (:-() so I wandered if there is a way to import remote schema as a whole.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-10 : 14:32:25
whats the error you got?
Go to Top of Page

medtech26
Posting Yak Master

169 Posts

Posted - 2009-03-10 : 15:20:55
I'll start with the fact that I'm using
CREATE XML SCHEMA COLLECTION schemas_tmp_name AS N'<?xml version="1.0" encoding="UTF-8" standalone="no"?>...'
to create the initial schema, then adding to it by using
ALTER XML SCHEMA COLLECTION schemas_tmp_name ADD '<?xml version="1.0" encoding="UTF-8"?>...'


Also (and as a response to you're second post) I was planing to insert data as you suggested but first create the table as you may see in the following example, this will allow SQL to parse XML data accordingly:
CREATE TABLE XML_table(ID int, XML_data xml(schemas_tmp_name))


Errors:
* "The XML Schema syntax '<xsd:include>' is not supported." ~ solution: removal of all "include" tags and related files were to be added individually (that was the plan).

* "XML parsing: line 1, character 38, unable to switch the encoding" ~ although encoding was converted to UTF-8 (from UTF-16) in notepad++, SQL would NOT accept it and seems to insist that encoding declaration stays point at UTF-16 (I would prefer UTF-8 but for quick resolution declared UTF-16).

* "Reference to an undefined name 'some_random_var'" ~ (some_random_var may very for each schema) my guess would be that the specific missing definition is defined in one of the other schema files ... not sure that this is the case but that's where I'm stuck as of now.
Go to Top of Page

medtech26
Posting Yak Master

169 Posts

Posted - 2009-03-12 : 15:14:54
I'm going to to try and combine all schema files (total of 5) but meanwhile wonder if there is a easier solution like link to remote schema (my initial question) or how to resolve the current problem with "...undefined name..."?
Go to Top of Page
   

- Advertisement -