将内联XSD架构转换为XML文档

时间:2012-05-09 16:18:48

标签: xml xsd

我想知道是否有办法将xsd架构直接定义到xml文档中。 我在MSXML

上看到这样的事情
<?xml version="1.0"?>
<catalog xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
         xmlns:x="urn:book"> 
<!-- START OF SCHEMA -->
<xsd:schema targetNamespace="urn:book">
 <xsd:element name="book">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="author" type="xsd:string"/>
      <xsd:element name="title" type="xsd:string"/>
      <xsd:element name="genre" type="xsd:string"/>
      <xsd:element name="price" type="xsd:float"/>
      <xsd:element name="publish_date" type="xsd:date"/>
      <xsd:element name="description" type="xsd:string"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:string"/>
  </xsd:complexType>
 </xsd:element>
</xsd:schema>
<!-- END OF SCHEMA -->
   <x:book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications with
      XML.</description>
   </x:book>
</catalog>

标准XML中有类似的东西吗?

为了向您展示上下文,我有一个动态创建XML及其XSD的代码,并通过一个流发送XML。所以我的目标是同时为XML提供他的架构。

有什么想法吗?可能吗 ?或者在通过我的流发送我的XML之前,架构必须是Web可访问的?

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

Here is a possible solution您需要确保您的XML解析器能够处理它。

相关问题