XML Schema

G

GendoIkari

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
 
U

usenet

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top