95

What is the difference between the xs and xsd prefixes in XML schema files?

Konrad
  • 17,740
  • 16
  • 106
  • 167
  • 7
    it's just a XML namespace prefix for the XML schema namespaces, which you can basically choose as you wish - xs and xsd are just the most commonly used ones – marc_s Jul 28 '09 at 14:04

3 Answers3

115

From the XSD 1.0 spec on w3.org:

The XML representation of schema components uses a vocabulary identified by the namespace name http://www.w3.org/2001/XMLSchema. For brevity, the text and examples in this specification use the prefix xs: to stand for this namespace; in practice, any prefix can be used.

in the end xs or xsd are only prefixes. XSD is used for example more by Microsoft schemas.

The important is how you declare the namespace.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  ...
</xs:schema>

or

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  ...
</xsd:schema>

should be equivalent.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65
Drake
  • 8,225
  • 15
  • 71
  • 104
  • 8
    So the short answer is, there is no difference? – Koray Tugay Nov 01 '14 at 19:13
  • 1
    nope ! Took me a while to get this sorted out - not just `xs`/`xsd` - but in general how XML Schemas work. Also, got to know the difference between DTD and XSD. – ARK Jul 04 '19 at 23:12
18

There is no difference, it is just a matter of choice

carpinchosaurio
  • 1,175
  • 21
  • 44
11

The xs: and xsd: are called namespace prefixes. They are declared using xmlns elements in the root element.

By convention people tend to choose either xs: or xsd: and map that to http://www.w3.org/2001/XMLSchema. Having both in a single document is confusing and should be avoided.

Check your xmlns declarations to determine what the namespaces are.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65
Harshal Bhamare
  • 372
  • 1
  • 6
  • 17