gpt4 book ai didi

xsd - 具有固定属性的固定元素的 XML 模式?

转载 作者:行者123 更新时间:2023-12-04 14:17:09 25 4
gpt4 key购买 nike

什么是正确的 XML Schema 1.0 声明?

<notice xml:lang="en">Banana banana banana</notice>

在哪里:
  • xml:lang 属性是强制性的
  • 值“en”是固定且强制的
  • 通知内容为简单文字。
  • 通知的内容是固定的(如上)和强制性的?

  • 我最好(但错误)的努力是以下片段:
    <xs:element name="notice" use="required" fixed="Banana banana banana">
    <xs:complexType>
    <xs:simpleContent>
    <xs:extension>
    <xs:attribute ref="xml:lang" use="required" fixed="en"/>
    </xs:extension>
    </xs:simpleContent>
    </xs:complexType>
    </xs:element>

    最佳答案

    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xs:element name="notice" type="notice"/>
    <xs:complexType name="notice">
    <xs:simpleContent>
    <xs:extension base="CONTENT">
    <xs:attribute ref="xml:lang" use="required" fixed="en"/>
    </xs:extension>
    </xs:simpleContent>
    </xs:complexType>
    <xs:simpleType name="CONTENT">
    <xs:restriction base="xs:string">
    <xs:enumeration value="Banana banana banana"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:schema>

    关于xsd - 具有固定属性的固定元素的 XML 模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9695635/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com