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

  • Home
  • SEARCH
  • 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 6248059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:59:18+00:00 2026-05-24T12:59:18+00:00

I have simple XML format for metas <?xml version=1.0 encoding=utf-8?> <metas> <meta type=date> <code>storage_date</code>

  • 0

I have simple XML format for metas

<?xml version="1.0" encoding="utf-8"?>

<metas>
<meta type="date">
    <code>storage_date</code>
    <value>12-02-1989</value>
</meta>
<meta type="int">
    <code>weight</code>
    <value>12</value>
</meta>
<meta type="bool">
    <code>foo</code>
    <value>true</value>
</meta>
<meta type="text">
    <code>bar</code>
    <value>Hello world</value>
</meta>    
</metas>

I want to have schema that takes into account my meta type and validate depending if it is an int bool date or text.

So far I have

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="metas" type="metasType" />
  <xsd:complexType name="metasType">
    <xsd:sequence>
      <xsd:element maxOccurs="unbounded" name="meta" type="metaType" />
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="metaType">
    ???
</xsd:schema>

Is what I am trying to do possible to validate with schemas ?

  • 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-24T12:59:19+00:00Added an answer on May 24, 2026 at 12:59 pm

    So you want the type attribute on the meta element to control the content of the meta element. One way to do that is to:

    1. let metaType be an empty type
    2. create a new type by extension from metaType for each possibility
    3. have the type attribute on the meta element be xsi:type
    4. the type attribute’s value should identify the actual subtype of metaType being used

    E.g. you define meta_int as a subtype of metaType. When you define the value element there, it will be type xs:int. Then you will have in your XML:

    <meta xsi:type="meta_int">
      <code>weight</code>
      <value>12</value>
    </meta>
    

    Another approach is to use different element names rather than the type attribute (e.g., a meta_int element). You can then use a choice group to choose between the various meta_* elements.

    Yet another approach might be to use assertions, but that is a feature of XSD 1.1 which is not yet official (AFAIK).

    I am not sure what you are doing, but I think it is fair to say that in XSD, the element names are generally what is most useful in controlling the content that follows, whereas you are trying to do that using an attribute.

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

Sidebar

Related Questions

I have 50000 XML records like this in the database: <?xml version=1.0 encoding=UTF-8?> <root>
I have a simple value type: [Serializable] private struct TimerInstance { public TimerInstance(string str,
I have a string containing field/value pairs in xml format and want to parse
I have a simple PHP script that outputs a dir listing in XML format.
I have a simple xml document that looks like the following snippet. I need
I have a simple XML extraction issue that should be solvable with straight PHP
i have a simple xml file in a wcf service that i am trying
I have a simple xml file and I want to remove everything before the
Situation: I have a simple XML document that contains image information. I need to
I have some very simple XML: <properties> <property> <name>BobFish</name> <explaination>Bob is a fish.</explaination> </property>

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.