0

我实际上正在使用为他的配置文件实现 XSD 架构的 Magento 2 框架。
我有一个文件flow.xml,开发人员在其中放置了他的 XML 映射和一些配置。
我的目标是强制使用两个节点mappingoptions开发人员可以在其中编写他想要的任何 XML 结构。

这是我的实际文件:

# File flow.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Dnd_Flow:etc/flow.xsd">
    <mapping>
        // Here can be other nodes on X levels (or simply string = bonus) 
    </mapping>
    <options>
        // Here can be other nodes on X levels (or simply string = bonus) 
    </options>
</config>

我的 XSD 文件如下所示:

# File flow.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="config" type="configType" />

    <xs:complexType name="configType">
        <xs:sequence>
            <xs:element type="xs:????" name="mapping" minOccurs="0" />
            <xs:element type="xs:????" name="options" minOccurs="0" />
        </xs:sequence>
    </xs:complexType>
</xs:schema>

我尝试了mixedvalues, xs:all, differents 元素类型,但没有结果。

这可能是小菜一碟,但我是 XSD 模式的新手,我正在努力寻找解决方案,让我的两个节点中可以有所有东西。

谢谢你,
马修。

4

1 回答 1

1

您想要的类型是xsd:anyType,您可以通过名称获得:

<xs:element type="xs:anyType" name="mapping" minOccurs="0" />
<xs:element type="xs:anyType" name="options" minOccurs="0" />

或通过省略type属性:

<xs:element name="mapping" minOccurs="0" />
<xs:element name="options" minOccurs="0" />
于 2016-04-08T00:26:13.100 回答