xsd-validation

cvc-complex-type.2.3: Element 'group' cannot have character [children], because the type's content type is element-only

梦想与她 提交于 2020-01-15 08:26:12
问题 I need to create XML from this XSD: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="group"> <xs:complexType> <xs:sequence> <xs:element name="person" minOccurs="5" maxOccurs="20" type="xs:string"/> </xs:sequence> <xs:attribute name="name" use="required" type="xs:string"/> </xs:complexType> </xs:element> </xs:schema> Here is the XML I've tried: <?xml version="1.0" ?> <group name="abcd"> xmlns="www.example.org" xmlns:xsi="http:/

Define simple type such as xsd:string in a new namespace?

本秂侑毒 提交于 2020-01-15 04:51:07
问题 This should be straight forward but everywhere I look it seems to have information only about complex types. Let's say that I have defined a namespace xmlns:address="http://...." . Now from what I have read it seams like I could do the following: <xsd:element name="street" type="address:sAdd"/> and then define the complex type <xsd:complexType name="sAdd"> . However, I cannot find what happens in the case of a non complex type like a xsd:string . My guess would be something like <xsd:element

different behavior for Full Framework and .NET Core for xml schema compilation

家住魔仙堡 提交于 2020-01-14 09:42:10
问题 here is my validation code: string xsdPath = "base.xsd"; XDocument doc = XDocument.Load(xmlPath); XmlSchemaSet schemas = new XmlSchemaSet(); schemas.Add("http://some.domain.org", xsdPath); schemas.Compile(); bool isValid = true; doc.Validate(schemas, (o, e) => { res.AddMessage(MessageSeverities.Error, $"{e.Severity}:{e.Message}"); isValid = false; }); if ( isValid ) { res.AddMessage( MessageSeverities.Notice, $"{formFile.FileName} is valid!"); } this code runs fine when used in a desktop app

Distribute XSD files over multiple Maven Artifacts

故事扮演 提交于 2020-01-12 03:52:51
问题 Here is a small Example of what I would like to achieve: Maven Artifact A is one of many Webservices and defines a XSD Schema with definitions for Requests and Responses. (src/main/resources/xsd) Artifact A depends on Artifact B wich is a simple JAR Project and contains a multitude of Master XSDs with low level Type descriptions. (src/main/resources/xsd) The XSDs in Artifact A use the type definitions (include) that are specified once in Artifact B. If at all possible I would really like to

How to add conditional validation in XSD :

风流意气都作罢 提交于 2020-01-11 05:11:18
问题 Existing XSD Snippet: <xs:element name="searchcriteria"> <xs:complexType> <xs:sequence> <xs:element ref="filter" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> <xs:attribute name="Request" type="RequestType" /> </xs:complexType> </xs:element> <xs:element name="filter"> <xs:complexType> <xs:sequence> <xs:element ref="filter" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> <xs:attribute name="FieldName" type="FieldNameType" /> </xs:complexType> </xs:element> ... RequestType :

XML Schema to validate XML Schemas?

夙愿已清 提交于 2020-01-09 05:26:10
问题 Does anyone know if its possible to validate an XML schema with another XML schema? If so, is there a reference implementation out there? I would like to parse a Schema doc using JAXB. 回答1: Of course. Most of the time you can just point your browser to the URL that serves as the namespace for the XML document. This also works with XML Schema: http://www.w3.org/2001/XMLSchema The XSD is linked from there. 回答2: Also check XSOM. This is what JAXB RI uses to load and process XSDs. 回答3: There are

Define an element with attribute and optional value

你说的曾经没有我的故事 提交于 2020-01-07 04:59:07
问题 How do I create an xsd that can validate either of the following two examples? <element attribute="attribute-value" /> and <element attribute="attribute-value">element-value</element> 回答1: <?xml version="1.0" encoding="utf-8"?> <xs:schema id="test" targetNamespace="http://tempuri.org/test.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/test.xsd" xmlns:mstns="http://tempuri.org/test.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" > <xs:complexType name="element_type"> <xs

Unique value across elements in XSD

与世无争的帅哥 提交于 2020-01-06 06:06:04
问题 I'm trying to enforce a unique value across an element used in multiple complexType elements. For example : <xs:element name="lmt"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element ref="lf" maxOccurs="unbounded"/> <xs:element ref="cdl" maxOccurs="unbounded"/> </xs:choice> </xs:complexType> <xs:unique name="uniquePos"> <xs:selector xpath="./*/pos"/> <xs:field xpath="."/> </xs:unique> </xs:element> <xs:element name="pos"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs

How can allowed element values depend on other element values in XSD?

北战南征 提交于 2020-01-05 04:54:13
问题 I have a following task (in simple version): Describe in XSD temperatures. There are min, max and default values. Default should be placed inside of min...max values. How to describe these things with XSD? I mean: Min_Set_Temp [ Integer between 0 and 1000 ] Max Set Temp [ Integer between 0 and 1000 ] Default_Set_Temp [ Integer between Min Set Temp and Max Set Temp] XSD start: <xs:simpleType name="tSetTemperature"> <xs:restriction base="xs:unsignedShort"> <xs:minInclusive value="0"/> <xs

Element type(long) without content

二次信任 提交于 2020-01-05 03:36:27
问题 My schema is: <xsd:element name="SetMonitor"> <xsd:complexType> <xsd:sequence> <xsd:element name="period" type="xsd:long" /> <xsd:element name="refreshrate" type="xsd:long" /> </xsd:sequence> </xsd:complexType> </xsd:element> And my xml will be: Case 1. <SetMonitor xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cb="http://schemas.cordys.com/1.0/coboc"> <period/> <refreshrate/> </SetMonitor> OR Case 2. <SetMonitor xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cb=