开发者

.Net Xml Serialize - XSD Definition for Multiple Namespaces

The following XML was generated by serializing .Net objects:

<?xml version="1.0" encoding="utf-8"?>
<Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://EPS.WebServices/WebServiceSchema" >
  <Method xmlns="http://EPS.Library/RequestSchema">PackPlacementUpdate</Method>
  <Type xmlns="http://EPS.Library/RequestSchema">开发者_如何学JAVA;PackPlacementUpdate</Type>
</Request>

I am using XSD to generate a schema. However, (I think) because there are multiple namespaces two different schema files get generated. We will be providing the XSD file externally and I'm concerned that two files will cause confusion.

Without changing the namespace of the .Net classes, is there is a way I can create a single XSD schema file and not two?

Thanks.


No!

A schema declares a targetNamespace; each schema defines elements and attributes in one namespace.

Also, there is a one-to-one mapping between .xsd (an XML schema definition file) and XML schema. You cannot define more than one schema in an .xsd file.

Therefore, if you have elements that belong in multiple namespaces, and if you want to define these elements in W3C XML Schema, then you need multiple .xsd files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜