xsd-1.0

Require element based on position and attribute value

送分小仙女□ 提交于 2021-02-10 20:22:36
问题 I have the following XSD (part of the XSD) <xs:element name="sourceValue" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:normalizedString"> <xs:attribute name="label" type="xs:normalizedString" use="required"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> In my XML I have: <?xml version="1.0" encoding="UTF-8"?> <Record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="assertion.xsd">

Require element based on position and attribute value

不打扰是莪最后的温柔 提交于 2021-02-10 20:19:23
问题 I have the following XSD (part of the XSD) <xs:element name="sourceValue" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:normalizedString"> <xs:attribute name="label" type="xs:normalizedString" use="required"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> In my XML I have: <?xml version="1.0" encoding="UTF-8"?> <Record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="assertion.xsd">

Unique value across elements in XSD

与世无争的帅哥 提交于 2020-01-06 06:06:04
问题 I'm trying to enforce a unique value across an element used in multiple complexType elements. For example : <xs:element name="lmt"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element ref="lf" maxOccurs="unbounded"/> <xs:element ref="cdl" maxOccurs="unbounded"/> </xs:choice> </xs:complexType> <xs:unique name="uniquePos"> <xs:selector xpath="./*/pos"/> <xs:field xpath="."/> </xs:unique> </xs:element> <xs:element name="pos"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs

XML Schema: Child element type based on parent attribute 'type'

ⅰ亾dé卋堺 提交于 2020-01-04 05:45:10
问题 I have an XML document like below: <operation name="func"> <param name="a" type="string">up</param> <param name="b" type="integer">5</param> <param name="c" type="CustomList"> <list> <idx>0</idx> <name>ZZZZ</name> <value>0.5464</value> </list> <list> <idx>1</idx> <name>YYYY</name> <value>0.464</value> </list> .... </param> </operation> and I wrote an XSD to restrict it: <xs:complexType name="CustomListNode"> <xs:sequence> <xs:element name="idx" type="xs:integer" /> <xs:element name="name"

XML Schema for a fixed element with a fixed attribute?

让人想犯罪 __ 提交于 2019-12-23 09:31:43
问题 What would be the correct XML Schema 1.0 declaration for a <notice xml:lang="en">Banana banana banana</notice> where: The xml:lang attribute is compulsory The value "en" is fixed and compulsory The content of notice is simple text. The content of notice is fixed (as above) and compulsory? My best (but wrong) effort is the following fragment: <xs:element name="notice" use="required" fixed="Banana banana banana"> <xs:complexType> <xs:simpleContent> <xs:extension> <xs:attribute ref="xml:lang"

What is the typical maximum length of values of the XML/XSD ID/IDREF types?

孤人 提交于 2019-12-22 12:36:15
问题 The W3C XSD 1.0 Part 2: Datatypes specification refers to the W3C XML 1.0 specification for the definition of the ID and IDREF types, but none of these documents defines any constraints on the length of values of these types. However, it seems that some XML editors implement length limitations for these types. Also, some Web browsers seem to implement length limitations, e.g. on the "id" attribute of the HTML Hx elements (which is defined as XML ID type in both HTML 4 and XHTML 1.1). Are

XSD “version” attribute semantics

杀马特。学长 韩版系。学妹 提交于 2019-12-13 13:17:28
问题 <schema xmlns="http://www.w3.org/2001/XMLSchema" ... version="xxx"> The XSD specification https://www.w3.org/TR/xmlschema11-1/#declare-schema does not specify the semantics for the version attribute: The other attributes ( id and version ) are for user convenience, and this specification defines no semantics for them. Nor does that the W3C versioning guide https://www.w3.org/TR/xmlschema-guide2versioning/. Is there a consensus arising whether this attribute should be used for specifying the

XSD Validation : Namespace causing root element to not be found

孤人 提交于 2019-12-11 05:52:25
问题 I'm trying to a update an existing schema to use its own namespace, so I can import it into another schema later and make it clear the types being used are from the imported schema. I tried changing the default and targeted namespaces but it's caused the schema validation to break and hide the root node. From what I can see i've hidden my root element in another namespace but I am unsure how to configure this to get my desired result. Here is a basic example of what I've tried XML <Parent Id=

Different sub-elements depending on attribute/element value

 ̄綄美尐妖づ 提交于 2019-12-07 17:07:27
问题 Another XSD question - how can I achieve that the following XML elements are both valid: <some-element> <type>1</type> <a>...</a> </some-element> <some-element> <type>2</type> <b>...</b> </some-element> The sub-elements ( either <a> or <b> ) should depend on the content of <type> (could also be an attribute). It would be so simple in RelaxNG - but RelaxNG doesn't support key integrity :( Is there a way to implement this in XSD? Note: XML schema version 1.1 supports <xs:alternative> , which

XML Schema to restrict one field based on another

…衆ロ難τιáo~ 提交于 2019-12-07 07:10:23
问题 I have the following schema, which I use to ensure that a person's PhoneNumber and PhoneNumberType (Home, Work, etc.) is not longer than 10 characters. However, I want to improve this schema so that PhoneNumberType is not required if a PhoneNumber is not provided, but is required if the PhoneNumber is provided. Is there a way to do this in XML Schema 1.0? I am aware this could be accomplished in XML Schema 1.1 using <xs:assert/> , but unfortunately I am stuck with XML Schema 1.0. <?xml