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 to create XSD without repeating myself

How to create XSD without repeating myself

Scheduled Pinned Locked Moved XML / XSL
xmldatabasetutorialquestion
3 Posts 3 Posters 12 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.
  • M Offline
    M Offline
    Mikael Sterley
    wrote on last edited by
    #1

    I want to create an XSD schema that describes this XML:

    <report>
    <head showpagenumer="true">
    <line left="10" top="100" width="200" />
    <image left="10" top="100" path="logotype.jpg" />
    <text size="16" value="This is the header" />
    </head>

    <body leftmargin="20">
    <line left="50" top="200" width="200" />
    <image left="15" top="300" path="diagram.jpg" />
    <text size="12" value="Here is the diagram" />
    </body>

    <foot showdate="true">
    <line left="10" top="600" width="200" />
    <image left="10" top="650" path="signature.jpg" />
    <text size="12" value="This is the footer" />
    </foot>
    </report>

    Note the following: - I dont want to repeat the line, image and text descriptions three times in the XSD, since they will always be se same format in the head, body and foot nodes. - As you can see, the allowed attributes in the head, body and foot nodes are different Is it possible to create an XSD like this?

    G B 2 Replies Last reply
    0
    • M Mikael Sterley

      I want to create an XSD schema that describes this XML:

      <report>
      <head showpagenumer="true">
      <line left="10" top="100" width="200" />
      <image left="10" top="100" path="logotype.jpg" />
      <text size="16" value="This is the header" />
      </head>

      <body leftmargin="20">
      <line left="50" top="200" width="200" />
      <image left="15" top="300" path="diagram.jpg" />
      <text size="12" value="Here is the diagram" />
      </body>

      <foot showdate="true">
      <line left="10" top="600" width="200" />
      <image left="10" top="650" path="signature.jpg" />
      <text size="12" value="This is the footer" />
      </foot>
      </report>

      Note the following: - I dont want to repeat the line, image and text descriptions three times in the XSD, since they will always be se same format in the head, body and foot nodes. - As you can see, the allowed attributes in the head, body and foot nodes are different Is it possible to create an XSD like this?

      G Offline
      G Offline
      George Jonsson
      wrote on last edited by
      #2

      I guess you can do something like this: First create your own type.

      Then use it for your elements, head, body and foot

      1 Reply Last reply
      0
      • M Mikael Sterley

        I want to create an XSD schema that describes this XML:

        <report>
        <head showpagenumer="true">
        <line left="10" top="100" width="200" />
        <image left="10" top="100" path="logotype.jpg" />
        <text size="16" value="This is the header" />
        </head>

        <body leftmargin="20">
        <line left="50" top="200" width="200" />
        <image left="15" top="300" path="diagram.jpg" />
        <text size="12" value="Here is the diagram" />
        </body>

        <foot showdate="true">
        <line left="10" top="600" width="200" />
        <image left="10" top="650" path="signature.jpg" />
        <text size="12" value="This is the footer" />
        </foot>
        </report>

        Note the following: - I dont want to repeat the line, image and text descriptions three times in the XSD, since they will always be se same format in the head, body and foot nodes. - As you can see, the allowed attributes in the head, body and foot nodes are different Is it possible to create an XSD like this?

        B Offline
        B Offline
        Bernhard Hiller
        wrote on last edited by
        #3

        By the way, Visual Studio (version 2015, but perhaps also others) can do that job for you: open the xml file in the editor, and then click on the "Create Schema" icon in the toolbar.

        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