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)
 how to add xml attribute

Author  Topic 

wabis
Starting Member

1 Post

Posted - 2009-03-07 : 12:43:07
code snippet:
CREATE XML SCHEMA COLLECTION MovieSchema AS N'<?xml version="1.0" encoding="UTF-16"?>
<xs:schema xmlns="http://schemas.sqlservercentral.com/MovieSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema">



<xs:element name="movies">

<xs:complexType>
<xs:sequence>
<xs:element name="film" minOccurs="1" maxOccurs="unbounded">


<xs:complexType>
<xs:sequence>
<xs:element name="name" minOccurs="1" maxOccurs="1" type="xs:string"/>
<xs:element name="releaseDate" minOccurs="1" maxOccurs="1" type="xs:date"/>
<xs:element name="gross" minOccurs="1" maxOccurs="1" type="xs:decimal"/>
<xs:element name="director" minOccurs="1" maxOccurs="1" type="xs:string"/>
</xs:sequence>

<xs:attribute name="disctype" type="xs:string"/>
<xs:attribute name="category" type="xs:string"/>

</xs:complexType>
</xs:element>
</xs:sequence>

</xs:complexType>
</xs:element>
</xs:schema>';
GO

this works well but i'm unable to add schema for an attribute called "status" to element "releaseDate".

I'm able to add disctype,category to element "film", can anybody suggest/help what i'm missing with.



WM

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-08 : 13:21:31
[code]
CREATE XML SCHEMA COLLECTION MovieSchema AS N'<?xml version="1.0" encoding="UTF-16"?>
<xs:schema xmlns="http://schemas.sqlservercentral.com/MovieSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema">



<xs:element name="movies">

<xs:complexType>
<xs:sequence>
<xs:element name="film" minOccurs="1" maxOccurs="unbounded">


<xs:complexType>
<xs:sequence>
<xs:element name="name" minOccurs="1" maxOccurs="1" type="xs:string"/>

<xs:element name="releaseDate" minOccurs="1" maxOccurs="1" type="xs:date">
<xs:complexType>
<xs:attribute name="disctype" type="xs:string"/>
</xs:complexType>
</xs:element>

<xs:element name="gross" minOccurs="1" maxOccurs="1" type="xs:decimal"/>
<xs:element name="director" minOccurs="1" maxOccurs="1" type="xs:string"/>
</xs:sequence>

<xs:attribute name="disctype" type="xs:string"/>
<xs:attribute name="category" type="xs:string"/>

</xs:complexType>
</xs:element>
</xs:sequence>

</xs:complexType>
</xs:element>
</xs:schema>';
GO
[/code]
try like above
Go to Top of Page
   

- Advertisement -