1

我已经学习了如何使用 xsd.exe 文件基于 XML 文件创建 XSD 文件。现在我有一个 site.xml 文件和一个作为 site.xsd 的示意图文件。我需要这个,因为我正在查看一个现有的应用程序并试图了解它是如何工作的,所以必须从基本步骤开始。现在一切正常,但我唯一的问题是,当我在 VS2010 中打开 site.xsd(原始应用程序)时,它显示了两个表(与我们在 SQL SERVER 和 Access 中的完全一样),其中显示了主键和外键,同时以图形方式链接)。我的也显示了表格,但它们没有以图形方式使用线条链接。

在生成 xsd 文件时我错过了哪一步?

谢谢。

<?xml version="1.0" ?>
<NewDataSet>
  <Products>
    <ProductID>355</ProductID>
    <CategoryID>16</CategoryID>
    <ModelNumber>RU007</ModelNumber>
    <ModelName>Rain Racer 2000</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>1499.9900</UnitCost>
    <Description>Looks like an ordinary bumbershoot, but don't be fooled! Simply place Rain Racer's tip on the ground and press the release latch. Within seconds, this ordinary rain umbrella converts into a two-wheeled gas-powered mini-scooter. Goes from 0 to 60 in 7.5 seconds - even in a driving rain! Comes in black, blue, and candy-apple red.</Description>
    <CategoryID1>16</CategoryID1>
    <CategoryName>Travel</CategoryName>
  </Products>
  <Products>
    <ProductID>356</ProductID>
    <CategoryID>20</CategoryID>
    <ModelNumber>STKY1</ModelNumber>
    <ModelName>Edible Tape</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>3.9900</UnitCost>
    <Description>The latest in personal survival gear, the STKY1 looks like a roll of ordinary office tape, but can save your life in an emergency.  Just remove the tape roll and place in a kettle of boiling water with mixed vegetables and a ham shank. In just 90 minutes you have a great tasking soup that really sticks to your ribs! Herbs and spices not included.</Description>
    <CategoryID1>20</CategoryID1>
    <CategoryName>General</CategoryName>
  </Products>
  <Products>
    <ProductID>371</ProductID>
    <CategoryID>18</CategoryID>
    <ModelNumber>WOWPEN</ModelNumber>
    <ModelName>Mighty Mighty Pen</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>129.9900</UnitCost>
    <Description>Some spies claim this item is more powerful than a sword. After examining the titanium frame, built-in blowtorch, and Nerf dart-launcher, we tend to agree! </Description>
    <CategoryID1>18</CategoryID1>
    <CategoryName>Munitions</CategoryName>
  </Products>
  <Products>
    <ProductID>372</ProductID>
    <CategoryID>20</CategoryID>
    <ModelNumber>ICNCU</ModelNumber>
    <ModelName>Perfect-Vision Glasses</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>129.9900</UnitCost>
    <Description>Avoid painful and potentially devastating laser eye surgery and contact lenses. Cheaper and more effective than a visit to the optometrist, these Perfect-Vision Glasses simply slide over nose and eyes and hook on ears. Suddenly you have 20/20 vision! Glasses also function as HUD (Heads Up Display) for most European sports cars manufactured after 1992.</Description>
    <CategoryID1>20</CategoryID1>
    <CategoryName>General</CategoryName>
  </Products>
  <Products>
    <ProductID>373</ProductID>
    <CategoryID>17</CategoryID>
    <ModelNumber>LKARCKT</ModelNumber>
    <ModelName>Pocket Protector Rocket Pack</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>1.9900</UnitCost>
    <Description>Any debonair spy knows that this accoutrement is coming back in style. Flawlessly protects the pockets of your short-sleeved oxford from unsightly ink and pencil marks. But there's more! Strap it on your back and it doubles as a rocket pack. Provides enough turbo-thrust for a 250-pound spy or a passel of small children. Maximum travel radius: 3000 miles.</Description>
    <CategoryID1>17</CategoryID1>
    <CategoryName>Protection</CategoryName>
  </Products>
  <Products>
    <ProductID>374</ProductID>
    <CategoryID>15</CategoryID>
    <ModelNumber>DNTGCGHT</ModelNumber>
    <ModelName>Counterfeit Creation Wallet</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>999.9900</UnitCost>
    <Description>Don't be caught penniless in Prague without this hot item! Instantly creates replicas of most common currencies! Simply place rocks and water in the wallet, close, open up again, and remove your legal tender!</Description>
    <CategoryID1>15</CategoryID1>
    <CategoryName>Deception</CategoryName>
  </Products>
  <Products>
    <ProductID>375</ProductID>
    <CategoryID>16</CategoryID>
    <ModelNumber>WRLD00</ModelNumber>
    <ModelName>Global Navigational System</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>29.9900</UnitCost>
    <Description>No spy should be without one of these premium devices. Determine your exact location with a quick flick of the finger. Calculate destination points by spinning, closing your eyes, and stopping it with your index finger.</Description>
    <CategoryID1>16</CategoryID1>
    <CategoryName>Travel</CategoryName>
  </Products>
  <Products>
    <ProductID>376</ProductID>
    <CategoryID>15</CategoryID>
    <ModelNumber>CITSME9</ModelNumber>
    <ModelName>Cloaking Device</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>9999.9900</UnitCost>
    <Description>Worried about detection on your covert mission? Confuse mission-threatening forces with this cloaking device. Powerful new features include string-activated pre-programmed phrases such as "Danger! Danger!", "Reach for the sky!", and other anti-enemy expressions. Hyper-reactive karate chop action deters even the most persistent villain.</Description>
    <CategoryID1>15</CategoryID1>
    <CategoryName>Deception</CategoryName>
  </Products>
  <Products>
    <ProductID>377</ProductID>
    <CategoryID>15</CategoryID>
    <ModelNumber>BME007</ModelNumber>
    <ModelName>Indentity Confusion Device</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>6.9900</UnitCost>
    <Description>Never leave on an undercover mission without our Identity Confusion Device! If a threatening person approaches, deploy the device and point toward the oncoming individual. The subject will fail to recognize you and let you pass unnoticed. Also works well on dogs.</Description>
    <CategoryID1>15</CategoryID1>
    <CategoryName>Deception</CategoryName>
  </Products>
  <Products>
    <ProductID>379</ProductID>
    <CategoryID>17</CategoryID>
    <ModelNumber>SHADE01</ModelNumber>
    <ModelName>Ultra Violet Attack Defender</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>89.9900</UnitCost>
    <Description>Be safe and suave. A spy wearing this trendy article of clothing is safe from ultraviolet ray-gun attacks. Worn correctly, the Defender deflects rays from ultraviolet weapons back to the instigator. As a bonus, also offers protection against harmful solar ultraviolet rays, equivalent to SPF 50.</Description>
    <CategoryID1>17</CategoryID1>
    <CategoryName>Protection</CategoryName>
  </Products>
  <Products>
    <ProductID>378</ProductID>
    <CategoryID>17</CategoryID>
    <ModelNumber>SQUKY1</ModelNumber>
    <ModelName>Guard Dog Pacifier</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>14.9900</UnitCost>
    <Description>Pesky guard dogs become a spy's best friend with the Guard Dog Pacifier. Even the most ferocious dogs suddenly act like cuddly kittens when they see this prop.  Simply hold the device in front of any threatening dogs, shaking it mildly.  For tougher canines, a quick squeeze emits an irresistible squeak that never fails to  place the dog under your control.</Description>
    <CategoryID1>17</CategoryID1>
    <CategoryName>Protection</CategoryName>
  </Products>
  <Products>
    <ProductID>382</ProductID>
    <CategoryID>20</CategoryID>
    <ModelNumber>CHEW99</ModelNumber>
    <ModelName>Survival Bar</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>6.9900</UnitCost>
    <Description>Survive for up to four days in confinement with this handy item. Disguised as a common eraser, it's really a high-calorie food bar. Stranded in hostile territory without hope of nourishment? Simply break off a small piece of the eraser and chew vigorously for at least twenty minutes. Developed by the same folks who created freeze-dried ice cream, powdered drink mix, and glow-in-the-dark shoelaces.</Description>
    <CategoryID1>20</CategoryID1>
    <CategoryName>General</CategoryName>
  </Products>
  <Products>
    <ProductID>402</ProductID>
    <CategoryID>20</CategoryID>
    <ModelNumber>C00LCMB1</ModelNumber>
    <ModelName>Telescoping Comb</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>399.9900</UnitCost>
    <Description>Use the Telescoping Comb to track down anyone, anywhere! Deceptively simple, this is no normal comb. Flip the hidden switch and two telescoping lenses project forward creating a surprisingly powerful set of binoculars (50X). Night-vision add-on is available for midnight hour operations.</Description>
    <CategoryID1>20</CategoryID1>
    <CategoryName>General</CategoryName>
  </Products>
  <Products>
    <ProductID>384</ProductID>
    <CategoryID>19</CategoryID>
    <ModelNumber>FF007</ModelNumber>
    <ModelName>Eavesdrop Detector</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>99.9900</UnitCost>
    <Description>Worried that counteragents have placed listening devices in your home or office? No problem! Use our bug-sweeping wiener to check your surroundings for unwanted surveillance devices. Just wave the frankfurter around the room ... when bugs are detected, this "foot-long" beeps! Comes complete with bun, relish, mustard, and headphones for privacy.</Description>
    <CategoryID1>19</CategoryID1>
    <CategoryName>Tools</CategoryName>
  </Products>
  <Products>
    <ProductID>385</ProductID>
    <CategoryID>16</CategoryID>
    <ModelNumber>LNGWADN</ModelNumber>
    <ModelName>Escape Cord</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>13.9900</UnitCost>
    <Description>Any agent assigned to mountain terrain should carry this ordinary-looking extension cord ... except that it's really a rappelling rope! Pull quickly on each end to convert the electrical cord into a rope capable of safely supporting up to two agents. Comes in various sizes including Mt McKinley, Everest, and Kilimanjaro. WARNING: To prevent serious injury, be sure to disconnect from wall socket before use.</Description>
    <CategoryID1>16</CategoryID1>
    <CategoryName>Travel</CategoryName>
  </Products>
  <Products>
    <ProductID>386</ProductID>
    <CategoryID>17</CategoryID>
    <ModelNumber>1MOR4ME</ModelNumber>
    <ModelName>Cocktail Party Pal</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>69.9900</UnitCost>
    <Description>Do your assignments have you flitting from one high society party to the next? Worried about keeping your wits about you as you mingle witih the champagne-and-caviar crowd? No matter how many drinks you're offered, you can safely operate even the most complicated heavy machinery as long as you use our model 1MOR4ME alcohol-neutralizing coaster. Simply place the beverage glass on the patented circle to eliminate any trace of alcohol in the drink.</Description>
    <CategoryID1>17</CategoryID1>
    <CategoryName>Protection</CategoryName>
  </Products>
  <Products>
    <ProductID>387</ProductID>
    <CategoryID>20</CategoryID>
    <ModelNumber>SQRTME1</ModelNumber>
    <ModelName>Remote Foliage Feeder</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>9.9900</UnitCost>
    <Description>Even spies need to care for their office plants.  With this handy remote watering device, you can water your flowers as a spy should, from the comfort of your chair.  Water your plants from up to 50 feet away.  Comes with an optional aiming system that can be mounted to the top for improved accuracy.</Description>
    <CategoryID1>20</CategoryID1>
    <CategoryName>General</CategoryName>
  </Products>
  <Products>
    <ProductID>388</ProductID>
    <CategoryID>20</CategoryID>
    <ModelNumber>ICUCLRLY00</ModelNumber>
    <ModelName>Contact Lenses</ModelName>
    <ProductImage>image.GIF</ProductImage>
    <UnitCost>59.9900</UnitCost>
    <Description>Traditional binoculars and night goggles can be bulky, especially for assignments in confined areas. The problem is solved with these patent-pending contact lenses, which give excellent visibility up to 100 miles. New feature: now with a night vision feature that permits you to see in complete darkness! Contacts now come in a variety of fashionable colors for coordinating with your favorite ensembles.</Description>
    <CategoryID1>20</CategoryID1>
    <CategoryName>General</CategoryName>
  </Products>
  <Products>
    <ProductID>389</ProductID>
    <CategoryID>20</CategoryID>
    <ModelNumber>OPNURMIND</ModelNumber>
    <ModelName>Telekinesis Spoon</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>2.9900</UnitCost>
    <Description>Learn to move things with your mind! Broaden your mental powers using this training device to hone telekinesis skills. Simply look at the device, concentrate, and repeat "There is no spoon" over and over.</Description>
    <CategoryID1>20</CategoryID1>
    <CategoryName>General</CategoryName>
  </Products>
  <Products>
    <ProductID>390</ProductID>
    <CategoryID>19</CategoryID>
    <ModelNumber>ULOST007</ModelNumber>
    <ModelName>Rubber Stamp Beacon</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>129.9900</UnitCost>
    <Description>With the Rubber Stamp Beacon, you'll never get lost on your missions again. As you proceed through complicated terrain, stamp a stationary object with this device. Once an object has been stamped, the stamp's patented ink will emit a signal that can be detected up to 153.2 miles away by the receiver embedded in the device's case. WARNING: Do not expose ink to water.</Description>
    <CategoryID1>19</CategoryID1>
    <CategoryName>Tools</CategoryName>
  </Products>
  <Products>
    <ProductID>391</ProductID>
    <CategoryID>17</CategoryID>
    <ModelNumber>BSUR2DUC</ModelNumber>
    <ModelName>Bullet Proof Facial Tissue</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>79.9900</UnitCost>
    <Description>Being a spy can be dangerous work. Our patented Bulletproof Facial Tissue gives a spy confidence that any bullets in the vicinity risk-free. Unlike traditional bulletproof devices, these lightweight tissues have amazingly high tensile strength. To protect the upper body, simply place a tissue in your shirt pocket. To protect the lower body, place a tissue in your pants pocket. If you do not have any pockets, be sure to check out our Bulletproof Tape. 100 tissues per box. WARNING: Bullet must not be moving for device to successfully stop penetration.</Description>
    <CategoryID1>17</CategoryID1>
    <CategoryName>Protection</CategoryName>
  </Products>
  <Products>
    <ProductID>393</ProductID>
    <CategoryID>20</CategoryID>
    <ModelNumber>NOBOOBOO4U</ModelNumber>
    <ModelName>Speed Bandages</ModelName>
    <ProductImage>image.GIF</ProductImage>
    <UnitCost>3.9900</UnitCost>
    <Description>Even spies make mistakes.  Barbed wire and guard dogs pose a threat of injury for the active spy.  Use our special bandages on cuts and bruises to rapidly heal the injury.  Depending on the severity of the wound, the bandages can take between 10 to 30 minutes to completely heal the injury.</Description>
    <CategoryID1>20</CategoryID1>
    <CategoryName>General</CategoryName>
  </Products>
  <Products>
    <ProductID>394</ProductID>
    <CategoryID>15</CategoryID>
    <ModelNumber>BHONST93</ModelNumber>
    <ModelName>Correction Fluid</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>1.9900</UnitCost>
    <Description>Disguised as typewriter correction fluid, this scientific truth serum forces subjects to correct anything not perfectly true. Simply place a drop of the special correction fluid on the tip of the subject's nose. Within seconds, the suspect will automatically correct every lie. Effects from Correction Fluid last approximately 30 minutes per drop. WARNING: Discontinue use if skin appears irritated.</Description>
    <CategoryID1>15</CategoryID1>
    <CategoryName>Deception</CategoryName>
  </Products>
  <Products>
    <ProductID>396</ProductID>
    <CategoryID>19</CategoryID>
    <ModelNumber>BPRECISE00</ModelNumber>
    <ModelName>Dilemma Resolution Device</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>11.9900</UnitCost>
    <Description>Facing a brick wall? Stopped short at a long, sheer cliff wall?  Carry our handy lightweight calculator for just these emergencies. Quickly enter in your dilemma and the calculator spews out the best solutions to the problem.   Manufacturer Warning: Use at own risk. Suggestions may lead to adverse outcomes.</Description>
    <CategoryID1>19</CategoryID1>
    <CategoryName>Tools</CategoryName>
  </Products>
  <Products>
    <ProductID>397</ProductID>
    <CategoryID>14</CategoryID>
    <ModelNumber>LSRPTR1</ModelNumber>
    <ModelName>Nonexplosive Cigar</ModelName>
    <ProductImage>397.gif</ProductImage>
    <UnitCost>29.9900</UnitCost>
    <Description>Contrary to popular spy lore, not all cigars owned by spies explode! Best used during mission briefings, our Nonexplosive Cigar is really a cleverly-disguised, top-of-the-line, precision laser pointer. Make your next presentation a hit.</Description>
    <CategoryID1>14</CategoryID1>
    <CategoryName>Communications</CategoryName>
  </Products>
  <Products>
    <ProductID>399</ProductID>
    <CategoryID>20</CategoryID>
    <ModelNumber>QLT2112</ModelNumber>
    <ModelName>Document Transportation System</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>299.9900</UnitCost>
    <Description>Keep your stolen Top Secret documents in a place they'll never think to look!  This patent leather briefcase has multiple pockets to keep documents organized.  Top quality craftsmanship to last a lifetime.</Description>
    <CategoryID1>20</CategoryID1>
    <CategoryName>General</CategoryName>
  </Products>
  <Products>
    <ProductID>400</ProductID>
    <CategoryID>15</CategoryID>
    <ModelNumber>THNKDKE1</ModelNumber>
    <ModelName>Hologram Cufflinks</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>799.9900</UnitCost>
    <Description>Just point, and a turn of the wrist will project a hologram of you up to 100 yards away. Sneaking past guards will be child's play when you've sent them on a wild goose chase. Note: Hologram adds ten pounds to your appearance.</Description>
    <CategoryID1>15</CategoryID1>
    <CategoryName>Deception</CategoryName>
  </Products>
  <Products>
    <ProductID>401</ProductID>
    <CategoryID>14</CategoryID>
    <ModelNumber>TCKLR1</ModelNumber>
    <ModelName>Fake Moustache Translator</ModelName>
    <ProductImage>401.gif</ProductImage>
    <UnitCost>599.9900</UnitCost>
    <Description>Fake Moustache Translator attaches between nose and mouth to double as a language translator and identity concealer. Sophisticated electronics translate your voice into the desired language. Wriggle your nose to toggle between Spanish, English, French, and Arabic. Excellent on diplomatic missions.</Description>
    <CategoryID1>14</CategoryID1>
    <CategoryName>Communications</CategoryName>
  </Products>
  <Products>
    <ProductID>404</ProductID>
    <CategoryID>14</CategoryID>
    <ModelNumber>JWLTRANS6</ModelNumber>
    <ModelName>Interpreter Earrings</ModelName>
    <ProductImage>404.gif</ProductImage>
    <UnitCost>459.9900</UnitCost>
    <Description>The simple elegance of our stylish monosex earrings accents any wardrobe, but their clean lines mask the sophisticated technology within. Twist the lower half to engage a translator function that intercepts spoken words in any language and converts them to the wearer's native tongue. Warning: do not use in conjunction with our Fake Moustache Translator product, as the resulting feedback loop makes any language sound like Pig Latin.</Description>
    <CategoryID1>14</CategoryID1>
    <CategoryName>Communications</CategoryName>
  </Products>
  <Products>
    <ProductID>406</ProductID>
    <CategoryID>19</CategoryID>
    <ModelNumber>GRTWTCH9</ModelNumber>
    <ModelName>Multi-Purpose Watch</ModelName>
    <ProductImage>image.gif</ProductImage>
    <UnitCost>399.9900</UnitCost>
    <Description>In the tradition of famous spy movies, the Multi Purpose Watch comes with every convenience! Installed with lighter, TV, camera, schedule-organizing software, MP3 player, water purifier, spotlight, and tire pump. Special feature: Displays current date and time. Kitchen sink add-on will be available in the fall of 2001.</Description>
    <CategoryID1>19</CategoryID1>
    <CategoryName>Tools</CategoryName>
  </Products>
  <Categories>
    <CategoryID>14</CategoryID>
    <CategoryName>Communications</CategoryName>
  </Categories>
  <Categories>
    <CategoryID>15</CategoryID>
    <CategoryName>Deception</CategoryName>
  </Categories>
  <Categories>
    <CategoryID>16</CategoryID>
    <CategoryName>Travel</CategoryName>
  </Categories>
  <Categories>
    <CategoryID>17</CategoryID>
    <CategoryName>Protection</CategoryName>
  </Categories>
  <Categories>
    <CategoryID>18</CategoryID>
    <CategoryName>Munitions</CategoryName>
  </Categories>
  <Categories>
    <CategoryID>19</CategoryID>
    <CategoryName>Tools</CategoryName>
  </Categories>
  <Categories>
    <CategoryID>20</CategoryID>
    <CategoryName>General</CategoryName>
  </Categories>
</NewDataSet>

它的 XSD 或原理图是:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="Products">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="ProductID" type="xs:string" minOccurs="0" />
              <xs:element name="CategoryID" type="xs:string" minOccurs="0" />
              <xs:element name="ModelNumber" type="xs:string" minOccurs="0" />
              <xs:element name="ModelName" type="xs:string" minOccurs="0" />
              <xs:element name="ProductImage" type="xs:string" minOccurs="0" />
              <xs:element name="UnitCost" type="xs:string" minOccurs="0" />
              <xs:element name="Description" type="xs:string" minOccurs="0" />
              <xs:element name="CategoryID1" type="xs:string" minOccurs="0" />
              <xs:element name="CategoryName" type="xs:string" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Categories">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="CategoryID" type="xs:string" minOccurs="0" />
              <xs:element name="CategoryName" type="xs:string" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>
4

1 回答 1

1

听起来您的问题与 XSD 推理引擎使用的“设计风格”有关。这是一个受欢迎的问题,我已经在这里回答了一段时间。

基本上,俄罗斯娃娃风格的 XSD(如在您的案例中创建的 XSD)会产生一个缺少关系的数据集。此样式不使用全局或元素声明(根除外)。通过将 global 设置为与根元素关联的类型,您的关系应该会显示出来。

根据您更新的帖子:

这就是您的 XSD 作为数据集的样子:

在此处输入图像描述

修改为使用全局类型(类型 T):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="NewDataSet" msdata:UseCurrentLocale="true" type="T"/>
    <xs:complexType name="T">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="Products">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="ProductID" type="xs:string" minOccurs="0" />
              <xs:element name="CategoryID" type="xs:string" minOccurs="0" />
              <xs:element name="ModelNumber" type="xs:string" minOccurs="0" />
              <xs:element name="ModelName" type="xs:string" minOccurs="0" />
              <xs:element name="ProductImage" type="xs:string" minOccurs="0" />
              <xs:element name="UnitCost" type="xs:string" minOccurs="0" />
              <xs:element name="Description" type="xs:string" minOccurs="0" />
              <xs:element name="CategoryID1" type="xs:string" minOccurs="0" />
              <xs:element name="CategoryName" type="xs:string" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Categories">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="CategoryID" type="xs:string" minOccurs="0" />
              <xs:element name="CategoryName" type="xs:string" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
</xs:schema>

如下所示。

在此处输入图像描述

查看您的 XSD,您的问题很可能会有所不同……也许您希望看到类别和产品之间的关系?基于类别ID?

如果是这样,那么您需要使用 Microsoft 特定标记;有关介绍,参阅本文,有关详细信息,请参阅本文。

于 2013-09-24T13:37:17.937 回答