xsd-validation

Synchronous XML Schema Validation? .NET 3.5

◇◆丶佛笑我妖孽 提交于 2019-12-13 13:05:06
问题 I know I can validate xml against a schema using a callback method like the following, but is there a way that I can do it synchronously instead of event driven? One way I thought of would be to set a class member boolean flag IsValidated=false then call xml.Validate(ValidationEventHandler). The event handler would set IsValidated=true once it's finished. In the mean time, do a loop checking until the flag is set to true then continue. This is for .Net 3.5. public bool ValidateSchema(string

Conditional Check based on another Tag

谁说胖子不能爱 提交于 2019-12-13 08:28:39
问题 I have an xml which has a structure: <?xml version="1.0" encoding="utf-8" ?> <XYZInquiry> <Source>ABC</Source> <Info>19991234</Info> <RawData> <EmailAddress>abc@email.com</EmailAddress> </RawData> </XYZInquiry> and corresponding XSD for validation as: <?xml version="1.0" encoding="utf-8"?> <xsd:schema id="XYZInquiry" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="XYZInquiry"> <xsd:complexType> <xsd:all> <xsd:element name="Source" minOccurs="1"

XSD restriction that negates a matching string

江枫思渺然 提交于 2019-12-13 07:16:29
问题 I want my XSD to validate the contents of a string. To be specific, I want to validate that a certain string does not occur . Consider this rule, which will verify that my string occurs. Looking for all Link elements starts with this particular string: /site/example.com <xs:element name="Link" type="xs:normalizedString" minOccurs="0"> <xs:simpleType> <xs:restriction base="xs:token"> <xs:pattern value="(/site/example\.com).*"/> </xs:restriction> </xs:simpleType> </xs:element> In other words,

How do I add namespaces to an XSD?

心不动则不痛 提交于 2019-12-13 05:54:45
问题 The following is my XML and its associated XSD: XML <?xml version="1.0" encoding="UTF-8" ?> <!-- <!DOCTYPE people SYSTEM "validator.dtd"> --> <people xmlns:xsi="http://www.w3c.org/200/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="student.xsd"> <student> <name>John</name> <course>Computer Technology</course> <semester>6</semester> <scheme>E</scheme> </student> <student> <name>Foo</name> <course>Industrial Electronics</course> <semester>6</semester> <scheme>E</scheme> </student> <

XSD: How to create a complexType where elements can be in any order, and one element must occur at least once

扶醉桌前 提交于 2019-12-13 03:37:29
问题 I have a complex type like: <xs:complexType name="blocks"> <xs:sequence> <xs:element name="BlockA" type="blockA" minOccurs="1" maxOccurs="unbounded"/> <xs:element name="BlockB" type="blockB" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> <xs:attribute name="Name" type="xs:string" use="required" /> <xs:attribute name="Use" type="xs:boolean" use="required" /></xs:complexType> but it is not configured how I would like. I want it so that Elements 'BlockA' and 'BlockB' can be in ANY order

XML Schema validator error on attribute declaration

那年仲夏 提交于 2019-12-13 03:35:45
问题 I get an error on validation: Error - Line 14, 36: org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 36; s4s-elt-must-match.1: The content of 'simpleType' must match (annotation?, (restriction | list | union)). A problem was found starting at: attribute. How to resolve it? My XML fragment <CHANEL_NAME lang="RUS/MD">N4</CHANEL_NAME> And XSD: <xs:element name="CHANEL_NAME"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:length value="40"/> </xs:restriction> <xs:attribute name=

Creating multiple element name with sequence.

天涯浪子 提交于 2019-12-13 01:23:26
问题 Below is the sample xml which has multiple <rulex> that starts with sequence 1 and it can end up to many rule like <rule1> , <rule2>, <rule3> etc.... <?xml version="1.0" encoding="UTF-8"?> <AddressChange_181> <rules> <rule1> <conditions>xya</conditions> <response_path>abc</response_path> </rule1> <rule2> <conditions>xxxx</conditions> <response_path>aaaa</response_path> </rule2> <rule3> <conditions>yyyyy</conditions> <response_path>ffff</response_path> </rule3> <rule4> <conditions>zzzz<

Validate XSD in C# as if it were an XML: doesn't give expected warnings

早过忘川 提交于 2019-12-12 16:42:06
问题 The short story: I want to validate an XSD file (all XSDs being XMLs themselves) using an XSD schema, in code, and get the same warnings or errors that Visual Studio displays when opening the same XSD file in its (xml as text) editor. Visual Studio shows a warning in its xml editor (see below). My problem is, the validation done in code gives 100% success. No warning, nothing. What am I missing? The long story: The XSD file is by definition an XML file, so I'm validating my custom XSD using

Value of XML element depends on values of other elements in XSD?

落花浮王杯 提交于 2019-12-12 16:30:55
问题 As example, let's say that orange GMC trucks are worth $20,000 while white and black GMC trucks are worth $10,000. Given the following XML: <example> <car> <make value='GMC'/> <model value='Truck'/> <configuration> <color value="orange"/> <bed value="short"/> <cab value="regular"/> </configuration> <price value='10000'/> </car> </example> The XML is telling me that my sales staff is selling an orange GMC short-bed truck with a regular cab for $10,000. I want to use a schema to prevent my

XML Schema union ignore whiteSpace property

与世无争的帅哥 提交于 2019-12-12 02:55:47
问题 According to XML Schema specification of whitespace: For all datatypes ·derived· by ·union· whiteSpace does not apply directly; however, the normalization behavior of ·union· types is controlled by the value of whiteSpace on that one of the ·memberTypes· against which the ·union· is successfully validated . and for string the value of whiteSpace is preserve Based on that , the following example should not be valid as the whitespace of the string should be preserved, and the pattern should not