xsd-validation

Error: S4s-elt-character: Non-whitespace Characters Are Not Allowed In Schema Elements Other Than 'xs:appinfo' And 'xs:documentation'

谁说我不能喝 提交于 2019-12-02 09:22:23
问题 I have this xml-Schema: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Fussballmannschaft"> <xs:complexType> <xs:attribute name="Name" type="xs:string" /> <xs:attribute name="Stadt" type="xs:string" /> <xs:attribute name="Tabellenplatz" type="xs:string" /> <xs:element name="Spieler"> <xs:complexType> <xs:attribute name="SpielerID" type="xs:string" /> <xs:keyref name="I_D" refer="Name" /> <xs:attribute

How to declare element

不羁的心 提交于 2019-12-02 08:03:57
I'm looking for validate an XML document with xrm prefix as you can read here : I wrote the following XML Schema : </xsd:extension> </xsd:complexContent> </xsd:complexType> </xsd:schema> However, when I check my XML document, I get the following error: 'xrm:plugin' is not a valid value for 'NCName' I understand I can't put xrm: in my name, but how can I validate my xrm:plugin and xrm:header ? Because, if I try to validate my XML document, I get this error: Cannot find the declaration of element 'xrm:plugin'. xrm is a namespace prefix, an abbreviation for the namespace. As the syntax error

Limit number of elements with attribute via XSD?

孤者浪人 提交于 2019-12-02 07:14:47
There is a fragment of XML <items> <itemUID>uid-1</itemUID> <itemUID>uid-2</itemUID> <itemUID key="true">uid-3</itemUID> <itemUID>uid-4</itemUID> <itemUID>uid-5</itemUID> <itemUID key="true">uid-6</itemUID> <itemUID>uid-7</itemUID> </items> Rule : Element items can contain from 1 to unbounded elements itemUID , but only 0 or 2 or 3 elements with attribute key . Can I define this rule with XSD restrictions only? You cannot express your constraint in XSD 1.0, but in XSD 1.1, you can use xs:assert to limit the itemUID elements with key attributes to 0, 2, 3 elements as follows: <xs:assert test=

XSD schema with choice

坚强是说给别人听的谎言 提交于 2019-12-02 07:05:30
I need to validate XML request data in below array: <studyYear></studyYear> <orgID></orgID> <originID></originID> <providerID></providerID> <userOID></userOID> Problem - I have to get either ( orgID ) or ( userOID ) or ( originID and providerID ) together. 'studyYear' will always be there. How I can realise it? If need more information just write. I referenced this link to use so as to try using xs:choice inside xs:all but could not get it working. This XSD, <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="r"> <xs:complexType> <xs

XSD for varying element names

懵懂的女人 提交于 2019-12-02 07:01:36
I want to form an xsd schema for an XMl whose elements will range from z1-zx. Is it possible to define this in the xml schema without having to write out declare each of the elements. Please see below: <?xml version="1.0"?> <Zones> <Z1>Asset00</Z1> <Z2>Asset00</Z2> </Zones> I want the zones to be able to go upto Zxxx without having to declare each and every one in the XSD, is it possible to do this? Please note that I wouldn't be able to change the structure of the xml, as I am using this for another software which can only take this format. XSD 1.0 The best you can do in XSD 1.0 is allow any

Allow only other existing XML values in XSD? (xs:key and xs:keyref)

老子叫甜甜 提交于 2019-12-02 06:06:37
Let's take the following example XML: <device> <name>NiceDevice</name> <value>123</value> </device> <user> <name>user1</name> <usesDevice>NiceDevice</usesDevice> </user> <user> <name>user2</name> <usesDevice>NiceDevice</usesDevice> </user> validated by this XSD: <xs:element name="device" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <element name="name" type="xs:string"/> <element name="value" type="xs:integer"/> </xs:complexType> </xs:element> <xs:element name="user" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <element name="name" type="xs:string"/> <element name="usesDevice

Setting max length of date type as 0 in XSD

大城市里の小女人 提交于 2019-12-02 05:58:46
<xsd:simpleType name="Date10"> <xsd:restriction base="xsd:date"> <xsd:pattern value="??"/> </xsd:restriction> </xsd:simpleType> The date field shouldn't be able to accept any value in it. I want it to appear like an empty tag. How do I do that? Your requirements contradict each other. You cannot constrain an element to be a date and also to be empty concurrently because dates cannot have zero length. If you intend to allow either a date or an empty string, see Allow XSD date element to be empty string . 来源: https://stackoverflow.com/questions/47757184/setting-max-length-of-date-type-as-0-in

xs:unique how to implement into attribute?

孤街醉人 提交于 2019-12-02 03:13:01
I would like to pass uniqueness of each attribute in the list of passengers in XML file. My xml file look like this: <passengers> <passenger resnumb="872-AA"> <name>John</name> <surname>Doe</surname> <datebirth>1997-10-01</datebirth> <pricetix>1321</pricetix> <telephone>+48 128382812</telephone> <dateofbuy>2015-10-01</dateofbuy> <comment>Confirmed</comment> </passenger> <passenger resnumb="962-AA"> <name>Jack</name> <surname>Lawnmower</surname> <datebirth>1993-01-01</datebirth> <pricetix>1243</pricetix> <telephone>+48 183722842</telephone> <dateofbuy>2015-09-01</dateofbuy> <comment>Confirmed<

How to use xsd:unique?

浪子不回头ぞ 提交于 2019-12-02 01:59:47
问题 I'm creating an XML file where I would like to store my changes of a project just for fun purposes. And therefore I have written a small XML schema. The problem is that I want that each Revision 's id attribute to be unique. So I have searched through the Internet and Stack Overflow but I could not fix this problem. I'm using Visual Studio 2015 - not sure if this would be a problem. The XML Schema that I'm using is: <?xml version="1.0" encoding="utf-8"?> <xs:schema targetNamespace="http:/

How to force child element to have a value in XSD?

若如初见. 提交于 2019-12-02 01:05:05
问题 I have XML (as an example) with a segment called Type within the segment Order . The segment is a one to many, so we have something like : <Order> <Type>1</Type> <Type>2</Type> <Type>3</Type> </Order> Now the validation should be, that there always should be segment Type with value 1 in the segment Order , if not, a validation error should occur. I tried some validations, but could not get the correct result. Has someone thought on how to implement this and if this is even possible? 回答1: XSD