xml-validation

Single-pass Read and Validate XML vs referenced XSD in C#

99封情书 提交于 2019-12-02 17:12:49
问题 I'm trying to read the data from an XML file, validating it against the XSD it suggests, into a single data structure (such as XmlDocument). I have a solution, but it requires 2 passes through the file, and I'm wondering if there's a single-pass solution. MyBooks.xml: <Books xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='books.xsd' id='999'> <Book>Book A</Book> <Book>Book B</Book> </Books> Books.xsd: <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'

XML Validation error : EntityRef: expecting';'

北慕城南 提交于 2019-12-02 17:05:32
<url> <loc>http://www.ezed.in/ezed/courseDemoIntroPage.do?courseId=COU10000000138003530&checkingCourseFrom=preLogin#.U2DcKvmSySo</loc> </url> error on line 102 at column 103: EntityRef: expecting';' Not able to figure out what could be the problem. Adriano Repetti Your URL must be escaped. & character is used in XML to insert a character reference with syntax &name; (note ; after name). Parser expects a ; but it can't find it (there are more available delimiters, this is just most common case). Solution is then escaping (how it's done depends on language you use to generate that XML file) but

Setting max length of date type as 0 in XSD

China☆狼群 提交于 2019-12-02 12:02:11
问题 <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? 回答1: 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

XSD schema with choice

折月煮酒 提交于 2019-12-02 11:43:34
问题 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. 回答1: This XSD, <?xml version="1.0" encoding=

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

前提是你 提交于 2019-12-02 10:12:31
问题 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"

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

Single-pass Read and Validate XML vs referenced XSD in C#

吃可爱长大的小学妹 提交于 2019-12-02 07:58:19
I'm trying to read the data from an XML file, validating it against the XSD it suggests, into a single data structure (such as XmlDocument). I have a solution, but it requires 2 passes through the file, and I'm wondering if there's a single-pass solution. MyBooks.xml: <Books xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='books.xsd' id='999'> <Book>Book A</Book> <Book>Book B</Book> </Books> Books.xsd: <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' elementFormDefault='qualified' attributeFormDefault='unqualified'> <xs:element name='Books'> <xs

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