XML Schema

Discussion in 'XML' started by GendoIkari, Feb 5, 2008.

  1. GendoIkari

    GendoIkari Guest

    I've been going nuts all day trying to figure this out... I need to
    create a schema that allows the document to have an element with any
    possible name. When using the <xs:any> tag, it still will only allow
    any element that is defined in my namespace. I need to allow elements
    which are not defined in any namespace. I've added namespace="##local"
    but that still doesn't work, because in the instance document the
    element in question is still part of the namespace. The only way at
    all I've gotten something to work is by adding processContents="lax",
    but this is not good because then I can't ensure that the element is
    the correct structure. I need the element to be a simple type, an
    xs:string. It should not be allowed to have child nodes. Is there any
    way I can force the document to be this specific structure, but NOT
    enforce a specific element name to be used?

    Thanks,

    -Robert
     
    GendoIkari, Feb 5, 2008
    #1
    1. Advertising

  2. GendoIkari

    Guest

    On 5 Feb, 19:33, GendoIkari <> wrote:
    > I've been going nuts all day trying to figure this out... I need to
    > create a schema that allows the document to have an element with any
    > possible name. When using the <xs:any> tag, it still will only allow
    > any element that is defined in my namespace. I need to allow elements
    > which are not defined in any namespace. I've added namespace="##local"
    > but that still doesn't work, because in the instance document the
    > element in question is still part of the namespace. The only way at
    > all I've gotten something to work is by adding processContents="lax",
    > but this is not good because then I can't ensure that the element is
    > the correct structure. I need the element to be a simple type, an
    > xs:string. It should not be allowed to have child nodes. Is there any
    > way I can force the document to be this specific structure, but NOT
    > enforce a specific element name to be used?
    >
    > Thanks,
    >
    > -Robert


    I'd be interested to know why you want to do this. There might be a
    better way to tackle the problem. For example, and XML instance along
    the lines of <data name="foo" value="bar"/> might work.

    Coming back to the problem as ou stated, if you do
    processContents="strict" then you will have to have a definition of
    the element somewhere for validation to complete. This would be the
    only way you could restrict the type of the element as well. With
    that in mind, you might be able to define an xs:group that defines all
    your possible extra elements.

    BTW - when using xs:any to allow elements in your existing namespace,
    you have to worry about the Unique Particle Attribution Constraint, or
    UPAC. Annoyingly, if you have an element prior to your xs:any that
    does not have fixed cardinality (i.e. minOccurs and maxOccurs are not
    the same value) then the xs:any will be in conflict with that element
    and the schema won't be valid!

    Other than that, can you not do namespace="##any" on your xs:any
    statement?

    HTH,

    Pete Cordell
    Codalogic
    Visit http://www.codalogic.com/lmx/ for XML C++ data binding
     
    , Feb 6, 2008
    #2
    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,665
    Markus
    Nov 23, 2005
  2. Fred Smith
    Replies:
    1
    Views:
    998
    Martin Honnen
    Feb 5, 2004
  3. Hari Om
    Replies:
    1
    Views:
    482
    Martin SChukrazy
    Mar 2, 2004
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,329
    Stanimir Stamenkov
    Apr 25, 2005
  5. Replies:
    3
    Views:
    3,175
Loading...

Share This Page