xsd-validation

xs:key, why is validation passing when key value is not member of key reference?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 00:45:11
问题 I am interested in defining a key constraint in my Xsd. It is my understanding that using xs:key should constrain the value used to a member of a referenced list of values. Assuming we are using the sample Xsd, <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="namespace1" xmlns:r="namespace1" elementFormDefault="qualified"> <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:element name="A" type="r:A" maxOccurs="unbounded"> <xs:keyref name="dummy" refer="r

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

How to exclude an enumeration value in XML file using XSD?

▼魔方 西西 提交于 2019-12-01 22:48:24
Is it possible to specify the value of a tag or attribute should not be like some_value ? I have a strange requirement, where the xsd isn't aware of the values being sent to it. The value of that particular tag can be a string with any value except one value ( say data_migration ). The sender should be acknowledged with the error, if that particular value is sent. Is it possible to specify this restriction? Jens Granlund I'm no regex expert, but this simpleType makes everything starting with data_migration invalid. <xs:simpleType name="notDataMigration"> <xs:restriction base="xs:string"> <xs

xs:key, why is validation passing when key value is not member of key reference?

早过忘川 提交于 2019-12-01 21:50:59
I am interested in defining a key constraint in my Xsd. It is my understanding that using xs:key should constrain the value used to a member of a referenced list of values. Assuming we are using the sample Xsd, <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="namespace1" xmlns:r="namespace1" elementFormDefault="qualified"> <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:element name="A" type="r:A" maxOccurs="unbounded"> <xs:keyref name="dummy" refer="r:pNumKey"> <xs:selector xpath="part"/> <xs:field xpath="@ref-number"/> </xs:keyref> </xs:element> <xs:element

Restrict type of xsd:any to xsd:string only?

余生长醉 提交于 2019-12-01 20:54:48
So I'm writing a new XSD and I've come across a little issue. Now I'll admit I'm not the best with these, but I would have thought what I have done should have worked but it doesn't. What I am after is I have an element called extraInfo and this element can have up to 42 child elements with any name but only of type string. Here is what I have: <xsd:element name="extraInfo" minOccurs="0" maxOccurs="1"> <xsd:annotation> <xsd:documentation></xsd:documentation> </xsd:annotation> <xsd:complexType> <xsd:sequence> <xsd:any minOccurs="0" maxOccurs="42" type="xsd:string" /> </xsd:sequence> </xsd

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

Is it possible to get the type of an XML node as it was defined in XSD?

蹲街弑〆低调 提交于 2019-12-01 19:31:33
I'm parsing an XML in python. I've an XSD schema to validate the XML. Can I get the type of a particular node of my XML as it was defined in XSD? For example, my XML (small part) is <deviceDescription> <wakeupNote> <lang xml:lang="ru">Русский</lang> <lang xml:lang="en">English</lang> </wakeupNote> </deviceDescription> My XSD is (once again a small part of it): <xsd:element name="deviceDescription" type="zwv:deviceDescription" minOccurs="0"/> <xsd:complexType name="deviceDescription"> <xsd:sequence> <xsd:element name="wakeupNote" type="zwv:description" minOccurs="0"> <xsd:unique name=

XSD custom type with attribute and restriction

你离开我真会死。 提交于 2019-12-01 18:36:37
I am developing an XSD document to validate XML Import files. Nearly all elements of the import file 'can' have an ID attribute (UPDATE). The UPDATE attribute must be limited to 4 possible values, so I have this pre-set type to use for the attribute restriction... <xs:simpleType name="MyUpDir"> <xs:restriction base="xs:string"> <xs:enumeration value="OVERWRITE"/> <xs:enumeration value="ADDONLY" /> <xs:enumeration value="NOERASE" /> <xs:enumeration value="IGNORE" /> </xs:restriction> </xs:simpleType> In addition to the attribute restrictions, each element's value is limited by a variety of pre

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

XML Signature element is not declared

橙三吉。 提交于 2019-12-01 16:31:16
I created XSD using Visual StudioXML Tools. And I use following C# code to validate XML and facing this error. Error The element is not declared ' http://www.w3.org/2000/09/xmldsig#:Signature '. So my question is how to fix it because in edit mode XML is valid 100%? Thank you! C# private void buttonValidateXML_Click(object sender, EventArgs e) { try { bool result = IsValidXml2(textBoxSignedXML.Text, textBoxXSDFile.Text, ""); rtbValidationResult.Text = result.ToString(); } catch (Exception ex) { rtbValidationResult.Text = ex.Message; } } public static bool IsValidXml2(string xmlFilePath, string