Click here to Skip to main content
15,909,466 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does anyone know how to create a schema for an XML document? This is the exact instructions, in case it helps.

Create a schema for an XML document that will store information about patients in a hospital. Information about patients must include name (in 3 parts), Social Security number, age, room number, primary insurance company – including member identification number, group number, phone number and address – secondary insurance company (in the same subparts as for the primary insurance company), known medical problems, and known drug allergies. Create a sample XML document with 2-3 patients in it that is valid based on your schema.
Posted

This looks like homework. The best answer for this is to consult with your class notes.

If it is not homework, you can create a schema in Visual Studio from an existing XML file (your question looks like you create the schema first, then generate xml from it... it is actually easier the other way around). Open the xml file in Visual Studio (assuming it has '.xml' extension). Click XML -> Create Schema

Viola :-)
 
Share this answer
 
It's kind of hard to explain what it is the OP is trying to .. understand. But given the apaucity of TSQL in the question I'd formulate that THAT'S what the question actually is. So ... look for stuff related to these things, here in CPQA, using google, even the BOL:
USE [database]
GO

CREATE TABLE [xml].[tblXMLDocBulkInserted](
	[xmliform] [nvarchar](max) NULL
) ON [PRIMARY]

BULK INSERT [database].[xml].[tblXMLDocBulkInserted]
    FROM 'c:\users\cpqa\js\xmlDocument.xml'

CREATE TABLE [xml].[tblXMLDocBulkInsertedIdx](
	[Idx] [int] IDENTITY(1,1) NOT NULL,
	[xmliform] [nvarchar](max) NULL
) ON [PRIMARY]

INSERT INTO [database].[xml].[tblXMLDocBulkInsertedIdx]
   SELECT * FROM [database].[xml].[tblXMLDocBulkInserted]

SELECT [Idx]
      ,[xmliform]
  FROM [20121212151401555].[xml].[tblXMLDocBulkInserted]
GO

SELECT * FROM  [database].[xml].[tblXMLDocBulkInsertedIdx]
 WHERE [xmliform] LIKE '%>%<%' 

In this return you'll see a list of all those good things found in a "schema". It's easy to see that there's data "contained" by it. Compare this result to the original input document.

On the other hand, then, there's some data here (perhaps):
SELECT * FROM [database].[xml].[tblXMLDocBulkInsertedIdx]
  WHERE [xmliform] NOT LIKE '%<%'	
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900