on XML Schema

Discussion in 'XML' started by Thorsten, Jan 19, 2007.

  1. Thorsten

    Thorsten Guest

    Hey there,

    I have a question concerning xml schemas and its contained elements.
    Let's say I have a schema (object.xsd) that defines an abstract element
    type (i.e. abstractObject). Dervied from this type are concrete types
    (i.e. house, car...).
    Now, I have an xml document that expects information about a datatype
    in xml schema format. How can I now define that it is supposed to
    expect an element of type "house"? Of course I can just refer to
    "object.xsd". But that would mean that entries of type "car" would be
    accepted as well. What possibilities do I have to restrict the schema
    definition to the type "house"?

    Thanks in advance,
    Thorsten
     
    Thorsten, Jan 19, 2007
    #1
    1. Advertising

  2. Thorsten wrote:
    > Hey there,
    >
    > I have a question concerning xml schemas and its contained elements.
    > Let's say I have a schema (object.xsd) that defines an abstract element
    > type (i.e. abstractObject). Dervied from this type are concrete types
    > (i.e. house, car...).
    > Now, I have an xml document that expects information about a datatype
    > in xml schema format. How can I now define that it is supposed to
    > expect an element of type "house"?


    Well in the schema you would use
    <xs:element name="someName" type="house"/>
    to define an element of the house type. Then an XML instance document to
    be validated against the schema needs to have an element of type house.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 19, 2007
    #2
    1. Advertising

  3. Thorsten

    George Bina Guest

    Hi Thorsten,

    It is not very clear for me what you want exactly. In addition to
    Martin's answer: if you have an element of type abstractObject then in
    the instance document you can use the xsi:type attribute to specify the
    type to house for instance, where xsi maps to the schema instance
    namespace: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    Best Regards,
    George
    ---------------------------------------------------------------------
    George Cristian Bina
    <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
    http://www.oxygenxml.com



    Thorsten wrote:
    > Hey there,
    >
    > I have a question concerning xml schemas and its contained elements.
    > Let's say I have a schema (object.xsd) that defines an abstract element
    > type (i.e. abstractObject). Dervied from this type are concrete types
    > (i.e. house, car...).
    > Now, I have an xml document that expects information about a datatype
    > in xml schema format. How can I now define that it is supposed to
    > expect an element of type "house"? Of course I can just refer to
    > "object.xsd". But that would mean that entries of type "car" would be
    > accepted as well. What possibilities do I have to restrict the schema
    > definition to the type "house"?
    >
    > Thanks in advance,
    > Thorsten
     
    George Bina, Jan 19, 2007
    #3
  4. Thorsten

    Thorsten Guest

    Thanks to both of you.

    I think George's advice might help me. To clearify my problem: I work
    with web services and one of them awaits a URL, where the data to
    process is deposited. In addition it expects a reference to a schema
    which describes the data structure of the data to process. Back to my
    example: let's say I want the web service to process a data of type
    "house" i have to post the URL to the house object and I have to
    specify the schema for "house". All I can do is specify
    "..../object.xsd" but to me that is too general, because the web
    service would then accept all other objects defined in "objects.xsd",
    but might not be able to process them.

    Hope that's more understandable,
    regards,
    Thorsten
     
    Thorsten, Jan 19, 2007
    #4
  5. Thorsten wrote:

    > I think George's advice might help me. To clearify my problem: I work
    > with web services and one of them awaits a URL, where the data to
    > process is deposited. In addition it expects a reference to a schema
    > which describes the data structure of the data to process. Back to my
    > example: let's say I want the web service to process a data of type
    > "house" i have to post the URL to the house object and I have to
    > specify the schema for "house". All I can do is specify
    > "..../object.xsd" but to me that is too general, because the web
    > service would then accept all other objects defined in "objects.xsd",
    > but might not be able to process them.


    A schema can define types but it can also define elements and usually
    does. So you would define a schema that defines an element of that house
    type.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 19, 2007
    #5
  6. Thorsten

    Thorsten Guest

    Ok, that's what I'll do.
    I thought that there is maybe another way than creating a new schema
    for the subtype

    Thanks a lot for you help guys!
    Thorsten
     
    Thorsten, Jan 19, 2007
    #6
    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. Markus
    Replies:
    1
    Views:
    1,541
    Markus
    Nov 23, 2005
  2. Fred Smith
    Replies:
    1
    Views:
    949
    Martin Honnen
    Feb 5, 2004
  3. Hari Om
    Replies:
    1
    Views:
    463
    Martin SChukrazy
    Mar 2, 2004
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,265
    Stanimir Stamenkov
    Apr 25, 2005
  5. Replies:
    3
    Views:
    2,873
Loading...

Share This Page