Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: Recursive XSD with targetNamespace

From: "Paul Spencer" <paul.spencer@--------.--.-->
To: "Todd Moon" <tmrfcm@-----.--->
Date: 11/17/2008 6:34:00 PM
There is a lot to be said for making the default namespace of the schema the
same as the target namespace. This only really matters if you xs:include a
schema with no target namespace into one that has one, but I have yet to
find a case where it is a disadvantage. No doubt someone will provide one.

You would then not need to worry about the prefix that Michael described.

Paul Spencer
  -----Original Message-----
  From: xmlschema-dev-request@w... [mailto:xmlschema-dev-request@w...]On
Behalf Of Todd Moon
  Sent: 14 November 2008 17:53
  To: Michael Kay
  Cc: xmlschema-dev@w...
  Subject: Re: Recursive XSD with targetNamespace


  > it is implicitly qualified by the targetNamespace.

  Well, I guess that was the gap in my knowledge. Thanks for all your help!

  - Todd Moon


  On Fri, Nov 14, 2008 at 4:42 PM, Michael Kay <mike@s...> wrote:

    Very little that's in XSD makes intuitive sense - get used to it.

    The basic rule is that when you are defining a component (such as an
element declaration), the "name" attribute gives the local name, and it is
implicitly qualified by the targetNamespace. When you are referencing a
component, you use a QName in the "ref" attribute, and if the QName is
unprefixed, it refers to a name in the default namespace - not the target
namespace.

    Michael Kay
    http://www.saxonica.com/



--------------------------------------------------------------------------
      From: Todd Moon [mailto:tmrfcm@g...]
      Sent: 14 November 2008 21:14
      To: Michael Kay
      Cc: xmlschema-dev@w...
      Subject: Re: Recursive XSD with targetNamespace


      This worked, but it doesn't make a lot of intuitive sense to me. The
namespace specified in the targetNamespace is the namespace of the document
to be validated. The Item type is defined in the schema. Why should I have
to use the target namespace when referencing a type defined and used within
the schema?

      Do all types defined in the schema automatically share the namespace
specified in targetSchema?

      Thanks!

      - Todd Moon


      On Fri, Nov 14, 2008 at 4:01 PM, Michael Kay <mike@s...>
wrote:

        Whenever you refer to a component in a namespace, you need to use a
qualified name. So it should be

        type="foo:Item"

        having declared

        xmlns:foo="http://foo"

        Michael Kay
        http://www.saxonica.com/



----------------------------------------------------------------------
          From: xmlschema-dev-request@w...
[mailto:xmlschema-dev-request@w...] On Behalf Of Todd Moon
          Sent: 14 November 2008 20:24
          To: xmlschema-dev@w...
          Subject: Recursive XSD with targetNamespace


          Hello everyone.

          I have a recursively defined type called "Item" and the schema
works fine at first. However, if I specify a targetNamespace in the XSD,
Visual Studio gives me an error claiming that "Item" is not defined (when
it's used within the definition of Item itself.)

          Here's a greatly simplified schema that still exposes the problem:

          <?xml version="1.0" encoding="utf-8" ?>
          <xsd:schema
             targetNamespace="http://foo"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema">

             <xsd:complexType name="Item">
                 <xsd:sequence>
                     <xsd:element name="SerialNumber" />
                     <xsd:sequence>
                         <xsd:element name="Item" type="Item" />
                     </xsd:sequence>
                 </xsd:sequence>
             </xsd:complexType>

          </xsd:schema>

          If I remove the targetNamespace attribute this works fine. Why is
this causing a problem?

          Thanks!

          - Todd Moon






transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent