xml – 如何定义XSD以允许任何元素

栏目: 编程语言 · XML · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/16917703/how-to-define-xsd-to-allow-any-element

我想为参数元素定义一个xsd,这将允许我以下列方式定义参数

<parameter name="save.type" value="attribute" />

要么

<parameter name="payload">
        <p:AdderProcessRequest xmlns:p="http://wso2.org/bps/sample">
            <!--Exactly 1 occurrence -->
            <x xmlns="http://wso2.org/bps/sample">{@xvalue}</x>
            <!--Exactly 1 occurrence -->
            <y xmlns="http://wso2.org/bps/sample">{@yvalue}</y>
        </p:AdderProcessRequest>
</parameter>

在第二种方法中,参数元素中的xml内容事先是未知的,因此它可以是任何内容.

以下是我创建的xsd但它似乎不起作用.

<xs:element name="parameter" maxOccurs="unbounded" minOccurs="0">
    <xs:complexType>
        <xs:sequence>
            <xs:any minOccurs="0"/>
        </xs:sequence>
        <xs:attribute type="xs:string" name="name" use="optional"/>
        <xs:attribute type="xs:string" name="value" use="optional"/>
    </xs:complexType>
</xs:element>

任何有关这方面的帮助将不胜感激.

提前致谢

经过在这里发布的规格,我能够弄明白,所以其他人可能需要它:).您必须添加processContents =“skip”,以便不会处理内容.
<xs:element name="parameter" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
    <xs:sequence>
        <xs:any processContents="skip" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute type="xs:string" name="name" use="optional"/>
    <xs:attribute type="xs:string" name="value" use="optional"/>
</xs:complexType>

翻译自:https://stackoverflow.com/questions/16917703/how-to-define-xsd-to-allow-any-element


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Web 2.0 Architectures

Web 2.0 Architectures

Duane Nickull、Dion Hinchcliffe、James Governor / O'Reilly / 2009 / USD 34.99

The "Web 2.0" phenomena has become more pervasive than ever before. It is impacting the very fabric of our society and presents opportunities for those with knowledge. The individuals who understand t......一起来看看 《Web 2.0 Architectures》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具