xsd-validation

Restrict complexType with attributes in XSD?

不羁的心 提交于 2019-11-29 16:12:34
I'm working with an XSD such as: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="algo"> <xs:complexType> <xs:sequence> <xs:element name="nota" type="t_algo" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="t_algo"> <xs:restriction base="xs:string"> <xs:pattern value="[1][0]|[0-9]" /> </xs:restriction> <xs:attribute name="modul" type="t_modul"/> </xs:complexType> <xs:simpleType name="t_modul"> <xs:restriction base="xs:string"> <xs:pattern

XSD 1.1 xs:alternative/xs:assert

安稳与你 提交于 2019-11-29 08:55:11
Is that possible with xsd 1.1? I want to switch the attributes depending on the "type" if its "A" or "B". How can I write an XSD 1.1 syntax for this simple problem? <?xml version="1.0"?> <node type="A" a1="asd" a2="d"/> <node type="B" b="4" /> Yes, you can define alternative types for node depending on the value of the type attribute using xs:alternative . You don't need xs:assert in this case. Your example seems so similar to the ones in the spec that I'm not quite sure why you are asking the question. For example: <xs:element name="message" type="messageType"> <xs:alternative test="@kind=

xmllint validation error “no DTD found” while using XSD

五迷三道 提交于 2019-11-29 03:32:36
I'm trying to use xmllint to check my work while developing a basic XSD i.e. XML Schema schema. However it's giving me an error Validation failed: no DTD found. What am I doing wrong? My xmllint command: xmllint --noout --valid --schema simple.xsd lucas-basic.xml lucas-basic.xml:5: validity error : Validation failed: no DTD found ! > ^ lucas-basic.xml validates Test XSD file: <?xml version = "1.0" encoding = "UTF-8"?> <!--Generated by XML Authority. Conforms to w3c http://www.w3.org/2001/XMLSchema--> <xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema"> <xsd:element name = "vehicles">

Setting minOccurs and maxOccurs in XSD based on value of other XML field?

醉酒当歌 提交于 2019-11-28 12:59:41
I have an XSD to validate an XML file. The structure is as follows: <root> <child> <size>2</size> <childElement>Element 1</childElement> <childElement>Element 2</childElement> </child> </root> The number of childElement s is dependent on the size provided i.e. if size was set as 3, not more than 3 childElement s can be added. I have tried using xs:alternative but it does not seem to work: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:element name="child" minOccurs="1" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs

Enforce further constraints on xsd:any?

白昼怎懂夜的黑 提交于 2019-11-28 10:36:00
问题 I have an XSD 1.0 sequence that defines a set of elements, some of which may be optional but none of which can occur more than once, and which also ends with an <xsd:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax"/> tag in order to enable users to add their own data elements in the easiest possible way when programmatically exporting conforming XML (i.e. ideally without requiring them to define their own namespace/XSD). When processing XML that users generate,

Dynamic enumeration restriction using XSD 1.1

随声附和 提交于 2019-11-28 10:16:22
I am trying to create a schema definition using XSD 1.1 in which outcome of one element is dependent on other. For example, I have drop-down for list of countries and list of states for each country. When a person selects a country, only the states of that country can be selected. The pseudo-code of what I am trying to attain looks something like this. <xs:schema xmlns:ie="http://www.interviewexchange.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="country"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="USA" /> <xs

XSD allowing both simpleType and complexType content for same element?

隐身守侯 提交于 2019-11-28 10:04:40
问题 I have a situation where I have different XMLs that will have different types of properties. Sometimes the element HEADER could have just a node or some XMLs could have elements within the HEADER node and values inside. Example 1 ( HEADER with just text): <Details HeaderLabel="DETAILS"> <HEADER Label="Header">2.5%</HEADER> </Details> Example 2 ( HEADER with two child elements): <Details HeaderLabel="DETAILS"> <HEADER Label="Header"> <HEAD Label="H1a">2.88%</HEAD> <HEAD Label="H2b">3.24%</HEAD

Restrict complexType with attributes in XSD?

。_饼干妹妹 提交于 2019-11-28 09:46:14
问题 I'm working with an XSD such as: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="algo"> <xs:complexType> <xs:sequence> <xs:element name="nota" type="t_algo" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="t_algo"> <xs:restriction base="xs:string"> <xs:pattern value="[1][0]|[0-9]" /> </xs:restriction> <xs:attribute name="modul" type="t_modul

XSD 1.1 xs:alternative/xs:assert

半世苍凉 提交于 2019-11-28 02:11:22
问题 Is that possible with xsd 1.1? I want to switch the attributes depending on the "type" if its "A" or "B". How can I write an XSD 1.1 syntax for this simple problem? <?xml version="1.0"?> <node type="A" a1="asd" a2="d"/> <node type="B" b="4" /> 回答1: Yes, you can define alternative types for node depending on the value of the type attribute using xs:alternative . You don't need xs:assert in this case. Your example seems so similar to the ones in the spec that I'm not quite sure why you are

XML validation (different child tags) based on attribute value

一世执手 提交于 2019-11-28 02:08:04
问题 I am writing an dashboard designer that will create widgets based on xml values. like <dashboard> <widget type="chart"> </widget> </dashboard> I want to change the tags inside the <widget> based on the value of @type for example if type="chart" Then it should allow different tags <dashboard> <widget type="chart"> <title text="Chart Title"></title> <plotOptions> <plotOptions> <pie showInLegend="true" shadow="false" innerSize="50%"> <dataLabels color="#fff" distance="-20" format="{point