Questions tagged [xml-validation]

the procedure of checking an XML document against some kind of schema that describes rules that this type of document must conform to. This can often be done programmatically in eg. Java or C# and the schemas are often of the type XSD.

XML validation is the procedure of checking an XML document against some kind of schema that describes rules that this type of document must conform to. This can often be done programmatically in eg. Java or C# and the schemas are often of the type XSD.

1005 questions
6
votes
1 answer

XSD Error: This element is not expected

I was writing an XSD to validate a XML, but when I was validating this error appeared: Output - error Validation of current file using XML Schema: ERROR: Element '{http://www.w3.org/2001/XMLSchema-instance}Gasto': This element is not expected.…
Joseph
  • 159
  • 2
  • 4
  • 12
6
votes
2 answers

At least one XML element with no duplicates in XSD

I'm trying to create a validation scenario where I want to choose at least one non-repeating element from a list. Somewhere along the lines of:
Daniel André
  • 1,158
  • 1
  • 12
  • 28
6
votes
1 answer

How to declare a complexType has only one child element?

When using XML Schema to declare that a complexType has just one child element, all the below three approaches achieve the goal:
MengT
  • 1,207
  • 2
  • 14
  • 16
6
votes
2 answers

Validate XML with loading schemas at runtime, failure depending on schema order

I am trying to do xml validation. I am being given a list of schemas at run-time (possibly wrapped in a jar). Validation passes or failes based on the order in which I provide the schemas to the SchemaFactory. Here is what I am doing: private void…
John B
  • 32,493
  • 6
  • 77
  • 98
6
votes
2 answers

XML Schema validation for POST requests with ASP.NET WebAPI

I am trying to find a solution to validate if XML data sent in a POST request are fulfilling a given custom XML schema. If I use the XmlMediaTypeFormatter delivered with ASP.NET Web API I don't have a schema validation available, as far as I can…
Slauma
  • 175,098
  • 59
  • 401
  • 420
5
votes
1 answer

Validate an XML against an XSD in Java / Getting a hold of the schemaLocation

How can one validate an XML file using an XSD in Java? We don't know the schema in advance. I would like to be able to get the schemaLocation, download the XSD, cache it and then perform the actual validation. The problem is, that with…
carlspring
  • 31,231
  • 29
  • 115
  • 197
5
votes
1 answer

XSD: specify a choice must have at least one from a list but no more than one of each

This has been driving me mad for hours. I've read every relevant XSD question on SO and the rest of the Internet it seems and still the answer eludes me. I need an XML schema that requires at least one of list of elements be present, but each…
Paul
  • 19,704
  • 14
  • 78
  • 96
5
votes
1 answer

XmlDocument.Validate does not fire for multiple errors

I am trying to validate an incoming input xmlDocument against a an existing XmlSchemaSet. Following is the code: public class ValidateSchemas { private bool _isValid = true; public List errorList = new List(); public…
harry2ms
  • 51
  • 2
5
votes
3 answers

Python hangs on lxml.etree.XMLSchema(tree) with apache + mod_wsgi

Python hangs on lxml.etree.XMLSchema(tree) when I use it on apache server + mod_wsgi (Windows) When I use Django dev server - all works fine if you know about other nice XML validation solution against XSD, tell me pls Update: I'm using soaplib,…
Andrey Koltsov
  • 1,956
  • 6
  • 24
  • 43
5
votes
1 answer

Nesting XML elements from different namespaces in XSD

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:
jpvee
  • 913
  • 1
  • 15
  • 23
5
votes
2 answers

In XSD how do I allow only whitespace in an element's content?

I am writing the XSD for an element that has no content, only attributes, which seems fairly straightforward:
Dave
  • 3,429
  • 2
  • 26
  • 29
5
votes
1 answer

Import complex types from another XSD

I am finding difficulty in importing and referencing a complex type from one XSD file to another. Let me illustrate my scenario with an example Student.xsd
Aarish Ramesh
  • 6,745
  • 15
  • 60
  • 105
5
votes
1 answer

How to reference local XSD from XML file?

I want to write a simple XML file with a custom xsd file located in the same local directory on my computer. I don't understand the necessary syntax at the beginning of the files (I have googled but XSD tutorials seem to focus on the element…
DavidA
  • 2,053
  • 6
  • 30
  • 54
5
votes
1 answer

XML Schema validation ignored when fragment-level conformance is enabled?

From my sojourn with XML and Schema validation, it seems that when fragment-level conformance is enabled for an XMLReader instance, the XML source stops being validated against any included Schemas. However I cannot verify this from the MSDN…
John K
  • 28,441
  • 31
  • 139
  • 229
5
votes
1 answer

XML validation by XSLT or Schematron in Eclipse XML Editor?

How can we validate xml document by either schematron or xslt in Eclipse xml editor? The idea is to extend xml document live validation in eclipse xml editor with some rules based validation method.
WSK
  • 5,949
  • 8
  • 49
  • 74