Results 1 to 7 of 7

Thread: XSD - Attribute Question **SOLVED**

  1. #1

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Resolved XSD - Attribute Question **SOLVED**

    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
    Last edited by Sgt-Peppa; Aug 23rd, 2005 at 10:07 AM. Reason: SOLVED
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  2. #2
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769

    Re: XSD - Attribute Question

    "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:
    Code:
    <Optional>
      <tag blah="myvalue" />
      <tag />
    </Optional>
    <Prohibited>
      <tag />
    </Prohibited>
    <Required>
      <tag blah="myvalue" />
    </Required>

  3. #3

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Re: XSD - Attribute Question

    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
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  4. #4
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769

    Re: XSD - Attribute Question **SOLVED**

    check the definition of type="myType"... perhaps this type declaration has some other definition that specifies what the format of the data should be....

  5. #5

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Re: XSD - Attribute Question **SOLVED**

    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?
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  6. #6
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769

    Re: XSD - Attribute Question **SOLVED**

    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
    Code:
    <xs:element name="tag">
       <xs:complexType>
          <xs:attribute name="blah" type="xs:integer" use="optional"/>
       </xs:complexType>
    </xs:element>

  7. #7

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Re: XSD - Attribute Question **SOLVED**

    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
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width