Groups | Blog | Home
all groups > dotnet xml > september 2005 >

dotnet xml : XSD for serialized object.


Craig
9/5/2005 7:26:08 AM

Anyone have any snippets of creating an XSD that I could validate a
serialized object against.

Specifically my problem comes from the the following serialized xml which
contains some d4p1 namespace entries.


<Attachment
d4p1:AttachmentId="297451"
d4p1:IsConfidential="false"
d4p1:FileSizeBytes="375412"
d4p1:UploadedWhen="2005-06-21T09:34:36.6549168+01:00"
d4p1:UploadedByUserId="CJH"
xmlns:d4p1="http://www.research-councils.ac.uk/ns/eps/nonschema/"
xmlns="http://www.research-councils.ac.uk/ns/common/">
<Filename>FileName.pdf</Filename>
</Attachment>

The attachment class has the following header..
<Serializable(),
System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://www.research-councils.ac.uk/ns/common/")> _


The properties that end up with d4p1 namespace are tagged like so..


<Xml.Serialization.XmlAttribute([Namespace]:="http://www.research-councils.ac.uk/ns/eps/nonschema/")> _
Public Property AttachmentId() As Integer
Get
Return Me._AttachmentId
End Get
Set(ByVal Value As Integer)
Me._AttachmentId = Value
End Set
End Property


So I'm a bit confused as to what generates that namespace prefix(sometimes
it appears as a d2p1, sometimes a d1p1), but more importantly how to bring
that into an XSD??

Any suggestions???





Pascal Schmitt
9/5/2005 5:28:44 PM
Hello!

[quoted text, click to view]

It's the XmlWriter that generates the prefixes, but you usually don't
have to care about them, in
<xml xmlns:a="foo" xmlns:b="foo">
<a:x /><b:x />
<x xmlns="foo" />
<c:x xmlns:c="foo" />
</xml>
Only the xmlns counts, not the prefix, the x-Elements are in the same
Namespace.


[quoted text, click to view]

Create an XSD for each Namespace you use, import the namespaces into the
other schemas and use references (like <attribute
ref="ns2:FileSizeBytes" />)


--
AddThis Social Bookmark Button