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 8700725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:14:01+00:00 2026-06-13T02:14:01+00:00

Suppose I have an XML like this: <foo …> <bar a=s1 b=s2 /> <bar

  • 0

Suppose I have an XML like this:

<foo ...>
   <bar a="s1" b="s2" />
   <bar a="s3" />
</foo>

What I’d like is to define in the XSD is that the default value of attribute b should be the value of attribute a. Is that possible?

Thanks in advance!

  • 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-06-13T02:14:02+00:00Added an answer on June 13, 2026 at 2:14 am

    Short answer: no.

    Medium answer, according to “XML Schema Part 1: Structures Second Edition”, section “3.2.1 The Attribute Declaration Schema Component”: “default specifies that the attribute is to appear unconditionally in the ·post-schema-validation infoset·, with the supplied value used whenever the attribute is not actually present”

    Long and practical answer: the key is “post-schema-validation infoset”. So ask yourself what you need the schema document for?

    • if you need it to validate incoming XML documents, then just use use="required" for attribute b
    • if you need it to build objects (e.g., using some (un)marshalling technologies such as Java’s JAXB or .NET’s XmlSerializer) then you must explicitely add some post-processing which satisifies this “post-schema-validation-infoset” term – you should detect if the value of b wasn’t set and set it yourself – that’s your business requirement
    • if you need to communicate your intent (*I/my app will treat empty b as having the same value as a) add documentation. XML Schema doesn’t have such concept. Using extrapolation – that would be the same requirement as “the value of b will be the current USD/EUR ratio” – it’s just computed value
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have XML like this: <child_metadata> <metadata> <attributes> <metadata_key value=include/> <metadata_value value=value1/> </attributes>
Suppose I have a few lines out of wikipedia XML that looks like this:
Suppose i have an XML file, that i use as local database, like this):
Let's suppose I have xml like this one: <Server Active=No> <Url>http://some.url</Url> </Server> C# class
Suppose I have XML like this: <xsl:template match=assessment | section > . . .
Suppose I have some XML like this: <section name=SampleSection> <item name=ScoredItem1> <attributes> <scored data_type=boolean
Suppose I have a resource xml file like this: <?xml version=1.0 encoding=UTF-8?> <resources> <array
I know that if I have an XML file like this: <persons> <class name=English>
So i have an XML document that looks like this: <?xml version=1.0 encoding=UTF-8?> <gesmes:Envelope
Suppose I have xml like this: <Products> <Product name=Liquid Oxygen> <Manufacturer name=Universal Exports country=UK

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.