.xsd位于http://www.w3.org/2007/app的位置?

时间:2012-01-17 21:37:59

标签: xml visual-studio-2010 xsd google-api

如果我为业务对象定义模式(使用Visual Studio 2010的XML编辑器),我该如何导入外部名称空间?我正在扩展Google Commerce Search的架构,但是如何定义名称空间前缀元素呢?例如在查询我的某些产品数据时,属于edited命名空间的一个元素app如下所示:

<app:edited>2012-01-17T17:22:05.182Z</app:edited>

Visual Studio建议我可能需要导入http://www.w3.org/2007/app命名空间的.xsd文件。我是否需要为Google产品Feed中已包含的其他命名空间找到其他.xsd文件?例如xmlns:scxmlns:scp我在哪里找到这些?或者我是否完全错了?

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="entry"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.w3.org/2005/Atom"
    elementFormDefault="qualified"
    xmlns="http://www.w3.org/2005/Atom"
    xmlns:app="http://www.w3.org/2007/app"
    xmlns:sc="http://schemas.google.com/structuredcontent/2009"
    xmlns:scp="http://schemas.google.com/structuredcontent/2009/products">

  <xs:element name="entry">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="id" type="xs:anyURI"></xs:element>
        <xs:element name="published" type="xs:date"></xs:element>
        <xs:element name="updated" type="xs:date"></xs:element>
        <xs:element name="title" type="xs:string"></xs:element>
        <!-- how do I define the <app:edited type="date" /> element here?? -->
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

3 个答案:

答案 0 :(得分:0)

您基本上想要重用其他架构中可用的定义(如edited)。为此,您需要使用xsd:import将其他模式导入到您自己的模式中。所以你必须找到那些模式。

答案 1 :(得分:0)

首先需要掌握模式。然后,您可以将它们添加到visual studio的模式存储中:

enter image description here

这意味着您在visual studio中创作的任何XML实例文档都可以从验证角度访问模式存储。

然后修改架构。首先导入新架构:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema ... xmlns:app="http://www.w3.org/2007/app" ... >
  <xs:import namespace="http://www.w3.org/2007/app" />
  ...

然后引用您要在该架构中使用的类型

<xs:element name="entry">
  <xs:complexType>
    <xs:sequence>
      ...
      <!-- how do I define the <app:edited type="date" /> element here?? -->
      <xs:element ref="app:edited" />
    </xs:sequence>
  </xs:complexType>
</xs:element>

答案 2 :(得分:0)

https://tools.oasis-open.org/version-control/browse/wsvn/cmis/trunk/SchemaProject/schema/似乎有一些架构文件可用 - 官方&#34;他们是,我不能告诉......