Using xs:import and xs:extension

Discussion in 'XML' started by randar@beer.com, Jan 17, 2006.

  1. Guest

    I'm having problems getting an XML document to validate against a
    fairly complex scenario.

    Goals:
    -To have two schemas with two different namespaces, so that I can
    validate each one seperately against an XML doc. Hence why I'm using
    xs:import instead of xs:include.
    -To create some sample XML that will validate in Visual Studio and I
    can use the tools there to enter in the XML data.

    Here is the "base" schema:
    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema id="BaseSchema" targetNamespace="http://tempuri.org/Program"
    elementFormDefault="qualified" xmlns="http://tempuri.org/Program"
    xmlns:mstns="http://tempuri.org/Program"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="BaseElement" type="BaseComplexType">
    </xs:element>
    <xs:complexType name="BaseComplexType">
    <xs:sequence>
    <xs:element name="Primary" type="xs:int" />
    </xs:sequence>
    </xs:complexType>
    </xs:schema>

    Here is the sub schema:
    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema id="SubSchema"
    targetNamespace="http://tempuri.org/ProgramSub"
    elementFormDefault="qualified" xmlns="http://tempuri.org/ProgramSub"
    xmlns:mstns="http://tempuri.org/ProgramSub"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:bs="http://tempuri.org/Program"
    xmlns:ss="http://tempuri.org/ProgramSub">
    <xs:import schemaLocation="BaseSchema.xsd"
    namespace="http://tempuri.org/Program"></xs:import>
    <xs:element name="SubElement" type="SubComplexType">
    </xs:element>
    <xs:complexType name="SubComplexType">
    <xs:complexContent>
    <xs:extension base="bs:BaseComplexType">
    <xs:sequence>
    <xs:element name="ExtraString" type="xs:string" />
    <xs:element name="Foo" type="xs:string" />
    </xs:sequence>
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>
    </xs:schema>

    Both of these seem to validate fine. When I create a new XML document
    using VS, the data entry tools work fine and it generates:
    <?xml version="1.0" encoding="utf-8"?>
    <SubElement xmlns="http://tempuri.org/ProgramSub">
    <Primary xmlns="http://tempuri.org/Program">1</Primary>
    <ExtraString>sad</ExtraString>
    <Foo>asdfasd</Foo>
    </SubElement>

    But it gives me the validation error of:
    C:\Projects\Miscellaneous\Prototypes\ProgramManagement\Test.xml(3): The
    active schema does not support the element 'Primary'.

    So I tried to put namespaces in:
    <?xml version="1.0" encoding="utf-8"?>
    <ss:SubElement xmlns:ss="http://tempuri.org/ProgramSub"
    xmlns:bs="http://tempuri.org/Program">
    <bs:primary>1</bs:primary>
    <ss:ExtraString>sd</ss:ExtraString>
    <ss:Foo>sad</ss:Foo>
    </ss:SubElement>

    But still no luck.
    C:\Projects\Miscellaneous\Prototypes\ProgramManagement\SubData.xml(3):
    The active schema does not support the element 'bs:primary'.

    Anybody have an idea?
    , Jan 17, 2006
    #1
    1. Advertising

  2. Works for me.

    That is, I can validate your instance with your schema docs just fine,
    using XSV.

    Sounds like a VS bug.

    ht
    --
    Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
    Half-time member of W3C Team
    2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
    Fax: (44) 131 650-4587, e-mail:
    URL: http://www.ltg.ed.ac.uk/~ht/
    [mail really from me _always_ has this .sig -- mail without it is forged spam]
    Henry S. Thompson, Jan 17, 2006
    #2
    1. Advertising

  3. VS2005 validates it as well.

    --
    Stan Kitsis
    Program Manager, XML Technologies
    Microsoft Corporation

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at
    http://www.microsoft.com/info/cpyright.htm

    "Henry S. Thompson" <> wrote in message
    news:...
    > Works for me.
    >
    > That is, I can validate your instance with your schema docs just fine,
    > using XSV.
    >
    > Sounds like a VS bug.
    >
    > ht
    > --
    > Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
    > Half-time member of W3C Team
    > 2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
    > Fax: (44) 131 650-4587, e-mail:
    > URL: http://www.ltg.ed.ac.uk/~ht/
    > [mail really from me _always_ has this .sig -- mail without it is forged
    > spam]
    Stan Kitsis [MSFT], Jan 17, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand
    Replies:
    3
    Views:
    878
    Tim Daneliuk
    Nov 8, 2003
  2. Christian Seberino
    Replies:
    3
    Views:
    1,168
    Christian Seberino
    Feb 5, 2004
  3. Elhanan
    Replies:
    0
    Views:
    543
    Elhanan
    Jan 23, 2007
  4. llothar
    Replies:
    17
    Views:
    1,243
    Steve Holden
    Apr 7, 2008
  5. David Cournapeau

    Statically linked extension and relative import

    David Cournapeau, May 7, 2009, in forum: Python
    Replies:
    0
    Views:
    291
    David Cournapeau
    May 7, 2009
Loading...

Share This Page