xsd-validation

How to ignore the validation of Unknown tags?

跟風遠走 提交于 2019-11-28 00:14:47
问题 One more challenge to the XSD capability, I have been sending XML files by my clients, which will be having 0 or more undefined or [call] unexpected tags (May appear in hierarchy). Well they are redundant tags for me .. so I have got to ignore their presence, but along with them there are some set of tags which are required to be validated. This is a sample XML: <root> <undefined_1>one</undefined_1> <undefined_2>two</undefined_2> <node>to_be_validated</node> <undefined_3>two</undefined_3>

xmllint validation error “no DTD found” while using XSD

天涯浪子 提交于 2019-11-27 21:40:24
问题 I'm trying to use xmllint to check my work while developing a basic XSD i.e. XML Schema schema. However it's giving me an error Validation failed: no DTD found. What am I doing wrong? My xmllint command: xmllint --noout --valid --schema simple.xsd lucas-basic.xml lucas-basic.xml:5: validity error : Validation failed: no DTD found ! > ^ lucas-basic.xml validates Test XSD file: <?xml version = "1.0" encoding = "UTF-8"?> <!--Generated by XML Authority. Conforms to w3c http://www.w3.org/2001

stax xml validation

被刻印的时光 ゝ 提交于 2019-11-27 18:50:39
I know I can validate xml-file when I use sax. But can I validate when I use Stax? There are two ways of XML validation possible with SAX and DOM: validate alone - via Validator.validate() validate during parsing - via DocumentBuilderFactory.setSchema() and SAXParserFactory.setSchema() With StAX, validation is possible , but only the first way of doing it. You can try something like this: import javax.xml.validation.*; import javax.xml.transform.stax.*; import javax.xml.stream.*; import javax.xml.*; import java.io.*; public class StaxValidation { public static void main (String args[]) throws

XML Schema to validate XML Schemas?

≡放荡痞女 提交于 2019-11-27 15:21:03
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. 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. Also check XSOM . This is what JAXB RI uses to load and process XSDs. There are two versions of the XML Schema Definition Language (XSD): 1.0 and 1.1. Version 1.0 was released in 2001 and version 1

Why does XSD validation expect {element} with braces rather than just element?

我是研究僧i 提交于 2019-11-27 08:15:30
问题 When I try to validate the below XML against the below XSD I get the following error: cvc-complex-type.2.4.a: Invalid content was found starting with element >'personal'. One of '{personal} expected. XML <main xmlns = "http://www.example.com" xmlns:xsi = "https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "main.xsd"> <personal> <full-name>John Smith</full-name> <contact> <street-address>12345 Example Street</street-address> <city>Somewhere</city> <state>EX</state> <postal-code

Setting minOccurs and maxOccurs in XSD based on value of other XML field?

五迷三道 提交于 2019-11-27 07:27:36
问题 I have an XSD to validate an XML file. The structure is as follows: <root> <child> <size>2</size> <childElement>Element 1</childElement> <childElement>Element 2</childElement> </child> </root> The number of childElement s is dependent on the size provided i.e. if size was set as 3, not more than 3 childElement s can be added. I have tried using xs:alternative but it does not seem to work: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="root"> <xs:complexType> <xs

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

XSD element substitution group example?

ぐ巨炮叔叔 提交于 2019-11-27 03:27:04
问题 I'd like to be able to specify single choice type for multiple extending types. For example, say we have the sea, in the sea there are many kinds of fishes. So in XML I will write: <Sea name="Atlantic Ocean"> <Tuna name="tuna1" /> <Carp name="carp1" /> <Carp name="carp2" /> <Tuna name="tuna2" /> <Salmon name="salmon1" /> </Sea> XSD <xs:complexType name="Fish"> </xs:complexType> <xs:complexType name="Salmon"> <xs:complexContent> <xs:extension base="Fish"> </xs:extension> </xs:complexContent> <

Does JAXB support xsd:restriction?

我怕爱的太早我们不能终老 提交于 2019-11-26 22:14:46
<xs:element name="age"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="120"/> </xs:restriction> </xs:simpleType> </xs:element> So I want it to get converted to Java code like this: public void setAge(int age){ if(age < 0 || age > 120){ //throw some exception } //setting the age as it is a valid value } Is it possible in JAXB? Had seen some WebService Client stub generator doing this maybe axis2 webservice but not sure. The JAXB (JSR-222) specification does not cover generating fail fast logic into the domain model. A common practice now

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:/