xsd-1.1

XML validation (different child tags) based on attribute value

一世执手 提交于 2019-11-28 02:08:04
问题 I am writing an dashboard designer that will create widgets based on xml values. like <dashboard> <widget type="chart"> </widget> </dashboard> I want to change the tags inside the <widget> based on the value of @type for example if type="chart" Then it should allow different tags <dashboard> <widget type="chart"> <title text="Chart Title"></title> <plotOptions> <plotOptions> <pie showInLegend="true" shadow="false" innerSize="50%"> <dataLabels color="#fff" distance="-20" format="{point

How to validate XML against XSD 1.1 in Java?

感情迁移 提交于 2019-11-27 22:11:44
What is the best way to validate XML files against XML Schema 1.1 in Java? I took the code from this tutorial and changed the line where it looks up the factory to use XML Schema 1.1 as I have seen in this code example from the Xerces FAQ . This is my code: import java.io.File; import java.io.IOException; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; import org.xml.sax.SAXException; public class XSDValidator { private static void

Dynamic enumeration restriction using XSD 1.1

我的未来我决定 提交于 2019-11-27 03:30:58
问题 I am trying to create a schema definition using XSD 1.1 in which outcome of one element is dependent on other. For example, I have drop-down for list of countries and list of states for each country. When a person selects a country, only the states of that country can be selected. The pseudo-code of what I am trying to attain looks something like this. <xs:schema xmlns:ie="http://www.interviewexchange.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element

Require XML element in XSD when another element has certain value?

血红的双手。 提交于 2019-11-26 20:57:28
I need a required attribute or element only if a specific value of an enumeration is chosen. Example below: <xs:element name="TYPE" type="TestEnum" /> <!-- // This Element should only required when TYPE = INTERNATIONAL --> <xs:element name="IBAN"/> </xs:complexType> <xs:simpleType name="TestEnum"> <xs:restriction base="xs:string"> <xs:enumeration value="NATIONAL"/> <xs:enumeration value="INTERNATIONAL"/> </xs:restriction> </xs:simpleType> XSD 1.1 Here's how use xs:assert to make IBAN be mandatory when TYPE = 'INTERNATIONAL' : <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http:/

How to validate XML against XSD 1.1 in Java?

自古美人都是妖i 提交于 2019-11-26 16:35:14
问题 What is the best way to validate XML files against XML Schema 1.1 in Java? I took the code from this tutorial and changed the line where it looks up the factory to use XML Schema 1.1 as I have seen in this code example from the Xerces FAQ. This is my code: import java.io.File; import java.io.IOException; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation

Require XML element in XSD when another element has certain value?

我只是一个虾纸丫 提交于 2019-11-26 04:27:42
问题 I need a required attribute or element only if a specific value of an enumeration is chosen. Example below: <xs:element name=\"TYPE\" type=\"TestEnum\" /> <!-- // This Element should only required when TYPE = INTERNATIONAL --> <xs:element name=\"IBAN\"/> </xs:complexType> <xs:simpleType name=\"TestEnum\"> <xs:restriction base=\"xs:string\"> <xs:enumeration value=\"NATIONAL\"/> <xs:enumeration value=\"INTERNATIONAL\"/> </xs:restriction> </xs:simpleType> 回答1: XSD 1.1 Here's how use xs:assert to

How to make type depend on attribute value using Conditional Type Assignment

◇◆丶佛笑我妖孽 提交于 2019-11-26 00:30:01
问题 I have an XML file like this <listOfA> <a type=\"1\"> <name></name> <surname></surname> </a> <a type=\"2\"> <name></name> <id></id> </a> </listOfA> I\'d like to make an XSD, so that if the value of the attribute \"type\" is 1, the name and surname elements must be present, and when it\'s 2, name and id must be there. I tried to generate the XSD in XSD schema generator, but it made the surname and id element minOccurs=0. How could I make it work? 回答1: You can do this using XSD 1.1's