1 / 5

UnTyped XML

UnTyped XML. CREATE TABLE TABLE2 ( XMLSample XML) GO INSERT TABLE2 VALUES('TEST') INSERT TABLE2 VALUES('123') - The table should not allow any TYPE of data other than XML format with specific element. But it allows. This is called ' UnTyped XML '.

sheryl
Download Presentation

UnTyped XML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UnTyped XML CREATE TABLE TABLE2 (XMLSample XML) GO INSERT TABLE2 VALUES('TEST') INSERT TABLE2 VALUES('123') - The table should not allow any TYPE of data other than XML format with specific element. But it allows. This is called 'UnTyped XML '.

  2. Create a schema to valide XML at update and insert time. • Typed XML : I create one Table with one column as XML datatype. It should allow only INTEGER type of data along with some specific XML Element. This is called 'Typed XML'.

  3. Typed XML • We have to define a XML SCHEMA. CREATE XML SCHEMA COLLECTION IntegerInXMLSchema AS ' <schema xmlns="http://www.w3.org/2001/XMLSchema"> <element name=“OurElement" type="int"/> </schema>' GO

  4. Thenwecreate the table with a specific type at the XML columns • CREATE TABLE TABLE2 (XMLTyped XML(IntegerInXMLSchema)) GO • Inserting this: INSERT TABLE2 VALUES('TEST') • Will give error: • - It will throw an Err Msg 6909, Level 16, State 1, Line 1 XML Validation: Text node is not allowed at this location, the type was defined with element only content or with simple content. Location: /

  5. Typed XML • INSERT TABLE2 VALUES('<OurElement>123</OurElement>') • Will give result:(1 row(s) affected)

More Related