By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,701 Members | 1,970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,701 IT Pros & Developers. It's quick & easy.

help with schema for xml data from exchange server

P: n/a
I have xml data coming in as a stream from a web service running against
exchange server.The attributes for the elements dtstart and dtend,
b:dt="dateTime.tz" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/,
are causing trouble. I tried to create schema using xmlspy and I get an
error saying name "b:dt" cannot have a namespace prefix.

I am new to xml. Can somebody please help with schema.

<appointments>
<appointment>
<url>http://test/exchange/test1/Calendar/meeting1-7.EML</url>
<subject>meeting1</subject>
<dtstart b:dt="dateTime.tz"
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">2003-09-09T14:00:00
..000Z</dtstart>
<dtend b:dt="dateTime.tz"
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">2003-09-09T14:30:00
..000Z</dtend>
</appointment>
<appointment>
<url>http://test/exchange/test1/Calendar/Testing%20freebusy1-7.EML</url>
<subject>Testing freebusy1</subject>
<dtstart b:dt="dateTime.tz"
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">2003-09-09T15:00:00
..000Z</dtstart>
<dtend b:dt="dateTime.tz"
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">2003-09-09T15:30:00
..000Z</dtend>
</appointment>
<appointment>
<url>http://test/exchange/test1/Calendar/meeting2-7.EML</url>
<subject>meeting2</subject>
<dtstart b:dt="dateTime.tz"
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">2003-09-09T18:00:00
..000Z</dtstart>
<dtend b:dt="dateTime.tz"
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">2003-09-09T18:30:00
..000Z</dtend>
</appointment>
</appointments>

The schema file -
<?xml version="1.0" encoding="UTF-8"?>

<!--W3C Schema generated by XMLSPY v2004 rel. 2 U (http://www.xmlspy.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="appointment">
<xs:complexType>
<xs:sequence>
<xs:element name="url" ref="url"/>
<xs:element name="subject" ref="subject"/>
<xs:element name="dtstart" ref="dtstart"/>
<xs:element name="dtend" ref="dtend"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="appointments">
<xs:complexType>
<xs:sequence>
<xs:element name="appointment" ref="appointment" minOccurs="1"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="dtend">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="dtendSimpleType">
<xs:attribute name="b:dt" type="xs:string" use="required"/>
<xs:attribute name="xmlns:b" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="dtendSimpleType">
<xs:restriction base="xs:dateTime">
<xs:enumeration value="2003-09-09T14:30:00.000Z"/>
<xs:enumeration value="2003-09-09T15:30:00.000Z"/>
<xs:enumeration value="2003-09-09T18:30:00.000Z"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="dtstart">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="dtstartSimpleType">
<xs:attribute name="b:dt" type="xs:string" use="required"/>
<xs:attribute name="xmlns:b" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="dtstartSimpleType">
<xs:restriction base="xs:dateTime">
<xs:enumeration value="2003-09-09T14:00:00.000Z"/>
<xs:enumeration value="2003-09-09T15:00:00.000Z"/>
<xs:enumeration value="2003-09-09T18:00:00.000Z"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="subject" type="xs:string"/>
<xs:element name="url">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration
value="http://test/exchange/test1/Calendar/Testing%20freebusy1-7.EML"/>
<xs:enumeration value="http://test/exchange/test1/Calendar/meeting1-7.EML"/>
<xs:enumeration value="http://test/exchange/test1/Calendar/meeting2-7.EML"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>
Thanks
mrao
Nov 11 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hello,

I tested your XML in XMPSPY, it worked when I generate schema in DTD or
XML-Data, and only failed with W3C Schema. It seems to be a limitation of
XMLSPY. You may contact thier support for more detail information:
http://www.xmlspy.com/support_center.html

Luke
Microsoft Online Partner Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 11 '05 #2

P: n/a
M Rao wrote:
I have xml data coming in as a stream from a web service running against
exchange server.The attributes for the elements dtstart and dtend,
b:dt="dateTime.tz" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/,
are causing trouble. I tried to create schema using xmlspy and I get an
error saying name "b:dt" cannot have a namespace prefix.
Seems like XML Spy's unable to generate Schema for such documents.
<xs:element name="url" ref="url"/> This is weird - xs:element can't have both name and ref attributes.
<xs:attribute name="b:dt" type="xs:string" use="required"/>
<xs:attribute name="xmlns:b" type="xs:string" use="required"/>

And this is wrong too.

Ok, I fixed up the generated schema. First of all you need 2 schema modules -
one to define basic XML structure (no namespace) and second to define dt
attribute in urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/ namespace. Here it is:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<!-- Import schema for b namespace -->
<xs:import namespace="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"
schemaLocation="dt.xsd"/>
<xs:element name="appointment">
<xs:complexType>
<xs:sequence>
<xs:element ref="url"/>
<xs:element ref="subject"/>
<xs:element ref="dtstart"/>
<xs:element ref="dtend"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="appointments">
<xs:complexType>
<xs:sequence>
<xs:element ref="appointment" minOccurs="1"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="dtend">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="dtendSimpleType">
<xs:attribute ref="b:dt"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="dtendSimpleType">
<xs:restriction base="xs:dateTime">
<xs:enumeration value="2003-09-09T14:30:00.000Z"/>
<xs:enumeration value="2003-09-09T15:30:00.000Z"/>
<xs:enumeration value="2003-09-09T18:30:00.000Z"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="dtstart">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="dtstartSimpleType">
<xs:attribute ref="b:dt"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="dtstartSimpleType">
<xs:restriction base="xs:dateTime">
<xs:enumeration value="2003-09-09T14:00:00.000Z"/>
<xs:enumeration value="2003-09-09T15:00:00.000Z"/>
<xs:enumeration value="2003-09-09T18:00:00.000Z"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="subject" type="xs:string"/>
<xs:element name="url">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration
value="http://test/exchange/test1/Calendar/Testing%20freebusy1-7.EML"/>
<xs:enumeration
value="http://test/exchange/test1/Calendar/meeting1-7.EML"/>
<xs:enumeration
value="http://test/exchange/test1/Calendar/meeting2-7.EML"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>

And dt.xsd is just

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"
xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<xs:attribute name="dt" type="xs:string" use="required"/>
</xs:schema>

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.