Click to See Complete Forum and Search --> : XSD - Attribute Question **SOLVED**
Sgt-Peppa
Aug 23rd, 2005, 08:24 AM
Hey all,
I have a question concerning attributes in XSD Schemas.
If I define an Attribute like this:
<xsd:attribute name="blah" type="myType">
there is an additional Attribute called use that one could insert.
Like this:
<xsd:attribute name="blah" type="myType" use="Optional/Prohibited/Required">
What are the results if I inserted either one of those three?
How would my Attribute need to like if I inserted that use Statement?
Hope I explained well (I doubt it,...)
Thanks Stephan
shunt
Aug 23rd, 2005, 09:23 AM
"Optional" : You can have the attribute in the tag if you want, but if you don't, no one will care...
"Prohibited" : You can never have this attribute in the tag.
"Required" : You must always have this attribute in the tag.
The following examples are valid tags:
<Optional>
<tag blah="myvalue" />
<tag />
</Optional>
<Prohibited>
<tag />
</Prohibited>
<Required>
<tag blah="myvalue" />
</Required>
Sgt-Peppa
Aug 23rd, 2005, 10:05 AM
Ok, thanks for the explanation.
I have an Application that provides an Xml Interface. I have the Schema, and I am trying to generate a valid instance to it. The schema says that the attribute is prohibited. If I dont send the attribute I get an error Message saying that the required attribute is missing, if I send it i get an error message saying that the value is not valid,even if it is, seems like a bug. I just wanted to make sure.
Thanks for the help,
Stephan
shunt
Aug 23rd, 2005, 10:09 AM
check the definition of type="myType"... perhaps this type declaration has some other definition that specifies what the format of the data should be....
Sgt-Peppa
Aug 23rd, 2005, 10:20 AM
I already did. It says it should be a number. \d+ is the reg ex used for that. But it should not matter cause as you said I should not be sending that Attibute at all right?
shunt
Aug 24th, 2005, 01:58 AM
Yes, thats right.... I don't know about your regexp. Have not tested it, but shouldnt you just use one of the built in datatypes? For an integer, use type="xs:integer" to define a number. This of course assumes that you have defined your schema definition as xmlns:xs="http://www.w3.org/2001/XMLSchema"....so
<xs:element name="tag">
<xs:complexType>
<xs:attribute name="blah" type="xs:integer" use="optional"/>
</xs:complexType>
</xs:element>
Sgt-Peppa
Aug 24th, 2005, 03:12 AM
The Schema is not defined by me. I am only trying to create a valid Instance. And they did use a custom Datatype follwed by restrictions. Thanks for all your time and help, I really appreciate it!
Stephan
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.