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. Different XSD representation of an element.

Different XSD representation of an element.

Scheduled Pinned Locked Moved XML / XSL
xmlhelpquestion
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
    Comp_Users
    wrote on last edited by
    #1

    Hi All, I used an Altova XMLSpy tool generate an XSD file for my XML file. The xsd equivalent for an simple xml element "Mfg" generated via the tool was

    <xs:element name="Mfg">
    xs:simpleType
    <xs:restriction base="xs:string">
    </xs:restriction>
    </xs:simpleType>
    </xs:element>

    I found out that modifying the above xsd to the one below just works fine.

    <xs:element name="Mfg" type="xs:string"/>

    Just wanted to know if these 2 XSD representations for the xml element are the same or are they different. Do the elements xs:simpleType, xs:restriction above have any signifance int he above mentioned scenario? (Actually tried going through MSDN but conldn't infer much info). It would be of great help if somebody points out the differences between the 2 if any and brief on it's significance.

    S 1 Reply Last reply
    0
    • C Comp_Users

      Hi All, I used an Altova XMLSpy tool generate an XSD file for my XML file. The xsd equivalent for an simple xml element "Mfg" generated via the tool was

      <xs:element name="Mfg">
      xs:simpleType
      <xs:restriction base="xs:string">
      </xs:restriction>
      </xs:simpleType>
      </xs:element>

      I found out that modifying the above xsd to the one below just works fine.

      <xs:element name="Mfg" type="xs:string"/>

      Just wanted to know if these 2 XSD representations for the xml element are the same or are they different. Do the elements xs:simpleType, xs:restriction above have any signifance int he above mentioned scenario? (Actually tried going through MSDN but conldn't infer much info). It would be of great help if somebody points out the differences between the 2 if any and brief on it's significance.

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      They are exactly the same because the restriction specified doesn't actually restrict the base type (i.e. xs:string). Here's an example of a restriction on a string using a regular expression pattern that could be used as a variable or type name:

      xs:simpleType
      <xs:restriction baseType="xs:string">
      <xs:pattern value="[A-Za-z][A-Za-z0-9_]*"/>
      </xs:restriction>
      </xs:simpleType>

      [edit]I recommend downloading the Essential XML Quick Reference PDF[^], as it's a very easy to use reference to XML technologies, including XSD.[/edit]

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      C 1 Reply Last reply
      0
      • S Stuart Dootson

        They are exactly the same because the restriction specified doesn't actually restrict the base type (i.e. xs:string). Here's an example of a restriction on a string using a regular expression pattern that could be used as a variable or type name:

        xs:simpleType
        <xs:restriction baseType="xs:string">
        <xs:pattern value="[A-Za-z][A-Za-z0-9_]*"/>
        </xs:restriction>
        </xs:simpleType>

        [edit]I recommend downloading the Essential XML Quick Reference PDF[^], as it's a very easy to use reference to XML technologies, including XSD.[/edit]

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        C Offline
        C Offline
        Comp_Users
        wrote on last edited by
        #3

        Oh. I see. Thanks for the info.

        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