xml-validation

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

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

How to use xsd:unique?

半城伤御伤魂 提交于 2019-12-01 23:44:54
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://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns

StAXSource not accepted by validator in JBoss EAP 6.1

ε祈祈猫儿з 提交于 2019-12-01 21:54:20
问题 Issue while Validating StAXSource in JBoss Server, What I Tried: I try to do parsing and validation at a time using StAX. As described in this example. I am able to execute the program as standalone application, but when I try it as a web application in JBoss EAP 6.1 server got below exception. Exception: java.lang.IllegalArgumentException: Source parameter of type javax.xml.transform.stax.StAXSource' is not accepted by this validator. at org.apache.xerces.jaxp.validation.ValidatorImpl

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

若如初见. 提交于 2019-12-01 20:26:06
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? XSD 1.0 Your constraint cannot be expressed in XSD 1.0. XSD 1.1 Your constraint can be expressed in XSD 1.1

Validating XML files against XSD in FireMonkey

江枫思渺然 提交于 2019-12-01 18:33:49
I am developing a cross-platform application (for Windows, Mac etc.) and for 32-bit and 64-bit machines. I have lots of XML files which I need to validate against their XSD . Is there any way of doing this in Delphi XE3? I have tried DTD validation but I'm always getting a "DTD prohibited" error. I have also tried solutions mentioned on lots of websites to resolve this error, but I've had no success. Thanks in advance. Below is the code I've used... function TForm2.ValidateXML(const xmlFile : TFileName) : boolean; var xmlDoc: TXMLDocument; begin result := false; xmlDoc := TXMLDocument.Create

Element must have no character or element information item [children], because the type's content type is empty

陌路散爱 提交于 2019-12-01 17:57:37
问题 As I work on this project I keep getting an error saying: Element 'Customer' must have no character or element information item [children], because the type's content type is empty. I am not sure why this is not working seeing I followed the notes and it looks like this: <xs:element name="Customer" type="xs:string"> <xs:complexType> <xs:attribute name="id" type="xs:integer" use="required"/> </xs:complexType> </xs:element> I know it's saying I can't have the type="xs:string" in there but then

Element must have no character or element information item [children], because the type's content type is empty

家住魔仙堡 提交于 2019-12-01 17:44:51
As I work on this project I keep getting an error saying: Element 'Customer' must have no character or element information item [children], because the type's content type is empty. I am not sure why this is not working seeing I followed the notes and it looks like this: <xs:element name="Customer" type="xs:string"> <xs:complexType> <xs:attribute name="id" type="xs:integer" use="required"/> </xs:complexType> </xs:element> I know it's saying I can't have the type="xs:string" in there but then how do I make it have to have a string? You'll need to fix your XSD's definition of Customer : Use xs