FAQ Database Discussion Community


Specify type for an element that must have at least one child element

xml,xsd,xml-validation
The element elements must contain at least the element element1 or element2, but each of them at most once. For this I've specified the following XML Schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="elements" type ="elementsType"/> <xs:complexType name="elementsType"> <xs:choice> <xs:sequence> <xs:element name="element1" type="xs:string" minOccurs="0"/> <xs:element name="element2"...

How to correct XSD so XML validates?

xml,xsd,xml-validation
In my application, I have the XSDs shown below. These are modifications of existing XSDs in my application and they are my starting point. GPSInformation.xsd <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns="aNamespace" elementFormDefault="qualified" targetNamespace="aNamespace" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="gps"> <xs:annotation> <xs:documentation>An instance of this class contains all of the information we want to retrieve...

Validate optional XML element in XSD

xml,xsd,xml-validation
How would I validate RequiresPaidSubscription only when provided? <xs:element name="RequiresPaidSubscription" minOccurs="0" > <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="True|true|False|false|0|1"/> </xs:restriction> </xs:simpleType> </xs:element> The minOccurs="0" doesn't seem to do anything for me with the above....

XSD regular expression restriction on xsd:string

regex,xml,xsd,xml-validation
What would be the regular expression if I want a sequence of integers separated with at least one blank? Something like "123 098"....

Set XSD duplicate constraint at document-level

xml,xsd,xml-validation
I have the following XML: <Movies> <Title> <Platform>Hulu</Platform> <PlatformID>50019855</PlatformID> <!-- Reject xml based on duplicate PlatformID --> <UnixTimestamp>1431892827</UnixTimestamp> </Title> <Title> <Platform>Hulu</Platform> <PlatformID>50019855</PlatformID> <!-- Reject xml based on duplicate PlatformID --> <UnixTimestamp>1431892127</UnixTimestamp> </Title> </Movies> The following XSD validates,...

XmlReader always validates a Xsd file against another Xsd file as valid

c#,xml,xsd,xmlreader,xml-validation
I've got strange behaviour of the XmlReader. When using it for validation Xml against Xsd everythink works fine and how I expect. But when I try validate a Xsd file against another Xsd, it throws no validation exception. For better explenation of my use case: I have an application where...

Validation error in XML Schema for complexType

xml,xsd,xml-validation
Error: s4s-elt-must-match.1: The content of 'viviendas' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: complextype. Schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns="http://wwww.vivienda.io" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.vivienda.io"> <xs:element name="viviendas"> <xs:complextype> <xs:sequence maxoccurs="unbounded"> <xs:element name="vivienda" minoccurs="1">...

How to correct a tag mismatch error?

xml,xml-validation
I've created a network xml file to be parsed into a Java application. But I get the following error when I validate the xml file: "Line 71, Column 14: end tag for element "location" which is not open" To debug this, I checked my opening and closing tags, but I...

XML Spec: Union of xs:date, xs:gYearMonth, xs:gYear?

xml,types,specifications,xml-validation
I'm working with an XML spec and it defines a "type" 'date' that is: date: A union of xs:date, xs:gYearMonth, xs:gYear Where the above datatypes are from W3C XML Schema Definition Language (XSD) 1.1 Part 2 My question is, does that mean I can expect the date value to possibly...

xsd:complexType after xsd:attribute declarations yields error

xml,vb.net,visual-studio-2010,xsd,xml-validation
I have the following XSD: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="urn:com.xxxxx.xxx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:com.xxxxx.xxx"> <xsd:element name="Stuff_EXT" type="DT_Analyse_EXT"/> <xsd:complexType name="Stuff_EXT"> <xsd:annotation> <xsd:documentation xml:lang="EN">Data Type Response</xsd:documentation> </xsd:annotation> <xsd:sequence> <xsd:element name="Res"> <xsd:complexType> <xsd:sequence>...

Docbook xi:include

xml,xml-validation,docbook
I am trying to create a docbook. I have created a main XML book and inside it I am using <xi:include> to add different chapters. I am following DocBook XSL: The Complete Guide / Using XInclude to create book and chapter files. Here is my main XML file book1.xml. <?xml...

How to prevent empty element in XSD while requiring an attribute

xml,xsd,xml-validation
I am validating an XML document with the below XSD, and I want to ensure that the value of reportPath is not empty. Here is my current XSD.. <xs:element name="reportPath"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="Name" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> Example: I want my XSD validator to...