xsd

XSD: difference between Element and Attribute

吃可爱长大的小学妹 提交于 2019-12-29 17:53:05
问题 I'm new to XSD, and I'm quite confused as to when to use attribute, and when to use element? Why cant we specify minOccurs and maxOccurs in attribute? Also, why is it we cannot specify use="required" in element? 回答1: An element is an XML element - a opening tag, some content, a closing tag - they are the building blocks of your XML document: <test>someValue</test> Here, "test" would be an element. Attributes is an additional info on a tag - it's an "add-on" or an extra info on an element, but

XSD: difference between Element and Attribute

不羁的心 提交于 2019-12-29 17:53:00
问题 I'm new to XSD, and I'm quite confused as to when to use attribute, and when to use element? Why cant we specify minOccurs and maxOccurs in attribute? Also, why is it we cannot specify use="required" in element? 回答1: An element is an XML element - a opening tag, some content, a closing tag - they are the building blocks of your XML document: <test>someValue</test> Here, "test" would be an element. Attributes is an additional info on a tag - it's an "add-on" or an extra info on an element, but

Difference between <xsd:all> and <xsd:sequence> in schema definition?

怎甘沉沦 提交于 2019-12-29 13:37:18
问题 I am using xsd:all in a complex type. When I miss any mandatory elements while validating it will show all the elements. It will not display the exact missed element. But if I am use xsd:sequence I can get the exact missed element. Is there any difference between these two? xsd:sequence : XML element must be in same order. But xsd:all : XML element may be any order. 回答1: <xsd:all> specifies that the child elements can appear in any order. <xsd:sequence> specifies child elements can only

Difference between <xsd:all> and <xsd:sequence> in schema definition?

坚强是说给别人听的谎言 提交于 2019-12-29 13:37:05
问题 I am using xsd:all in a complex type. When I miss any mandatory elements while validating it will show all the elements. It will not display the exact missed element. But if I am use xsd:sequence I can get the exact missed element. Is there any difference between these two? xsd:sequence : XML element must be in same order. But xsd:all : XML element may be any order. 回答1: <xsd:all> specifies that the child elements can appear in any order. <xsd:sequence> specifies child elements can only

xml schema maxOccurs = unbounded within xs:all

烈酒焚心 提交于 2019-12-29 09:12:26
问题 Is it possible to have a combination of xs:all and xs:sequence ? I've have a xml structure with an element probenode which consist of the elements name, id, url, tags, priority, statuws_raw, active. And a combination of device and group. device and group can occur zero or more times... the solution below doesn't work because it is not allowed to use unbounded for an element. within an all group. <xs:complexType name="probenodetype"> <xs:all> <xs:element name="name" type="xs:string" /> <xs

How to make a schema for an unordered list where some occur once, some many times

自作多情 提交于 2019-12-29 08:06:45
问题 This is a similar question to How to create a schema for an unordered list of XML nodes, with occurrence constraints, but actually slightly simpler. However I am having great trouble understanding the logic behind sequences and choices (and especially when they are nested into sequences of choices or choices of sequences), and although I've studied it for a long time I can't understand how the example above works. What I need is schema for a list of nodes, ChildA and ChildB, whereby ChildA

In .NET XML deserialization, how can I allow polymorphic use of Array types?

落爺英雄遲暮 提交于 2019-12-29 08:02:03
问题 Example Schema: <complexType name="Dog">...</complexType> <complexType name="Cat">...</complexType> <complexType name="ArrayOfDog"> <sequence> <element name="Dog" type="tns:Dog minOccurs="0" maxOccurs="unbounded" /> </sequence> </complexType> <complexType name="Foo"> <sequence> <element name="Bar" type="string"/> <element name="Baz" type="anyType"/> </sequence> </complexType> Running this through .NET's wsdl.exe generates code similar to the following: [System.Xml.Serialization

In .NET XML deserialization, how can I allow polymorphic use of Array types?

我们两清 提交于 2019-12-29 08:01:28
问题 Example Schema: <complexType name="Dog">...</complexType> <complexType name="Cat">...</complexType> <complexType name="ArrayOfDog"> <sequence> <element name="Dog" type="tns:Dog minOccurs="0" maxOccurs="unbounded" /> </sequence> </complexType> <complexType name="Foo"> <sequence> <element name="Bar" type="string"/> <element name="Baz" type="anyType"/> </sequence> </complexType> Running this through .NET's wsdl.exe generates code similar to the following: [System.Xml.Serialization

Define an XSD element which can be a dateTime or empty with an attribute

若如初见. 提交于 2019-12-29 07:38:14
问题 My question is almost exactly the same as this one, but for a xs:dateTime type rather than a user defined element. An element in my XML (which I do not create) can look like: <parent> ... <start>2012-01-01T00:00:00.000</start> <end>2013-01-01T00:00:00.000</end> ... </parent> -or- <parent> ... <start reference="a string" /> <end reference="a string" /> ... </parent> In other words, within the parent element, the "start" and "end" fields can contain either a xs:dateTime value, or will be empty

Validate XML against XSD in a single method

怎甘沉沦 提交于 2019-12-29 04:38:08
问题 I need to implement a C# method that needs to validate an XML against an external XSD and return a Boolean result indicating whether it was well formed or not. public static bool IsValidXml(string xmlFilePath, string xsdFilePath); I know how to validate using a callback. I would like to know if it can be done in a single method, without using a callback. I need this purely for cosmetic purposes: I need to validate up to a few dozen types of XML documents so I would like to make is something