如何使用多个选项定义 xsd 元素? [英] how to define xsd element with multiple option?

查看:27
本文介绍了如何使用多个选项定义 xsd 元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个场景,我必须将相同的 XSD 元素用于不同的目的,以便我生成的 XML 可以包含一个或多个 p 标签,但不是全部.

I have scenario where I have to use the same XSD element for different purpose so that my resulting XML can contain either one or more p tags but not all.

   <p>some paragraph here </p>

    <p> 
        <img src = "....."   alt="......"/>
    </p>

    <p> <b> some text here <b> <p> 

     <p> ...... <g1> ........ <g2>.......<g3>........<p>

我是 XML Schema 的新手,提前致谢.

I am new to XML Schema, Thanks in advance.

推荐答案

我所做的假设是您试图通过显示不同的内容模型来定义 p 标签.首先,通过接收文本,您必须将其内容定义为混合内容.从那里,您可以使用一个重复选项列出所有其他元素,例如 img、b、g1、g2 等.

The assumption I am making is that you're trying to define the p tag, by showing its different content models. The first thing is that by taking in text, you have to define its content as mixed. From there, you could use a repeating choice that lists all other elements, such as img, b, g1, g2, etc.

我正在展示 XHTML XSD 的摘录:

I am showing an excerpt from the XHTML XSD:

  <xs:element name="p">
    <xs:complexType mixed="true">
      <xs:complexContent>
        <xs:extension base="Inline">
          <xs:attributeGroup ref="attrs" />
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:complexType name="Inline" mixed="true">
    <xs:annotation>
      <xs:documentation>
      "Inline" covers inline or "text-level" elements
      </xs:documentation>
    </xs:annotation>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:group ref="inline" />
      <xs:group ref="misc.inline" />
    </xs:choice>
  </xs:complexType>

一个很好的学习可能是查看 XTHML XSD.您可以使用 XSD 编辑器来调查与 p 标签相关的结构.

A good learning might be to look at the XTHML XSD. You could use an XSD editor to investigate the structures associated with the p tag.

这篇关于如何使用多个选项定义 xsd 元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆