Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. How do I create a schema for elements with attributes

How do I create a schema for elements with attributes

Scheduled Pinned Locked Moved XML / XSL
questiondatabasexml
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Christian Wikander
    wrote on last edited by
    #1

    How can I create a schema for the following?

    <Data>
    <Value unit="m/s">10</Value>
    <Value unit="ºF">25</Value>
    </Data>

    I would like to have the following description in the xsd

    <xs:complexType name="rootSchema">
    xs:sequence
    <xs:element name="Value" type="valueSchema" maxOccurs="unbounded" />
    </xs:sequence>
    </xs:complexType>
    <xs:element name="Multicalc" type="rootSchema" />

    How do I write the definition of valueSchema? (I hope I didn't make any mistakes in the definitions. I simplified things a bit compared to my own xsd.)

    L 1 Reply Last reply
    0
    • C Christian Wikander

      How can I create a schema for the following?

      <Data>
      <Value unit="m/s">10</Value>
      <Value unit="ºF">25</Value>
      </Data>

      I would like to have the following description in the xsd

      <xs:complexType name="rootSchema">
      xs:sequence
      <xs:element name="Value" type="valueSchema" maxOccurs="unbounded" />
      </xs:sequence>
      </xs:complexType>
      <xs:element name="Multicalc" type="rootSchema" />

      How do I write the definition of valueSchema? (I hope I didn't make any mistakes in the definitions. I simplified things a bit compared to my own xsd.)

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      see if this works

      <xs:complexType name="valueSchema">
          xs:simpleContent
            <xs:extension base="xs:integer">
              <xs:attribute name="unit" type="xs:string" use="required" />
            </xs:extension>
          </xs:simpleContent>  
        </xs:complexType>

      led mike

      C 1 Reply Last reply
      0
      • L led mike

        see if this works

        <xs:complexType name="valueSchema">
            xs:simpleContent
              <xs:extension base="xs:integer">
                <xs:attribute name="unit" type="xs:string" use="required" />
              </xs:extension>
            </xs:simpleContent>  
          </xs:complexType>

        led mike

        C Offline
        C Offline
        Christian Wikander
        wrote on last edited by
        #3

        Thanks a bunch. It did the trick it seems. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups