xsd-validation

Difference between <xsd:all> and <xsd:sequence> in schema definition?

坚强是说给别人听的谎言 提交于 2019-12-29 13:37:05
问题 I am using xsd:all in a complex type. When I miss any mandatory elements while validating it will show all the elements. It will not display the exact missed element. But if I am use xsd:sequence I can get the exact missed element. Is there any difference between these two? xsd:sequence : XML element must be in same order. But xsd:all : XML element may be any order. 回答1: <xsd:all> specifies that the child elements can appear in any order. <xsd:sequence> specifies child elements can only

cleaner extension of elements using XSD

♀尐吖头ヾ 提交于 2019-12-25 03:13:36
问题 I defined xml schema the contains an element called 'field' and an extension to it called 'composite-field'. it is defined as following: <xs:complexType name="field"> <xs:sequence> <xs:element name="value" type="xs:string" /> </xs:sequence> </xs:complexType> <xs:complexType name="composite-Field"> <xs:complexContent> <xs:extension base="field"> <xs:sequence> <xs:element name="length" type="xs:integer" /> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> in order to use it

cleaner extension of elements using XSD

放肆的年华 提交于 2019-12-25 03:13:07
问题 I defined xml schema the contains an element called 'field' and an extension to it called 'composite-field'. it is defined as following: <xs:complexType name="field"> <xs:sequence> <xs:element name="value" type="xs:string" /> </xs:sequence> </xs:complexType> <xs:complexType name="composite-Field"> <xs:complexContent> <xs:extension base="field"> <xs:sequence> <xs:element name="length" type="xs:integer" /> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> in order to use it

Parsing/validating xml not including information about xsd using codesynthesis-xsd

我只是一个虾纸丫 提交于 2019-12-25 01:11:54
问题 I've encountered a similar problem as in this question. Basically if my xml does not contain the information about the xsd, I get errors. Given below are the xml,xsd and a sample program giving me the errors. hello.xml <?xml version="1.0"?> <hello> <greeting>Hello</greeting> <name>sun</name> <name>moon</name> <name>world</name> </hello> Had I replaced the 'hello' tag in the beginning with the following then the program would've run just fine. <hello xmlns:xsi="http://www.w3.org/2001/XMLSchema

Validate descendants of unknown XML elements via XSD?

↘锁芯ラ 提交于 2019-12-24 18:02:07
问题 My XML file looks like : <root> <template> <unknownTag> <anotherUnknownTag/> <anotherKnownTag/> <field name='price'/> </unknownTag> </template> <template> <field name='salary'/> </template> <anothorKnownTag/> </root> I want to apply regex restriction to the attribute name of the tag <field/> whether it's a child or a grandchild or a grand grandchild and so on. I have tried the following code, but the regex only applied to the element field when it's a direct child of the template tag. <xs

Nested sequence in XSD

半城伤御伤魂 提交于 2019-12-24 13:23:32
问题 I would like to validate this XML: <meta> <house> <big ... /> <little ... /> <big ... /> </house> <flat> <red ... /> <red ... /> <yellow ... /> </flat> </meta> I wrote that. <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="meta"> <xs:complexType> <xs:sequence minOccurs="0" maxOccurs="unbounded"> <xs:element name="house"> <xs:complexType> <xs:sequence minOccurs="0" maxOccurs="unbounded"> <xs:element name='big' /> <xs:element name=

Error with XSD validation: “cvc-elt.1: Cannot find the declaration of element 'xs:schema'”

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 12:33:38
问题 I am trying to use the Maven XML plugin to validate my xml against a schema but I keep having an error saying: cvc-elt.1: Cannot find the declaration of element 'xs:schema'. I guess it has to deal with my namespaces declaration, so here they are: In my XSD: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.myurl.com/schemas" targetNamespace="http://www.myurl.com/schemas" elementFormDefault="qualified" version="1.0"> In my XML: <myTag xmlns="http://www.myurl.com/schemas"

In XSD I want to specify that an element can only have whitespace content

泄露秘密 提交于 2019-12-24 11:37:30
问题 The following XSD should allow for an element called OnlyWhiteSpaceElement which has a required Name attribute, and can have only whitespace content: <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="OnlyWhiteSpaceType"> <xs:simpleContent> <xs:extension base="OnlyWhiteSpaceContentType"> <xs:attribute name="Name" type="xs:string" use="required"/> </xs:extension> </xs:simpleContent> </xs:complexType> <xs:simpleType name=

XSD conditional type assignment default type confusion?

余生颓废 提交于 2019-12-24 09:35:13
问题 I try to design a XSD with CTA. I have the following XML: <?xml version="1.0" encoding="UTF-8"?> <persons xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd"> <person version="1"> <firstname>toto</firstname> <lastname>tutu</lastname> </person> <person version="2"> <firstname>toto</firstname> <lastname>tutu</lastname> <birthdate>2017-12-18</birthdate> </person> </persons> The XSD looks like: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns

Optional/mandatory element based on non-sibling element value using xsd:assert?

别说谁变了你拦得住时间么 提交于 2019-12-24 08:46:29
问题 I am trying to apply validation of mandatory and optional on one element of XML which is depending upon value of other element. Below is XSD: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" vc:minVersion="1.1"> <xs:element name="root" type="root"></xs:element> <xs:complexType name="root"> <xs:sequence> <xs:element name="P1Message" type="p1Message"> </xs:element> </xs:sequence> </xs:complexType