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


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

查看所有标签

猜你喜欢:

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

Python编程初学者指南

Python编程初学者指南

[美]Michael Dawson / 王金兰 / 人民邮电出版社 / 2014-10-1

Python是一种解释型、面向对象、动态数据类型的高级程序设计语言。Python可以用于很多的领域,从科学计算到游戏开发。 《Python编程初学者指南》尝试以轻松有趣的方式来帮助初学者掌握Python语言和编程技能。《Python编程初学者指南》共12章,每一章都会用一个完整的游戏来演示其中的关键知识点,并通过编写好玩的小软件这种方式来学习编程,引发读者的兴趣,降低学习的难度。每章最后都会......一起来看看 《Python编程初学者指南》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

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

RGB CMYK 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具