473,626 Members | 3,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to write XDR

PA
My dream XML will look like as follows:

<?xml version="1.0"?>
<bk:bookList xmlns:bk="urn:B ookSampleSchema .xdr">
<book>
<title>Doe's Book</title>
<author>J Doe</author>
<year>2002</year>
</book>
<book>
<title>Sam's Book</title>
<author>Sam</author>
<year>2003</year>
</book>
</bk:bookList>

and my XDR schema is:

<Schema name="test_sche ma"
xmlns="urn:sche mas-microsoft-com:xml-data"
xmlns:dt="urn:s chemas-microsoft-com:datatypes">

<ElementType name="title" content="textOn ly" model="closed"/>
<ElementType name="author" content="textOn ly" model="closed"/>
<ElementType name="year" content="textOn ly" model="closed"/>

<ElementType name="book" content="eltOnl y" model="closed">
<element type="title" minOccurs="1" maxOccurs="1"/>
<element type="author" minOccurs="1" maxOccurs="1"/>
<element type="year" minOccurs="1" maxOccurs="1"/>
</ElementType>

<ElementType name="bookList" content="eltOnl y" model="closed">
<element type="book" minOccurs="0" maxOccurs="*"/>
</ElementType>
</Schema>

I am using XMLValidatingRe ader to validate above xml. It fails if I
don't mention bk before book, title etc. elements.

Can anyone tell me what is the valid XDR for above XML?

Thanks in advance.

Pratibha
Nov 12 '05 #1
6 3843
why are you using XDR? XDR was Microsoft's implementation of an early
working draft of the XML Schema specification. In .NET, XDR is supported
primarily for backward compatibility. In general you should be using XML
Schema, which is now final.

Using the xsd.exe utility included in the .NET SDK, you can infer a schema
from a document.
The schema I get from your document is:

<xs:schema id="bookList" targetNamespace ="urn:BookSampl eSchema.xdr"
xmlns:mstns="ur n:BookSampleSch ema.xdr" xmlns="urn:Book SampleSchema.xd r"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata"
attributeFormDe fault="qualifie d" elementFormDefa ult="qualified" >
<xs:element name="bookList" msdata:IsDataSe t="true" msdata:Prefix=" bk">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="book" form="unqualifi ed">
<xs:complexType >
<xs:sequence>
<xs:element name="title" form="unqualifi ed" type="xs:string "
minOccurs="0" />
<xs:element name="author" form="unqualifi ed" type="xs:string "
minOccurs="0" />
<xs:element name="year" form="unqualifi ed" type="xs:string "
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

"PA" <pr*******@jvc. co.uk> wrote in message
news:f7******** *************** ***@posting.goo gle.com...
My dream XML will look like as follows:

<?xml version="1.0"?>
<bk:bookList xmlns:bk="urn:B ookSampleSchema .xdr">
<book>
<title>Doe's Book</title>
<author>J Doe</author>
<year>2002</year>
</book>
<book>
<title>Sam's Book</title>
<author>Sam</author>
<year>2003</year>
</book>
</bk:bookList>

and my XDR schema is:

<Schema name="test_sche ma"
xmlns="urn:sche mas-microsoft-com:xml-data"
xmlns:dt="urn:s chemas-microsoft-com:datatypes">

<ElementType name="title" content="textOn ly" model="closed"/>
<ElementType name="author" content="textOn ly" model="closed"/>
<ElementType name="year" content="textOn ly" model="closed"/>

<ElementType name="book" content="eltOnl y" model="closed">
<element type="title" minOccurs="1" maxOccurs="1"/>
<element type="author" minOccurs="1" maxOccurs="1"/>
<element type="year" minOccurs="1" maxOccurs="1"/>
</ElementType>

<ElementType name="bookList" content="eltOnl y" model="closed">
<element type="book" minOccurs="0" maxOccurs="*"/>
</ElementType>
</Schema>

I am using XMLValidatingRe ader to validate above xml. It fails if I
don't mention bk before book, title etc. elements.

Can anyone tell me what is the valid XDR for above XML?

Thanks in advance.

Pratibha

Nov 12 '05 #2
P A
OK. I am now using XSD. Here is my new xml file.

<?xml version="1.0"?>
<bk:bookList xmlns:bk="urn:B ookSample.xsd">
<book>
<title>Doe's Book</title>
<author>J Doe</author>
<year>2002</year>
</book>
<book>
<title>Sam's Book</title>
<author>Sam</author>
<year>2003</year>
</book>
</bk:bookList>

I used XSD.exe to create XSD file. This is what I got

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="bookList" targetNamespace ="urn:BookSampl e.xsd"
xmlns:mstns="ur n:BookSample.xs d" xmlns="urn:Book Sample.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata"
attributeFormDe fault="qualifie d" elementFormDefa ult="qualified" >
<xs:element name="bookList" msdata:IsDataSe t="true"
msdata:Locale=" en-GB" msdata:Prefix=" bk">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="book" form="unqualifi ed">
<xs:complexType >
<xs:sequence>
<xs:element name="title" form="unqualifi ed"
type="xs:string " minOccurs="0" />
<xs:element name="author" form="unqualifi ed"
type="xs:string " minOccurs="0" />
<xs:element name="year" form="unqualifi ed"
type="xs:string " minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

My .NET code looks like as follows:

public function XMLValidattor() as Boolean
Dim myXMLDoc As New XmlDocument()
Dim myXMLNode As XmlElement
Dim myXMLReader As XmlReader
Dim sXMLData As String

myXMLDoc.Load(S erver.MapPath(" BookSample.xml" ))

' validate xml first
Dim TR As New XmlTextReader(N ew StringReader(my XMLDoc.OuterXml ))
Dim VR As XmlValidatingRe ader = New XmlValidatingRe ader(TR)

VR.Schemas.Add( "urn:Root.x dr", Server.MapPath( "BookSample.xsd "))
VR.ValidationTy pe = ValidationType. Schema
sErrMsg = ""
AddHandler VR.ValidationEv entHandler, AddressOf
ValidationCallB ack
While VR.Read
End While
VR.Close()
TR.Close()
If sErrMsg <> "" Then
Return False
Else
Return True
End If

Public Sub ValidationCallB ack(ByVal sender As Object, ByVal args As
ValidationEvent Args)
sErrMsg = args.Message
End Sub

When I run this I get following error:

System.Xml.Sche ma.XmlSchemaExc eption: The attribute targetNamespace does
not match the designated namespace URI. An error occurred at
file:///c:/inetpub/wwwroot/CMService/BookSample.xsd, (2, 2).
at System.Xml.Sche ma.Compiler.Sen dValidationEven t(XmlSchemaExce ption
e, XmlSeverityType severity)
at System.Xml.Sche ma.Compiler.Sen dValidationEven t(String code,
XmlSchemaObject source)
at System.Xml.Sche ma.Compiler.Pre process(XmlSche ma schema, String
targetNamespace , Compositor compositor)
at System.Xml.Sche ma.Compiler.Pre process(XmlSche ma schema, String
targetNamespace )
at System.Xml.Sche ma.Compiler.Com pile(XmlSchema schema, String
targetNamespace , SchemaInfo schemaInfo)
at System.Xml.Sche ma.XmlSchema.Co mpile(XmlSchema Collection
collection, XmlNameTable nameTable, SchemaNames schemaNames,
ValidationEvent Handler validationEvent Handler, String targetNamespace ,
SchemaInfo schemaInfo, Boolean compileContentM odel, XmlResolver
resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, SchemaInfo
schemaInfo, XmlSchema schema, Boolean compile, XmlResolver resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, XmlReader
reader, XmlResolver resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, String uri)
at CMService.CMSer vice.XMLReading WithXDR() in
C:\Inetpub\wwwr oot\CMService\C MService.asmx.v b:line 674
What's wrong now?

Thanks in advance.

Pratibha
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
The targetNamespace you have still refers to the XDR schema's namespace.

Change this line:
VR.Schemas.Add( "urn:Root.x dr", Server.MapPath( "BookSample.xsd "))

to this line:
VR.Schemas.Add( "urn:BookSample .xsd", Server.MapPath( "BookSample.xsd "))
--
Kirk Allen Evans
http://blogs.msdn.com/kaevans

-- This posting is provided "AS IS" with no warranties, and confers no
rights.

"P A" <do****@xml.co. uk> wrote in message
news:uA******** *****@tk2msftng p13.phx.gbl...
OK. I am now using XSD. Here is my new xml file.

<?xml version="1.0"?>
<bk:bookList xmlns:bk="urn:B ookSample.xsd">
<book>
<title>Doe's Book</title>
<author>J Doe</author>
<year>2002</year>
</book>
<book>
<title>Sam's Book</title>
<author>Sam</author>
<year>2003</year>
</book>
</bk:bookList>

I used XSD.exe to create XSD file. This is what I got

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="bookList" targetNamespace ="urn:BookSampl e.xsd"
xmlns:mstns="ur n:BookSample.xs d" xmlns="urn:Book Sample.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata"
attributeFormDe fault="qualifie d" elementFormDefa ult="qualified" >
<xs:element name="bookList" msdata:IsDataSe t="true"
msdata:Locale=" en-GB" msdata:Prefix=" bk">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="book" form="unqualifi ed">
<xs:complexType >
<xs:sequence>
<xs:element name="title" form="unqualifi ed"
type="xs:string " minOccurs="0" />
<xs:element name="author" form="unqualifi ed"
type="xs:string " minOccurs="0" />
<xs:element name="year" form="unqualifi ed"
type="xs:string " minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

My .NET code looks like as follows:

public function XMLValidattor() as Boolean
Dim myXMLDoc As New XmlDocument()
Dim myXMLNode As XmlElement
Dim myXMLReader As XmlReader
Dim sXMLData As String

myXMLDoc.Load(S erver.MapPath(" BookSample.xml" ))

' validate xml first
Dim TR As New XmlTextReader(N ew StringReader(my XMLDoc.OuterXml ))
Dim VR As XmlValidatingRe ader = New XmlValidatingRe ader(TR)

VR.Schemas.Add( "urn:Root.x dr", Server.MapPath( "BookSample.xsd "))
VR.ValidationTy pe = ValidationType. Schema
sErrMsg = ""
AddHandler VR.ValidationEv entHandler, AddressOf
ValidationCallB ack
While VR.Read
End While
VR.Close()
TR.Close()
If sErrMsg <> "" Then
Return False
Else
Return True
End If

Public Sub ValidationCallB ack(ByVal sender As Object, ByVal args As
ValidationEvent Args)
sErrMsg = args.Message
End Sub

When I run this I get following error:

System.Xml.Sche ma.XmlSchemaExc eption: The attribute targetNamespace does
not match the designated namespace URI. An error occurred at
file:///c:/inetpub/wwwroot/CMService/BookSample.xsd, (2, 2).
at System.Xml.Sche ma.Compiler.Sen dValidationEven t(XmlSchemaExce ption
e, XmlSeverityType severity)
at System.Xml.Sche ma.Compiler.Sen dValidationEven t(String code,
XmlSchemaObject source)
at System.Xml.Sche ma.Compiler.Pre process(XmlSche ma schema, String
targetNamespace , Compositor compositor)
at System.Xml.Sche ma.Compiler.Pre process(XmlSche ma schema, String
targetNamespace )
at System.Xml.Sche ma.Compiler.Com pile(XmlSchema schema, String
targetNamespace , SchemaInfo schemaInfo)
at System.Xml.Sche ma.XmlSchema.Co mpile(XmlSchema Collection
collection, XmlNameTable nameTable, SchemaNames schemaNames,
ValidationEvent Handler validationEvent Handler, String targetNamespace ,
SchemaInfo schemaInfo, Boolean compileContentM odel, XmlResolver
resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, SchemaInfo
schemaInfo, XmlSchema schema, Boolean compile, XmlResolver resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, XmlReader
reader, XmlResolver resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, String uri)
at CMService.CMSer vice.XMLReading WithXDR() in
C:\Inetpub\wwwr oot\CMService\C MService.asmx.v b:line 674
What's wrong now?

Thanks in advance.

Pratibha
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #4
Yes

and just to be quite clear

the urn:BookSample. xsd in the VR.Schemas.Add( ) line, must match the
xmlns:bk="urn:B ookSample.xsd" line in the xml file.

The "urn:BookSample .xsd" is a XML Namespace, and it could be ANYTHING, even
something like
I.love.fried.gr een.tomatoes

....as long as it is consistent in the xml doc and in the VR.Schemas.Add( )
call. What you are doing in the Schemas.Add() call is associating that
namespace with a particular XSD document (BookSample.xsd , in your case).

So in fact you could use "urn:Root.x dr" as the namespace, but you would have
to use it both in the VR.Schemas.Add( ) call as well as in the xml document
itself eg

<bk:bookList xmlns:bk="urn:R oot.xdr">

The presence of the letters "xdr" in the namespace does not mean you are
actually using XDR as your schema. So using "urn:Root.x dr" as your
namespace would be a source of potential confusion if you are using XSD.
In fact the namespace is just a string, and is never evaluated. There is no
magic anywhere in any compliant XML parser that looks at a namespace like
"urn:Root.x dr" and interprets it, decides that it might be a filename and
then tries to find a file by that name. The namespace is treated only as a
string. It could just as easily be a UUID or (as above)
"I.love.fried.g reen.tomatoes".

For more on XML Namespaces please see
http://msdn.microsoft.com/library/en...namespaces.asp
-Dino
"Kirk Allen Evans [MSFT]" <ki***@online.m icrosoft.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
The targetNamespace you have still refers to the XDR schema's namespace.

Change this line:
VR.Schemas.Add( "urn:Root.x dr", Server.MapPath( "BookSample.xsd "))

to this line:
VR.Schemas.Add( "urn:BookSample .xsd", Server.MapPath( "BookSample.xsd "))
--
Kirk Allen Evans
http://blogs.msdn.com/kaevans

-- This posting is provided "AS IS" with no warranties, and confers no
rights.

"P A" <do****@xml.co. uk> wrote in message
news:uA******** *****@tk2msftng p13.phx.gbl...
OK. I am now using XSD. Here is my new xml file.

<?xml version="1.0"?>
<bk:bookList xmlns:bk="urn:B ookSample.xsd">
<book>
<title>Doe's Book</title>
<author>J Doe</author>
<year>2002</year>
</book>
<book>
<title>Sam's Book</title>
<author>Sam</author>
<year>2003</year>
</book>
</bk:bookList>

I used XSD.exe to create XSD file. This is what I got

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="bookList" targetNamespace ="urn:BookSampl e.xsd"
xmlns:mstns="ur n:BookSample.xs d" xmlns="urn:Book Sample.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata"
attributeFormDe fault="qualifie d" elementFormDefa ult="qualified" >
<xs:element name="bookList" msdata:IsDataSe t="true"
msdata:Locale=" en-GB" msdata:Prefix=" bk">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="book" form="unqualifi ed">
<xs:complexType >
<xs:sequence>
<xs:element name="title" form="unqualifi ed"
type="xs:string " minOccurs="0" />
<xs:element name="author" form="unqualifi ed"
type="xs:string " minOccurs="0" />
<xs:element name="year" form="unqualifi ed"
type="xs:string " minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

My .NET code looks like as follows:

public function XMLValidattor() as Boolean
Dim myXMLDoc As New XmlDocument()
Dim myXMLNode As XmlElement
Dim myXMLReader As XmlReader
Dim sXMLData As String

myXMLDoc.Load(S erver.MapPath(" BookSample.xml" ))

' validate xml first
Dim TR As New XmlTextReader(N ew StringReader(my XMLDoc.OuterXml ))
Dim VR As XmlValidatingRe ader = New XmlValidatingRe ader(TR)

VR.Schemas.Add( "urn:Root.x dr", Server.MapPath( "BookSample.xsd "))
VR.ValidationTy pe = ValidationType. Schema
sErrMsg = ""
AddHandler VR.ValidationEv entHandler, AddressOf
ValidationCallB ack
While VR.Read
End While
VR.Close()
TR.Close()
If sErrMsg <> "" Then
Return False
Else
Return True
End If

Public Sub ValidationCallB ack(ByVal sender As Object, ByVal args As
ValidationEvent Args)
sErrMsg = args.Message
End Sub

When I run this I get following error:

System.Xml.Sche ma.XmlSchemaExc eption: The attribute targetNamespace does
not match the designated namespace URI. An error occurred at
file:///c:/inetpub/wwwroot/CMService/BookSample.xsd, (2, 2).
at System.Xml.Sche ma.Compiler.Sen dValidationEven t(XmlSchemaExce ption
e, XmlSeverityType severity)
at System.Xml.Sche ma.Compiler.Sen dValidationEven t(String code,
XmlSchemaObject source)
at System.Xml.Sche ma.Compiler.Pre process(XmlSche ma schema, String
targetNamespace , Compositor compositor)
at System.Xml.Sche ma.Compiler.Pre process(XmlSche ma schema, String
targetNamespace )
at System.Xml.Sche ma.Compiler.Com pile(XmlSchema schema, String
targetNamespace , SchemaInfo schemaInfo)
at System.Xml.Sche ma.XmlSchema.Co mpile(XmlSchema Collection
collection, XmlNameTable nameTable, SchemaNames schemaNames,
ValidationEvent Handler validationEvent Handler, String targetNamespace ,
SchemaInfo schemaInfo, Boolean compileContentM odel, XmlResolver
resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, SchemaInfo
schemaInfo, XmlSchema schema, Boolean compile, XmlResolver resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, XmlReader
reader, XmlResolver resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, String uri)
at CMService.CMSer vice.XMLReading WithXDR() in
C:\Inetpub\wwwr oot\CMService\C MService.asmx.v b:line 674
What's wrong now?

Thanks in advance.

Pratibha
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 12 '05 #5
PA
Thank you very much for your replies. I had found out that bug soon
after posting my message. Thank you for explaining what xmlns actually
means.

Another problem.

I have now modified my XML as follows:

<?xml version='1.0'?>
<A:Address xmlns:A="urn:Te st.xsd" xmlns:B="urn:Te st_app1.xsd">
<Name>My Name</Name>
<Street>My Street</Street>
<Country>My Country</Country>
<B:PostCode>M y Post Code</B:PostCode>
</A:Address>

Just added additional xmlns:B for PostCode and reran xsd to create
XSDs.

Below are 2 xsds created using xsd.exe

Test.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NewDataSet " targetNamespace ="urn:Test.x sd"
xmlns:mstns="ur n:Test.xsd" xmlns="urn:Test .xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata"
attributeFormDe fault="qualifie d" elementFormDefa ult="qualified"
xmlns:app1="urn :Test_app1.xsd" >
<xs:import namespace="urn: Test_app1.xsd"
schemaLocation= "Test_app1. xsd" />
<xs:element name="Address" msdata:Prefix=" A">
<xs:complexType >
<xs:sequence>
<xs:element name="Name" form="unqualifi ed" type="xs:string "
minOccurs="0" />
<xs:element name="Street" form="unqualifi ed" type="xs:string "
minOccurs="0" />
<xs:element name="Country" form="unqualifi ed" type="xs:string "
minOccurs="0" />
<xs:element ref="app1:PostC ode" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NewDataSe t" msdata:IsDataSe t="true"
msdata:Locale=" en-GB" msdata:Prefix=" A">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element ref="Address" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Test_app1.xsd:
<?xml version="1.0" standalone="yes "?>
<xs:schema id="NewDataSet " targetNamespace ="urn:Test_app1 .xsd"
xmlns:mstns="ur n:Test.xsd" xmlns="urn:Test _app1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata"
attributeFormDe fault="qualifie d" elementFormDefa ult="qualified"
xmlns:app1="urn :Test_app1.xsd" >
<xs:import namespace="urn: Test.xsd" schemaLocation= "Test.xsd" />
<xs:element name="PostCode" msdata:Prefix=" B" type="xs:string " />
</xs:schema>

I have also modified my code to add both schemas in schema cache:

VR.Schemas.Add( "urn:Test.x sd", Server.MapPath( "Test.xsd") )
VR.Schemas.Add( "urn:Test_app1. xsd", Server.MapPath( "Test_app1.xsd" ))

When I run my code, I get following error:
System.Xml.Sche ma.XmlSchemaExc eption: The global element
'urn:Test_app1. xsd:PostCode' has already been declared. An error
occurred at file:///c:/inetpub/wwwroot/CMService/Test_app1.xsd, (4,
4).
at System.Xml.Sche ma.Compiler.Sen dValidationEven t(XmlSchemaExce ption
e, XmlSeverityType severity)
at System.Xml.Sche ma.Compiler.Sen dValidationEven t(String code,
String msg, XmlSchemaObject source)
at System.Xml.Sche ma.Compiler.Add ToTable(XmlSche maObjectTable
table, XmlQualifiedNam e qname, XmlSchemaObject item)
at System.Xml.Sche ma.Compiler.Pre process(XmlSche ma schema, String
targetNamespace , Compositor compositor)
at System.Xml.Sche ma.Compiler.Pre process(XmlSche ma schema, String
targetNamespace )
at System.Xml.Sche ma.Compiler.Com pile(XmlSchema schema, String
targetNamespace , SchemaInfo schemaInfo)
at System.Xml.Sche ma.XmlSchema.Co mpile(XmlSchema Collection
collection, XmlNameTable nameTable, SchemaNames schemaNames,
ValidationEvent Handler validationEvent Handler, String targetNamespace ,
SchemaInfo schemaInfo, Boolean compileContentM odel, XmlResolver
resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, SchemaInfo
schemaInfo, XmlSchema schema, Boolean compile, XmlResolver resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, XmlReader
reader, XmlResolver resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, String uri)
at CMService.CMSer vice.XMLReading WithXDR() in
C:\Inetpub\wwwr oot\CMService\C MService.asmx.v b:line 675

What's wrong now?

Thanks in advance.

Pratibha
Nov 12 '05 #6
maybe the Test_app1.xsd has already been recurseively added by the original
Add();

"PA" <pr*******@jvc. co.uk> wrote in message
news:f7******** *************** ***@posting.goo gle.com...
Thank you very much for your replies. I had found out that bug soon
after posting my message. Thank you for explaining what xmlns actually
means.

Another problem.

I have now modified my XML as follows:

<?xml version='1.0'?>
<A:Address xmlns:A="urn:Te st.xsd" xmlns:B="urn:Te st_app1.xsd">
<Name>My Name</Name>
<Street>My Street</Street>
<Country>My Country</Country>
<B:PostCode>M y Post Code</B:PostCode>
</A:Address>

Just added additional xmlns:B for PostCode and reran xsd to create
XSDs.

Below are 2 xsds created using xsd.exe

Test.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NewDataSet " targetNamespace ="urn:Test.x sd"
xmlns:mstns="ur n:Test.xsd" xmlns="urn:Test .xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata"
attributeFormDe fault="qualifie d" elementFormDefa ult="qualified"
xmlns:app1="urn :Test_app1.xsd" >
<xs:import namespace="urn: Test_app1.xsd"
schemaLocation= "Test_app1. xsd" />
<xs:element name="Address" msdata:Prefix=" A">
<xs:complexType >
<xs:sequence>
<xs:element name="Name" form="unqualifi ed" type="xs:string "
minOccurs="0" />
<xs:element name="Street" form="unqualifi ed" type="xs:string "
minOccurs="0" />
<xs:element name="Country" form="unqualifi ed" type="xs:string "
minOccurs="0" />
<xs:element ref="app1:PostC ode" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NewDataSe t" msdata:IsDataSe t="true"
msdata:Locale=" en-GB" msdata:Prefix=" A">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element ref="Address" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Test_app1.xsd:
<?xml version="1.0" standalone="yes "?>
<xs:schema id="NewDataSet " targetNamespace ="urn:Test_app1 .xsd"
xmlns:mstns="ur n:Test.xsd" xmlns="urn:Test _app1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata"
attributeFormDe fault="qualifie d" elementFormDefa ult="qualified"
xmlns:app1="urn :Test_app1.xsd" >
<xs:import namespace="urn: Test.xsd" schemaLocation= "Test.xsd" />
<xs:element name="PostCode" msdata:Prefix=" B" type="xs:string " />
</xs:schema>

I have also modified my code to add both schemas in schema cache:

VR.Schemas.Add( "urn:Test.x sd", Server.MapPath( "Test.xsd") )
VR.Schemas.Add( "urn:Test_app1. xsd", Server.MapPath( "Test_app1.xsd" ))

When I run my code, I get following error:
System.Xml.Sche ma.XmlSchemaExc eption: The global element
'urn:Test_app1. xsd:PostCode' has already been declared. An error
occurred at file:///c:/inetpub/wwwroot/CMService/Test_app1.xsd, (4,
4).
at System.Xml.Sche ma.Compiler.Sen dValidationEven t(XmlSchemaExce ption
e, XmlSeverityType severity)
at System.Xml.Sche ma.Compiler.Sen dValidationEven t(String code,
String msg, XmlSchemaObject source)
at System.Xml.Sche ma.Compiler.Add ToTable(XmlSche maObjectTable
table, XmlQualifiedNam e qname, XmlSchemaObject item)
at System.Xml.Sche ma.Compiler.Pre process(XmlSche ma schema, String
targetNamespace , Compositor compositor)
at System.Xml.Sche ma.Compiler.Pre process(XmlSche ma schema, String
targetNamespace )
at System.Xml.Sche ma.Compiler.Com pile(XmlSchema schema, String
targetNamespace , SchemaInfo schemaInfo)
at System.Xml.Sche ma.XmlSchema.Co mpile(XmlSchema Collection
collection, XmlNameTable nameTable, SchemaNames schemaNames,
ValidationEvent Handler validationEvent Handler, String targetNamespace ,
SchemaInfo schemaInfo, Boolean compileContentM odel, XmlResolver
resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, SchemaInfo
schemaInfo, XmlSchema schema, Boolean compile, XmlResolver resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, XmlReader
reader, XmlResolver resolver)
at System.Xml.Sche ma.XmlSchemaCol lection.Add(Str ing ns, String uri)
at CMService.CMSer vice.XMLReading WithXDR() in
C:\Inetpub\wwwr oot\CMService\C MService.asmx.v b:line 675

What's wrong now?

Thanks in advance.

Pratibha

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2903
by: Greg Hurlman | last post by:
I've got what I'm sure is a very simple problem. In an ASP page, I am trying to write out 4 fields from a recordset in succession: Response.Write rs("LastName") Response.Write rs("Suffix") Response.Write rs("FirstName") Response.Write rs("MiddleInitial") All fields are populated and are single terms. I would expect "LastNameSuffixFirstNameMiddleInitial" ("UserIIITestA" in my test record) to
1
2866
by: techy techno | last post by:
Hii Just wanted to know how can I decorate my texboxes and Listmenu which is called from a JS file using the following code below: document.write("<SELECT NAME='cur2' ONCHANGE='cconv1();'>"); document.write("<OPTION VALUE='0.345066110642241'>Argentina Peso </OPTION>"); document.write("<OPTION VALUE='0.790200069503053'>Australia Dollar
2
2378
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of copying/pasting everytime I change it, I figure this will be better, as I only change it once. The problem is, document.write doesn't handle multiple lines very well, so I was wondering what is the best way to do this? Maybe there is even a better...
0
1748
by: hari krishna | last post by:
hi all, My requirement is to generate xl reports throu Asp.Net without installing xl on web server computer. i am using Response object and wrtifile method as below. i dont know whether it is correct, but giving error says " file is accessed by other process cannot access" I have some logic inbetween and write the info using response.write in to html format Ex: Response.Write("<td>" & "client_no" & "</td>"). I am getting the error at :...
8
17901
by: Ben | last post by:
Hi all, Just wondering how to write (using document.write) to a table cell. I have table with 3 rows and 3 colums. I want to write from within the Javascript to say third column of a first row. How do I do it? I think one way is to write the entire table out in document.write("<table>...) but I'd like to know if it is possible to access a particular cell in a table.
4
2944
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400, like DOS, uses memory-mapped display, two bytes per character (one char byte and one attribute byte). We can get the screen offset allright, and I've written a javascript which does the math to convert the offset into row/col (i.e. left, top)...
11
16216
by: Vmusic | last post by:
Hi, I am trying to write out an array of string variables to Notepad. I can't get SendKeys to accept the string variable only literal quoted strings. I DO NOT want the hassle of writing to a file I DO NOT want to write to a report I DO NOT want to write to a form My user requires I write this array of string variables out to Notepad,
4
4319
by: cbtechlists | last post by:
I have an ASP app that we've moved from a Windows 2000 to a Windows 2003 server (sql server 2000 to sql server 2005). The job runs fine on the old servers. Part of the app takes a recordset and response.writes out comma delimited strings so that the results are opened in Excel or saved to a flat file. Basically, it looks something like this like this:
0
5883
by: kuguy | last post by:
Hi all, I'm new to the forums, so I hope this isn't in the wrong place... I have that "Software caused connection abort: socket write error" exception error that i've never meet before. Basically what im trying to do is the following: - a client connect to a server using sslsocket. - server receive the connection and reply with the first part of the data and keep the connection open. - then client receive the reply and request for...
8
7092
by: Mateusz Viste | last post by:
Hi, I am trying make some multimedia files playable from my website. So far, I am able to generate dynamically a new page containing the right <embed> section. However, when I load my script, it overwrites the current page. Is there any way I could load a new tab or window, and put the new content into it? Here is the script I am using right now:
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8638
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8365
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.