Cheetah
Cheetah

Reputation: 14379

XML xsd declaration

I am just wondering how I legally declare things like xmlns in XML files.

Using maven assembly as an example, I have something like this in one of my files:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">

Clearly that .xsd file does not exist any more it is here: http://maven.apache.org/xsd/assembly-1.1.2.xsd.

So what should I be putting in the xmlns and xsi:schemaLocation?

Upvotes: 0

Views: 149

Answers (2)

Ondrej Svejdar
Ondrej Svejdar

Reputation: 22054

xmlns can be any uri (it doesn't have to exists physically, its just namespace declaration). As for schemaLocation take a look at msdn - http://msdn.microsoft.com/en-gb/library/ms256100(v=vs.110).aspx

The location of a schema that contains qualified (a schema with a namespace) schema constructs. The first URI reference in each pair is a namespace name, and the second is the location of a schema that describes that namespace.

So consists of pairs of "[xmlns] [url]". The example which you have stated (maven) has valid url (http://maven.apache.org/xsd/assembly-1.1.0.xsd).

Upvotes: 0

Alex
Alex

Reputation: 1641

The "xmlns"-attribute is not mandatory if you just want to validate your xml-file against any xsd-file.

Into "xsi:schemaLocation" you have to enter the path to the xsd-file which you want to use for validation. ( This as well can be a local file)

Maybe best start with some easy example: http://www.w3schools.com/schema/schema_example.asp

Upvotes: 1

Related Questions