xml扩展类型和用户定义

时间:2011-03-23 17:15:05

标签: xml xsd

我有一个xml文档,根据其对某个节点“level”的模式定义,只允许预定义的值列表(如果没有错误,也称为枚举)。此预定义值适用于某个国家/地区,但如果我们更改国家/地区,则值可能会更改。

为此,“level”节点允许(并且这里开始我的怀疑)属性“userDefined”和子节点如<extension>,我相信是通过这个<extension>节点或者可能是用户定义的attr我将能够指定其他值,从而验证文档。

xsd文件在这里:http://utdanning.no/schemas/CDM/2.1/CDM.xsd和xml示例文件

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CDM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://utdanning.no/schemas/CDM/2.1/CDM.xsd">
    <orgUnit>
        <orgUnitID>217</orgUnitID>
        <orgUnitName>Contoso Inc [TEST PURPOSES ONLY]</orgUnitName>
        <webLink>
            <href>http://www.google.com</href>
        </webLink>
        <course>
            <courseID>341</courseID>
            <courseCode>FWTEST2222222</courseCode>
            <courseName>Another field course test imported</courseName>
            <courseDescription>Testing purposes only test teste teste</courseDescription>
            <level level="other_value"/><!--This is where i want to add a diff value other than the allowed list: vgs, folkehogskole, bachelor, master, phd, fagskole, evu, aarsstudium -->
            <credits ECTScredits="45"/>
            <admissionInfo/>
            <teachingPlace>
                <adr>
                  <country>NORWAY</country>
                </adr>
            </teachingPlace>
            <formOfTeaching>Field course</formOfTeaching>
            <instructionLanguage>Norske</instructionLanguage>
        </course>
    </orgUnit>
</CDM>

1 个答案:

答案 0 :(得分:1)

此架构不允许“level”属性中的任意值。无法扩展有效值集。