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 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

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.