简体   繁体   English

XSD 适用于仅包含文本内容的任何元素?

[英]XSD for any element with text content only?

Creating an XSD for this XML:为此 XML 创建 XSD:

  <items name="home">
    <chicken>Foo</chicken>
    <nuggets>Bar</nuggets>
    <moo>Hello World</moo>
     ....
  </item>

I don't know what elements items will contain except that the value should be a string (no further nodes).我不知道items将包含哪些元素,除了值应该是一个字符串(没有其他节点)。

Is the only way to use <any processContents="skip" /> ?是使用<any processContents="skip" />的唯一方法吗?

XSD 1.0 XSD 1.0

You can use <xsd:any processContents="skip"/> to allow any element under items , but you won't be able to further mandate anything about those elements' content models.您可以使用<xsd:any processContents="skip"/>来允许items下的任何元素,但您将无法进一步强制要求有关这些元素的内容模型的任何内容。 (You won't be able to say that those child elements can only have text in their content models.) (您不能说这些子元素只能在其内容模型中包含文本。)

You can use <xsd:any processContents="strict"/> or <xsd:any processContents="lax"/> and have control over only the content models of only those child elements you're able to foresee to define in your XSD.您可以使用<xsd:any processContents="strict"/><xsd:any processContents="lax"/>并仅控制您能够预见到在 XSD 中定义的那些子元素的内容模型.

See also也可以看看

XSD 1.1 XSD 1.1

If you wish to control the content model of child elements that you've not declared explicitly, you can combine <xsd:any processContents="skip"/> with <xsd:assert test="*[not(*)]"/> on items to insist that the children of items have no element children of their own.如果您希望控制您未明确声明的子元素的内容 model,您可以将<xsd:any processContents="skip"/><xsd:assert test="*[not(*)]"/>items上坚持items的孩子没有自己的元素孩子。

See also也可以看看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM