【问题标题】:Where is .xsd located for http://www.w3.org/2007/app?http://www.w3.org/2007/app 的 .xsd 位于何处?
【发布时间】:2012-02-12 16:42:45
【问题描述】:

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

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

Visual Studio 建议我可能需要为 http://www.w3.org/2007/app 命名空间导入 .xsd 文件。我是否需要为已包含在 Google 产品供稿中的其他命名空间查找其他 .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>

【问题讨论】:

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


    【解决方案1】:

    您首先需要掌握架构。然后你可以将它们添加到 Visual Studio 的模式存储中:

    这意味着您在 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>
    

    【讨论】:

    • 回到我原来的问题——w3.org/2007/app 的 .xsd 文件在哪里?我必须自己做吗?它是否托管在 w3.org 上?
    • 看起来 Atom 发布协议有一个 RelaxNG 紧凑模式,没有 XSD 模式。所以在这种情况下你不走运。您可以使用 Trang 之类的工具将 RelaxNG 架构转换为 XSD:thaiopensource.com/relaxng/trang.html
    • http://www.w3.org/2007/app 的 RelaxNG 紧凑模式在哪里?您在哪里找到这些信息?
    • RelaxNG Compact 模式是本文档的附录:tools.ietf.org/html/rfc5023
    • 如果我没有正确表达问题或完全误解了问题,我深表歉意,但是 1) 我会尝试的 RelaxNG 架构 file转换或 2) http://www.w3.org/2007/app 架构 file 我会尝试导入?听起来问题 1) 会为问题 2) 创建文件。我错过了什么吗?
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      https://tools.oasis-open.org/version-control/browse/wsvn/cmis/trunk/SchemaProject/schema/ 上似乎有一些架构文件可用——它们有多“官方”,我不知道......

      【讨论】:

        猜你喜欢
        • 2013-06-10
        • 1970-01-01
        • 2017-01-27
        • 1970-01-01
        • 1970-01-01
        • 2011-09-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多