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
71
votes
7 answers

JAXB - Property "Value" is already defined. Use to resolve this conflict

Using JAXB to generate XML binding classes. The schema is based on a set of legacy XML files, and includes this snippet:
brasskazoo
  • 76,030
  • 23
  • 64
  • 76
69
votes
5 answers

XSD - one of 2 attributes is required?

Is there a way to specify that one of 2 attributes is required in XSD? for example, I have a definition like this: I want to be…
user92454
  • 1,201
  • 1
  • 10
  • 13
69
votes
2 answers

Add attributes to a simpletype or restriction to a complextype in Xml Schema

The problem is as follows: I have the following XML snippet: The problem is that I can't add both the attribute and the restriction at the same time. The attribute format can only have the values minutes, hours…
Ikke
  • 99,403
  • 23
  • 97
  • 120
69
votes
2 answers

XSD Definition for Enumerated Value

I'm stuck trying to define an XSD containing a field that can have only one of the following three values: Green Red Blue Essentially, I want to define a strict enumeration at the Schema level. My First attempt appears wrong and I'm not sure about…
Nate
  • 18,892
  • 27
  • 70
  • 93
65
votes
4 answers

Free DTD to XSD conversion utility?

I have a DTD that I need to convert to an XSD (XML schema) file. Is there a free utility or simple way to accomplish this?
Jeremy Stein
  • 19,171
  • 16
  • 68
  • 83
64
votes
6 answers

XML Schema: root element

The following post asks how to indicate that an element is the root element in an XML schema: Is it possible to define a root element in an XML Document using Schema? I have followed the w3schools tutorial on XML Schema but something is still not…
johngoche9999
  • 1,641
  • 2
  • 14
  • 21
63
votes
6 answers

How to generate xsd from wsdl

Is there any way by which I can generate xsd from wsdl. Any link or tool will also do. What is the simplest way to do this?
user3365075
  • 713
  • 1
  • 8
  • 11
62
votes
1 answer

how to Validate a XML file with XSD through xmllint

i have to validate my xml file with a given XSD file. Figured the easiest way to do so would be xmllint, but i can't get it to work. Can anyone tell me the exact command? I tried: xmllint --valid myxsd.xsd myxml.xml What am i doing wrong? This…
Econ
  • 2,419
  • 3
  • 13
  • 18
62
votes
3 answers

How to reference a local XML Schema file correctly?

I'm having this problem with referencing my XML Schema in an XML file. I have my XSD in this path: C:\environment\workspace\maven-ws\ProjectXmlSchema\email.xsd But when in my XML file I'm trying to locate the schema like this, the XSD is not…
Arturas M
  • 4,120
  • 18
  • 50
  • 80
62
votes
3 answers

xsd:boolean element type accept "true" but not "True". How can I make it accept it?

I am using xmllint --schema option to validate my XML that looks like this True In my schema file, I have following line that describes Active element. When I run…
Soichi Hayashi
  • 3,384
  • 2
  • 22
  • 15
61
votes
3 answers

No matching global declaration available for the validation root

Background Validate an XML document using a schema. Problem The simplest form of the problem is shown in two files. XML Document file.xml sugar…
Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
60
votes
18 answers

How to fix Eclipse validation error "No grammar constraints detected for the document"?

Eclipse 3.5.2 is throwing an XML schema warning message: No grammar constraints (DTD or XML schema) detected for the document. The application.xml file:
cmcginty
  • 113,384
  • 42
  • 163
  • 163
60
votes
2 answers

What does the ref attribute on an element in an XSD do?

Documentation seems to say that it references another element in the schema, but how could it be used - I've never seen it in schemas that I have worked with. Anyone got any nice use cases or something that could explain its use further?
Fiona - myaccessible.website
  • 14,481
  • 16
  • 82
  • 117
59
votes
7 answers

Does XML care about the order of elements?

XML confuses me sometimes, but I'm trying to get this figured out. What the vendor is telling me doesn't make sense but again, XML and I don't get along :) I have some XML that I'm sending to a vendor's web service that is giving me random…
dragonmantank
  • 15,243
  • 20
  • 84
  • 92
59
votes
2 answers

How to create a XSD schema from a class?

I'm having a hard time with the XSD files. I'm trying to create an XSD file from a class: public enum Levels { Easy, Medium, Hard } public sealed class Configuration { public string Name { get;set; } public Levels Level { get; set; } …
Darf Zon
  • 6,268
  • 20
  • 90
  • 149