Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7537463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:51:31+00:00 2026-05-30T06:51:31+00:00

This question is plain ignorance, sorry. I can’t find the example I want. If

  • 0

This question is plain ignorance, sorry. I can’t find the example I want. If I have a single element in an XML file and want to put a required attribute on it, what would be the XSD definition? The documentation I’ve seen seems to suggest that a type must be complex to include other elements or attributes. But when I try using complexType definition without other elements, I cannot add a “type” without anonymous child type complaints.

I am basically wanting something to define

Texty Texted Text

My searches keep showing me how to add attributes to complexTypes with multiple nested elements, which seems pretty straight forward. Can you help without laughing too much? I know this has to be simple. anAttribute is type xs:string as well as the type for anElement.

Thanks,
BBB

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:51:32+00:00Added an answer on May 30, 2026 at 6:51 am

    Simple types cannot have attributes, and string is a simple type. Therefore, you must define a complex type to carry the attribute declaration. To define a complex type that is based on the simple type string, you need to derive a new complex type from the simple type string:

      <xs:element name="anElement">
        <xs:complexType>
         <xs:simpleContent>
          <xs:extension base="xs:string">
           <xs:attribute name="anAttribute" type="xs:string"/>
          </xs:extension>
         </xs:simpleContent>
        </xs:complexType>
       </xs:element>
    

    Use the complexType element to start the definition of a new (anonymous) type. To indicate that the content model of the new type contains only character data and no elements, use a simpleContent element. Finally, derive the new type by extending the simple string type. The extension consists of adding a anAttribute attribute using a standard attribute declaration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is NOT a question on plain old boring customization; I actually want to
This is not a question about a specific framework. I am using plain php
This question and answer shows how to send a file as a byte array
This question was very helpful, however I have a list control in my report,
I'm having difficulties believing this question hasn't been asked before, but I couldn't find
Hopefully this question won't be too convoluted or vague. I know what I want
I could equally have titled this question, Is it good enough for CRAN? I
I have been storing my passwords in plain-text for development purposes but want to
I seen this question Encrypting/Hashing plain text passwords in database and i am aware
Although this question concerns EhCache primarily, it really applies to caching frameworks (and plain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.