首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于代码生成的XSD文件,需要提示

用于代码生成的XSD文件,需要提示
EN

Stack Overflow用户
提问于 2011-04-07 20:35:36
回答 1查看 269关注 0票数 1

我需要为CodeSynthesis的XSD生成一个xsd文件。对于不同的响应类型,将有多个模式。正如您在示例XML文件中看到的,有些元素有type属性,有些元素没有nil属性。这些属性不提供解析信息,我已经知道类型并在xsd文件中正确设置了它们。除此之外,我不知道哪些元素是nillable。这些属性是否可以在xsd模式中以某种方式跳过,或者我应该为每个元素编写:

代码语言:javascript
复制
<xsd:complexType>
    <xsd:attribute name="type" type="TypeAttr" fixed="integer"/>
    <xsd:attribute ref="nil"/>
</xsd:complexType>

哪里

代码语言:javascript
复制
<xsd:attribute name="nil" type="xsd:boolean"/>

这是其中一个XML文件:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<account>
  <access-key>bla-bla-bla</access-key>
  <billing-error-date type="date" nil="true"></billing-error-date>
  <default-ticket-report-id type="integer">0</default-ticket-report-id>
  <default-time-zone nil="true"></default-time-zone>
  <description nil="true"></description>
  <disk-usage type="integer">38048</disk-usage>
  <flagged-for-billing-error type="boolean">false</flagged-for-billing-error>
  <force-ssl type="boolean">false</force-ssl>
  <id type="integer">1</id>
  <plan>micro</plan>
  <subdomain>companyname</subdomain>
  <text-markup>markdown,textile,plain</text-markup>
  <title>companyname</title>
  <features>
    <attachments>true</attachments>
    <ssl>false</ssl>
    <storage>512</storage>
    <time_tracking>false</time_tracking>
    <max_people>10</max_people>
    <max_pages>99999</max_pages>
    <beta>false</beta>
  </features>
  <notebook_pages>0</notebook_pages>
  <created-at>2011-02-16T13:50:09Z</created-at>
  <updated-at>2011-04-07T09:11:10Z</updated-at>
</account>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-04-08 10:17:19

我使用以下代码添加了类型和nil属性支持。

代码语言:javascript
复制
<xsd:complexType name="UString">
  <xsd:simpleContent>
    <xsd:extension base="xsd:string">
      <xsd:attribute name="type" type="TypeAttr" fixed="string" use="optional"/>
      <xsd:attribute name="nil" type="xsd:boolean" use="optional"/>
    </xsd:extension>
  </xsd:simpleContent>
</xsd:complexType>

<xsd:complexType name="UInteger">
  <xsd:simpleContent>
    <xsd:extension base="xsd:integer">
      <xsd:attribute name="type" type="TypeAttr" fixed="integer" use="optional"/>
      <xsd:attribute name="nil" type="xsd:boolean" use="optional"/>
    </xsd:extension>
  </xsd:simpleContent>
</xsd:complexType>

<xsd:simpleType name="TypeAttr">
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="datetime"/>
    <xsd:enumeration value="integer"/>
    <xsd:enumeration value="boolean"/>
  </xsd:restriction>
</xsd:simpleType>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5581101

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档