xsd-validation

ADO.Net Entity Framework generate model from XSD file

风流意气都作罢 提交于 2020-01-04 02:41:32
问题 I have a rather large XSD file and I have heard that it is possible using the entity framework to connect to XML files like databases and validate them against the XSD, however I do not know how to go about doing this. So what I'm trying to do is generate a entity framework model from my XSD file, and I imagine this will generate a series of objects which will be used when opening a XML file for validation and population. 回答1: Linq2xsd will do that. http://linqtoxsd.codeplex.com/ once dead it

Nesting XML elements from different namespaces in XSD

烂漫一生 提交于 2020-01-03 19:31:27
问题 Assume that I have an XML schema definition for elements of a namespace that I would like to use as child elements of XML elements within a second namespace. As an example, suppose we have file foo.xsd : <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns="urn:foo-ns" targetNamespace="urn:foo-ns" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="foo" type="fooType"/> <xs:complexType name="fooType"> <xs:attribute name="id" use="required"/> </xs

XSD schema: How to specify the number of digits in a value?

这一生的挚爱 提交于 2020-01-03 12:59:11
问题 i want to limit the number of digits allowed in an element to 6: <AccountNumber>123456</AccountNumber> <AccountNumber>999999</AccountNumber> <AccountNumber>000000</AccountNumber> The field format specification is 6-digit, zero-padded, numeric. i read that i might want to use the totalDigits restriction, based on: totalDigits Specifies the exact number of digits allowed. Must be greater than zero So i have the simple type: <xs:simpleType name="AccountNumber"> <xs:restriction base="xs:int"> <xs

How to define mutually exclusive attributes in XSD?

泄露秘密 提交于 2020-01-03 08:22:10
问题 First the code fragment... <tag name="default" abc="10" def="20> <!-- not valid, abc and def should be mutually exclusive --> <tag name="default1" abc="10"> <!-- valid --> <tag name="default2" def="20> <!-- valid --> What I want to do... What can I put into my XSD so that @abc and @def cannot coexist as attributes on the same element? So that validation would fail if they coexisted on the same element? 回答1: XSD 1.0 Can be done with clever trick using xs:key . See @Kachna's answer. Note that

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found

无人久伴 提交于 2020-01-03 02:54:30
问题 I am trying to understand <any> element in xsd. I had two xsds. Book Catalogue.xsd <?xml version="1.0" encoding="ISO-8859-1"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified"> <xs:element name="BookCatalogue"> <xs:complexType> <xs:sequence> <xs:element name="Book" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="Title" type="xs:string" /> <xs:element name=

XSD 1.1 Conditional Type Assignment <alternative test=“”> to check if an element hasn't an attribute set?

大兔子大兔子 提交于 2020-01-02 07:10:17
问题 I would like to ask if someone knows how to make an XSD 1.1 Conditional Type Assignment check if an element hasn't an attribute using the XPath query, e.g.: <!--inline alternative type definitions --> <element name="TimeTravel" type="TravelType"> <alternative test="@direction='Future'"> <complexType> <complexContent> <restriction base="TravelType" .... <!-- some past travel related elements go here --> </complexType> </alternative> <alternative test="@direction='Past'"> <complexType>

Parser configuration exception parsing XML from class path resource

只愿长相守 提交于 2020-01-01 07:22:30
问题 I am trying to run a junit test case for testing whether the applicationcontext is initialized and it throws the following error. Is it something related to the xml or the java version. How do I fix this? org.springframework.beans.factory.BeanDefinitionStoreException: Parser configuration exception parsing XML from class path resource [tasospring-online-context.xml]; nested exception is javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org

XSD: Cannot resolve the name 'type' to a(n) 'type definition' component

不问归期 提交于 2020-01-01 04:33:04
问题 I am defining the schema but on validating it in eclipse it gives following error. src-resolve: Cannot resolve the name 'common:Name' to a(n) 'type definition' component. My schema looks like following: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://www.mycompany.com/myproject/service/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.mycompany.com/myproject/service/v1" xmlns:product="http://www.mycompany.com/otherproject/service/products/v1"

XSD/Schema validation workaround in .net core?

牧云@^-^@ 提交于 2019-12-30 08:59:25
问题 I got from https://github.com/dotnet/corefx/issues/3633, that XSD Schema Validation now is not yet supported, and planned in .Net Core 1.2.0 whose release date is Spring, 2017. However it's one of the key features of our product, so it somehow has to be supported. Now .Net Standard doesn't even have System.Xml.Schema when we thought to temporarily use full .net core, yet doesn't help. Before v1.2.0 , is there any workaround to do the xsd schema validation? 回答1: If you need some functionality

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