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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:53:48+00:00 2026-05-12T21:53:48+00:00

I’ve inherited the task of creating a schema for some XML which already exists

  • 0

I’ve inherited the task of creating a schema for some XML which already exists – and IMHO is not the best that could have been done. The section giving me problems is the element at the end of the ‘scan-result’ element.

The best I’m hoping for with regard to the data in the ‘spectrum’ element is to treat it as type=”xs:string”. I’ll programatically divide up the numeric pairs that constitute the data in the string later. (Even though this step would not be needed had the data been properly structured in the first place.)

Here’s a similar piece of XML data to what I have to work with…

    <scan-result>
      <spectrum-index>0</spectrum-index>
      <scan-index>2</scan-index>
      <time-stamp>5609</time-stamp>
      <tic>55510</tic>
      <start-mass>22.0</start-mass>
      <stop-mass>71.0</stop-mass>
      <spectrum count="5">30,11352;31,360;32,16634;45,1161;46,26003</spectrum>
    </scan-result>

The problem is, I can’t seem to get a working definition for the ‘spectrum’ element that has the ‘count’ attribute and allows me to define the ‘spectrum’ element type as “xs:string”.

What I would like is something like the following:

<xs:complexType name="ctypScanResult">
    <xs:sequence>
        <xs:element name="spectrum-index" type="xs:integer"/>
        <xs:element name="scan-index" type="xs:integer"/>
        <xs:element name="time-stamp" type="xs:integer"/>
        <xs:element name="tic" type="xs:integer"/>
        <xs:element name="start-mass" type="xs:float"/>
        <xs:element name="stop-mass" type="xs:float"/>
        <xs:element name="spectrum" type="xs:string">
            <xs:complexType>
                <xs:attribute name="count" type="xs:integer"/>
            </xs:complexType>
        </xs:element>
    </xs:sequence>
    <xs:attribute name="count" type="xs:integer"/>
</xs:complexType>

The problem is that I can define the type of the ‘spectrum’ element as “xs:string” XOR I can define the anonymous ‘xs:complexType’ in the ‘spectrum’ element, which allows me to insert the ‘count’ attribute. But I need to be able to express both.

Given that I’m kind of stuck with the XML as it was handed to me, is there a schema definition that will allow me to describe this data?

Sorry this is long, but thanks to any and all who respond,

AlarmTripper

Followup: I know why the error occurs…

Quoted from W3C:

3.3.3 Constraints on XML Representations of Element Declarations
Schema Representation Constraint: Element Declaration Representation OK

In addition to the conditions imposed on element information items by the schema for schemas: all of the following must be true:
1 default and fixed must not both be present.
2 If the item’s parent is not , then all of the following must be true:
2.1 One of ref or name must be present, but not both.
2.2 If ref is present, then all of , , , , , nillable, default, fixed, form, block and type must be absent, i.e. only minOccurs, maxOccurs, id are allowed in addition to ref, along with .
3 type and either or are mutually exclusive.
4 The corresponding particle and/or element declarations must satisfy the conditions set out in Constraints on Element Declaration Schema Components (§3.3.6) and Constraints on Particle Schema Components (§3.9.6).

But I’m still in the same fix I was before… How can I actually accomplish something that resembles my goal?

Thanks,

AlarmTripper

  • 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-12T21:53:48+00:00Added an answer on May 12, 2026 at 9:53 pm

    Let a tool do it for you! Try xsd.exe.

    Or, if you must define by hand, at least check your hand-written-definition with an automatically generated one.

    Here’s what XSD.exe gave me for your input. I trimmed out some MS-NS cruft.

    <xs:element name="spectrum">
              <xs:complexType>
                <xs:simpleContent>
                  <xs:extension base="xs:string">
                    <xs:attribute name="count" type="xs:string" />
                  </xs:extension>
                </xs:simpleContent>
              </xs:complexType>
    </xs:element>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 240k
  • Answers 240k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It sounds like you're trying to figure out the best… May 13, 2026 at 7:17 am
  • Editorial Team
    Editorial Team added an answer The magic of django forms is that you don't need… May 13, 2026 at 7:17 am
  • Editorial Team
    Editorial Team added an answer Wow, that's a tall order. You might want to look… May 13, 2026 at 7:17 am

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.