I've never used XML schemas before, though I know what their purpose is for. I did some research into how to write one, and I've got everything done I think. The problem is that I don't understand the purpose of a namespace, or if I even need to use one given the extremely small scope of my project. I'm not using this for some web service; its only purpose is to validate the structure of an XML document stored locally for use with an application I'm writing.

Here's my XSD file:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="XMLSchema1"
  <xs:complexType name="ingredient">
      <xs:extension base="xs:string">
        <xs:attribute name="amount" type="xs:string" use="required"/>
        <xs:attribute name="format" type="xs:string"/>
        <xs:attribute name="calories" type="xs:positiveInteger"/>
        <xs:attribute name="fat" type="xs:positiveInteger"/>
        <xs:attribute name="sodium" type="xs:positiveInteger"/>
        <xs:attribute name="carbs" type="xs:positiveInteger"/>
        <xs:attribute name="protein" type="xs:positiveInteger"/>
  <xs:element name="recipe">
        <xs:element name="ingredient" type="ingredient" minOccurs="1" maxOccurs="unbounded"/>
        <xs:element name="step" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
        <xs:element name="tip" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
      <xs:attribute name="title" type="xs:string" use="required"/>
      <xs:attribute name="yield" type="xs:positiveInteger"/>
      <xs:attribute name="preptime" type="xs:string"/>
      <xs:attribute name="cooktime" type="xs:string"/>
      <xs:attribute name="description" type="xs:string"/>

When I wrote the XSD file using visual studio, it put in as a template targetNamespace="http://tempuri.org/XMLSchema1.xsd" . I don't have, nor do I need, a web URI for this application. So knowing this, do I even need to bother thinking about namespaces? Or do I just have to structure it differently or something?

5 Years
Discussion Span
Last Post by hericles

You don't technically need one if your project is never going to be used outside your own software. The default one provided will suffice, you don't need to restructure anything. However, providing a namespace is painless and correct but the final choice is up to you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.