Questions tagged [xsd]

XSD generally refers to a document written in the W3C XML Schema format, containing a description of a particular type of XML document.

XML Schema, published as a W3C recommendation in May 2001, is one of several XML schema languages.

Because of confusion between XML Schema as a specific W3C specification, and the use of the same term to describe schema languages in general, some parts of the user community referred to this language as WXS, an initialism for W3C XML Schema, while others referred to it as XSD, an initialism for XML Schema Document — a document written in the XML Schema language, typically containing the "xsd" XML namespace prefix and stored with the ".xsd" filename extension.

As of April 5th 2012, the XML Schema Definition (XSD) 1.1 is a W3C Recommendation; W3C has adopted XSD as the preferred acronym.

What is an XML Schema?

The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD.

An XML Schema:

  • defines elements that can appear in a document.
  • defines attributes that can appear in a document.
  • defines which elements are child elements.
  • defines the order of child elements.
  • defines the number of child elements.
  • defines whether an element is empty or can include text.
  • defines data types for elements and attributes.
  • defines default and fixed values for elements and attributes.

See also:

14065 questions
58
votes
5 answers

Why do we need targetNamespace?

I would like to understand the purpose of targetNamespace as used both in XML Schema and in WSDL. In fact, to keep things simple, let's limit this question to XML Schema. I feel like I fully understand the notion of (simple) XML namespaces. By…
Student
  • 1,947
  • 2
  • 18
  • 25
56
votes
7 answers

Generating a JAXB class that implements an interface

I'm currently using JAXB to generate java classes in order to unmarshall XML. Now I would like to create a new schema very similar to the first and have the classes that are generated implement the same interface. Say for example, I have two schema…
Alex Spurling
  • 54,094
  • 23
  • 70
  • 76
55
votes
4 answers

There is no Unicode byte order mark. Cannot switch to Unicode

I am writing an XML validator with XSD. Below is what I did, but when the validator reached the line while (list.Read()) it gives me the error There is no Unicode byte order mark. Cannot switch to Unicode. Can anybody help me fix it? public class…
user3122648
  • 887
  • 2
  • 8
  • 21
55
votes
1 answer

Troubles with WADL / generated XSD using Jersey with a contract-first approach

I have been working on a REST web service using Jersey for a few days now, and managed to have all CRUD operations working, with several exchange formats: XML, JSON, Google Protobuf. However I am facing some issues related to automatically generated…
Marc Carré
  • 1,446
  • 13
  • 19
54
votes
8 answers

Unable to generate a temporary class (result=1). error CS0030: Cannot convert type 'Type[]' to 'Type'?

I get this error after I created a class from my xsd file using the xsd.exe tool. So I searched the net and found a solution. Here is the link: http://satov.blogspot.com/2006/12/xsdexe-generated-classes-causing.html Problem is that this makes the…
grady
  • 12,281
  • 28
  • 71
  • 110
53
votes
7 answers

How to choose between DTD and XSD

I want to use either a DTD or an XSD to describe my XML document. I've read that XSDs are better than DTDs since they support namespaces and data types, and that DTDs are older. Does this mean that I should only use XSDs for all future needs and…
ajsie
  • 77,632
  • 106
  • 276
  • 381
52
votes
5 answers

How to convert XSD to Python Class

I just want to know if there is a program that can convert an XSD file to a Python class as JAXB does for Java?
Kortex786
  • 1,089
  • 1
  • 8
  • 10
50
votes
2 answers

XSD element with both attributes and child elements

I want to know the correct syntax for defining an element containing both attributes and child elements (if possible). For example:
Ste83
  • 551
  • 1
  • 4
  • 9
50
votes
2 answers

Is it possible to generate a XSD from a JAXB-annotated class?

I've written a number of classes using JAXB for serialization and I was wondering if there was a way to generate a XSD file for each of these objects based on the annotations. Is there a tool for this? Something like generate-xsd…
Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411
49
votes
2 answers

Multiple XSD schema files to C# classes

What is the best way to generate C# classes from multiple XSD schema files? Some XSD schema files may have dependency to the other, I am trying to avoid duplicated C# classes being generated.
Ray Lu
  • 26,208
  • 12
  • 60
  • 59
48
votes
3 answers

JAXB: How to change XJC-generated classes names when attr type is specified in XSD?

I'm a beginner to JAXB and I'm having annoying issues when generating Java classes with xjc. I am provided with a XSD like this: ...
miguel perher
  • 901
  • 1
  • 8
  • 17
48
votes
4 answers

XML namespaces and attributes

I'm trying to understand how namespaces work in XML. When I have an element like foo:bar, the attributes will often not have namespaces on them. But sometimes they will. Are the attribute in the namespace of the element, even when the default…
user4315
  • 4,775
  • 5
  • 23
  • 9
48
votes
6 answers

How to generate a Java class which implements Serializable interface from xsd using JAXB?

I would like to introduce caching into an existing Spring project which uses JAXB to expose WebServices. Caching will be done on the level of end points. In order to do that classes generated from XSD using JAXB need to implement Serializable…
Boris Pavlović
  • 63,078
  • 28
  • 122
  • 148
48
votes
5 answers

cvc-elt.1: Cannot find the declaration of element 'MyElement'

I'm trying to validate a really simple xml using xsd, but for some reason I get this error. I'll really appreciate if someone can explain me why. XML File A XSD File
Mitko Mitev
  • 483
  • 1
  • 4
  • 7
47
votes
3 answers