3
votes

I was going thru maven pom.xml which starts with...

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  1. Why do I need to use xsi:schemaLocation here? I understand its a way to discover XSD that has a target namespace., but when I use xmlns="http://www.w3.org/2001/XMLSchema" I don't need to mention schemaLocation?

  2. When I try overriding the prefix xsi with something else (say xsitest) editor shows it invalid. Is it a standard prefix keyword one should use? I thought prefixes can be anything.

1

1 Answers

1
votes

You ask "Why do I need to use xsi:schemaLocation ...?"

Do you? Whether you need to use xsi:schemaLocation or not depends on the validators and other schema-aware processors you are using: xsi:schemaLocation is one way, but not the only way, to bind namespaces to particular schemas.

You are right to expect that a document should remain valid if you change the prefix to which the XSI namespace is bound. If your software is showing you an error, then perhaps there is an error in the software, or perhaps you did not rebind the prefix correctly.