简体   繁体   English

将xml链接到xml模式(xsd)

[英]linking xml to an xml-schema (xsd)

Im workinng with The Recipe Exchang Markup Language. 我正在使用“食谱交换标记语言”。 My task is to extand XML-Schema (reml.xsd). 我的任务是扩展XML模式(reml.xsd)。 After adding some new simple and complex types in reml.xsd i noticed that in my recipes.xml i dont have any "call" to reml.xsd. 在reml.xsd中添加了一些新的简单和复杂类型之后,我注意到在我的recipes.xml中,我对reml.xsd没有任何“调用”。 I added (like in exemple on http://www.w3schools.com/schema ) : 我添加了(例如http://www.w3schools.com/schema上的示例 ):

 <meal name="Meatballs"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:SchemaLocation="reml.xsd"    >

But i dont see any difference after adding this lines. 但是添加这些行后我看不到任何区别。

Here comes my codes: .XML 我的代码如下:.XML

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="reml.xsl" type="text/xsl"?>


  <reml version="0.5" language="eng" country="us">
 <menu name="Menu"><userData></userData>

  <meal name="Meatballs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:SchemaLocation="reml.xsd"            ><userData></userData>
  <mealItem name="Swedish meatballs" servings="9" prepTime="30 min">
  <userData></userData><createDate>2013-09-26</createDate>
   <updateDate>2013-09-29</updateDate>
   <location locality="Sweden" /><difficulty>Normal</difficulty>
   <procedure>
   <procedureText>In a large bowl, beat eggs and milk. Add bread; mix gently and         stand for 5 
    minutes. Add beef, onion, baking powder, salt and pepper; mix well (mixture  
   will be soft). Shape into 1-in. balls.
   In a large skillet, brown meatballs, a d 
   few at a time, in shortening. Place in an 
   ungreased 3-q. baking dish. In a  
   bowl, stir soups and milk until smooth; pour 
   over meatballs. Bake, uncovered,  
   at 350° for 1 hour. Sprinkle with parsley.
   </procedureText>
   </procedure>
   <fb><usertext>Hej text från user</usertext></fb>
    <author name="Taste of Home " emailAddress="maxin@kth.se"/>
     <nutrition calories="399" />
      <ingredient name="Eggs" quantity-integer="4">
     <IUnit><IUnitArbitrary></IUnitArbitrary></IUnit></ingredient>
      <ingredient name="milk" quantity-integer="1">
    <IUnit><IUnitArbitrary>cup</IUnitArbitrary></IUnit></ingredient>
   <ingredient name="torn white bread" quantity-integer="8">
   <IUnit><IUnitArbitrary>slice</IUnitArbitrary></IUnit></ingredient>
   <ingredient name="ground beef" quantity-integer="2">
    <IUnit><IUnitArbitrary>pound</IUnitArbitrary></IUnit></ingredient>

     <IUnit><IUnitArbitrary>cup</IUnitArbitrary></IUnit></ingredient>
     <ingredient name="pepper" quantity-integer="4">
    <IUnit><IUnitArbitrary>teaspoon</IUnitArbitrary></IUnit></ingredient>
    <ingredient name="shortening" quantity-integer="2">
   <IUnit><IUnitArbitrary>tablespoon</IUnitArbitrary></IUnit></ingredient>
   <ingredient name="condensed cream of chicken soup, undiluted" quantity-integer="2">
   <IUnit><IUnitArbitrary>can</IUnitArbitrary></IUnit></ingredient>
          <ingredient name="condensed cream of mushroom soup, 
        undiluted"              quantity              integer="2">
     <IUnit><IUnitArbitrary>can</IUnitArbitrary></IUnit></ingredient>
    <ingredient name="evaporated milk" quantity-integer="1">
         <IUnit><IUnitArbitrary>can</IUnitArbitrary></IUnit></ingredient>
        <ingredient name="Minced fresh parsley" quantity-integer="2">
        <IUnit><IUnitArbitrary>ton</IUnitArbitrary></IUnit></ingredient>
    <category><CategoryArbitrary>Swedish dishes</CategoryArbitrary></category>
  <feedback><usertext> *Jag tycker bla bla * asdasd </usertext></feedback></mealItem>

    </meal>
     </menu>
     </reml>

Here comes my .XSD: 这是我的.XSD:

<?xml version="1.0"?>
   <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

  >
<xsd:annotation>
    <xsd:documentation xml:lang="en">
The REML schema for the food recipe exchange markup language.
Version 0.5, copyright 2005, Gary Gocek, all rights reserved.
Full permission granted to freely use, redistribute and promote
this schema.  Please retain the copyright notice.
When updating, add the new version number to the VersionType
enumeration. This supports backward compatibilty.
Home: http://www.sourceforge.net/projects/reml/
    </xsd:documentation>
</xsd:annotation>
<xsd:element name="reml" type="remlType" />
<xsd:complexType name="remlType">
    <xsd:annotation>
        <xsd:documentation xml:lang="en">
The type definition of the root reml element.
The root element has the attributes version, language and country.
The root element contains the elements vendor, vendorData and menu.
        </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
        <xsd:element name="vendor" type="VendorType" minOccurs="0"
                    maxOccurs="unbounded" />
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
                maxOccurs="unbounded" />
        <xsd:element name="menu" type="MenuType" minOccurs="1" 
              maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="version" type="VersionType" use="required" />
    <xsd:attribute name="language" type="xsd:string" use="optional"  
          default="eng" />
    <xsd:attribute name="country" type="xsd:string" use="optional"     
        default="us" />
</xsd:complexType>
<xsd:simpleType name="VersionType">
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="0.1" />
        <xsd:enumeration value="0.2" />
        <xsd:enumeration value="0.3" />
        <xsd:enumeration value="0.4" />
        <xsd:enumeration value="0.5" />
    </xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="VendorType">
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
              maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required" />
    <xsd:attribute name="emailAddress" type="xsd:string" use="optional" />
    <xsd:attribute name="postalAddress" type="xsd:string" use="optional" />
    <xsd:attribute name="phoneNumber" type="xsd:string" use="optional" />
    <xsd:attribute name="URL" type="xsd:string" use="optional" />
</xsd:complexType>
<xsd:complexType name="MenuType">
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
              maxOccurs="unbounded" />
        <xsd:element name="userData" type="xsd:string" minOccurs="0" 
                  maxOccurs="unbounded" />
        <xsd:element name="location" type="LocationType" 
           minOccurs="0"                maxOccurs="unbounded" />
        <xsd:element name="meal" type="MealType" minOccurs="0"  
                 maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
<xsd:complexType name="LocationType">
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
            maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="country" type="xsd:string" use="optional" />
    <xsd:attribute name="region" type="xsd:string" use="optional" />
    <xsd:attribute name="locality" type="xsd:string" use="optional" />
    <xsd:attribute name="useWhenCurrent" type="xsd:boolean" use="optional" 
              default="true" />
</xsd:complexType>
<xsd:complexType name="ScheduleType">
    <xsd:annotation>
        <xsd:documentation xml:lang="en">
            A dateTime looks like   1999-05-31T13:20:00.000-05:00
        </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
              maxOccurs="unbounded" />
        <xsd:element name="nextPrepDate" type="xsd:dateTime" minOccurs="0" 
             maxOccurs="1" />
    </xsd:sequence>
</xsd:complexType>
<xsd:complexType name="MealType">
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
         maxOccurs="unbounded" />
        <xsd:element name="userData" type="xsd:string" minOccurs="0" 
            maxOccurs="unbounded" />
        <xsd:element name="location" type="LocationType" minOccurs="0"
               maxOccurs="unbounded" />
        <xsd:element name="cost" type="CostType" minOccurs="0" 
                    maxOccurs="1" />
        <xsd:element name="mealItem" type="MealItemType" minOccurs="0"
                  maxOccurs="unbounded" />
        <xsd:element name="schedule" type="ScheduleType" minOccurs="0" 
               maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="optional" />
    <xsd:attribute name="servings" type="xsd:long" use="optional" />
</xsd:complexType>
<xsd:complexType name="CostType">
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0"
        maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="unitAmount" type="xsd:decimal" use="optional" />
    <xsd:attribute name="totalAmount" type="xsd:decimal" use="optional" />
    <xsd:attribute name="currency" type="xsd:string" use="optional" />
</xsd:complexType>
<xsd:complexType name="MealItemType">
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
         maxOccurs="unbounded" />
        <xsd:element name="userData" type="xsd:string" minOccurs="0" 
              maxOccurs="unbounded" />
        <xsd:element name="createDate" type="xsd:date" minOccurs="0" 
                     maxOccurs="1" />
        <xsd:element name="updateDate" type="xsd:date" minOccurs="0" 
             maxOccurs="1" />
        <xsd:element name="location" type="LocationType" minOccurs="0" 
               maxOccurs="unbounded" />
        <xsd:element name="cost" type="CostType" minOccurs="0" 
               maxOccurs="1" />
        <xsd:element name="difficulty" type="DifficultyType" minOccurs="0" 
              maxOccurs="1" />
        <xsd:element name="procedure" type="ProcedureType" minOccurs="0"
                          maxOccurs="unbounded" />
        <xsd:element name="fb" type="FeedBack" minOccurs="0" 
                 maxOccurs="unbounded" />
        <xsd:element name="author" type="AuthorType" minOccurs="0" 
                maxOccurs="unbounded" />
        <xsd:element name="nutrition" type="NutritionType" minOccurs="0" 
                maxOccurs="1" />
        <xsd:element name="ingredient" type="IngredientType" minOccurs="0" 
               maxOccurs="unbounded" />
        <xsd:element name="category" type="CategoryType" minOccurs="0" 
             maxOccurs="unbounded" />
        <xsd:element name="schedule" type="ScheduleType" minOccurs="0" 
               maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required" />
    <xsd:attribute name="servings" type="xsd:long" use="optional" />
    <xsd:attribute name="pictureFile" type="xsd:string" use="optional" />
    <xsd:attribute name="prepTime" type="xsd:string" use="optional" />
    <xsd:attribute name="procedureTime" type="xsd:string" use="optional" />
</xsd:complexType>
<xsd:simpleType name="DifficultyType">
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="Beginner" />
        <xsd:enumeration value="Normal" />
        <xsd:enumeration value="Expert" />
    </xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="ProcedureType">
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
              maxOccurs="unbounded" />
        <xsd:element name="prepText" type="xsd:string" minOccurs="0" 
              maxOccurs="1" />
        <xsd:element name="procedureText" type="xsd:string" minOccurs="0" 
                maxOccurs="1" />
        <xsd:element name="location" type="LocationType" minOccurs="0" 
                maxOccurs="unbounded" />
    </xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FeedBack">
    <xsd:sequence>
        <xsd:element name="usertext" type="xsd:string" minOccurs="0" 
          maxOccurs="1" />

    </xsd:sequence>
</xsd:complexType>
<xsd:complexType name="AuthorType">
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
        maxOccurs="unbounded" />

    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required" />
    <xsd:attribute name="emailAddress" type="xsd:string" use="required" />
    <xsd:attribute name="postalAddress" type="xsd:string" use="optional" />
    <xsd:attribute name="phoneNumber" type="xsd:string" use="optional" />
    <xsd:attribute name="URL" type="xsd:string" use="optional" />
</xsd:complexType>
<xsd:complexType name="IngredientType">
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
                 maxOccurs="unbounded" />
        <xsd:element name="userData" type="xsd:string" minOccurs="0"
            maxOccurs="unbounded" />
        <xsd:element name="location" type="LocationType" minOccurs="0"
                 maxOccurs="unbounded" />
        <xsd:element name="cost" type="CostType" minOccurs="0" 
                     maxOccurs="1" />
        <xsd:element name="nutrition" type="NutritionType" minOccurs="0" 
                maxOccurs="1" />
        <xsd:element name="substitute" type="SubstituteType" minOccurs="0"
                     maxOccurs="1" />
        <xsd:element name="IUnit" type="IUnitType" minOccurs="0" 
                      maxOccurs="1" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required" />
    <xsd:attribute name="quantity-integer" type="xsd:long" use="optional" />
    <xsd:attribute name="quantity-numerator" type="xsd:long" use="optional" />
    <xsd:attribute name="quantity-denominator" type="xsd:long" use="optional" 
            />
</xsd:complexType>
<xsd:complexType name="SubstituteType">
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
                   maxOccurs="unbounded" />
        <xsd:element name="userData" type="xsd:string" minOccurs="0" 
                      maxOccurs="unbounded" />
        <xsd:element name="IUnit" type="IUnitType" minOccurs="0" 
                 maxOccurs="1" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required" />
    <xsd:attribute name="quantity-integer" type="xsd:long" use="optional" />
    <xsd:attribute name="quantity-numerator" type="xsd:long" use="optional" />
    <xsd:attribute name="quantity-denominator" type="xsd:long" 
               use="optional"    />
</xsd:complexType>
<xsd:complexType name="NutritionType">
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
                        maxOccurs="unbounded" />
        <xsd:element name="nutritionItem" type="NutritionItemType" 
                     minOccurs="0" maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="calories" type="xsd:decimal" use="optional" />
    <xsd:attribute name="pctCalFromFat" type="xsd:decimal" use="optional" />
    <xsd:attribute name="pctCalFromProtein" type="xsd:decimal" use="optional" 
                 />
    <xsd:attribute name="pctCalFromCarbs" type="xsd:decimal" use="optional" />
</xsd:complexType>
<xsd:complexType name="NutritionItemType">
    <xsd:sequence>
        <xsd:element name="vendorData" type="xsd:string" minOccurs="0" 
                    maxOccurs="unbounded" />
        <xsd:element name="NUnit" type="NUnitType" minOccurs="0" 
                  maxOccurs="1" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="optional" />
    <xsd:attribute name="pctDailyReq" type="xsd:decimal" use="optional" />
    <xsd:attribute name="amount" type="xsd:decimal" use="optional" />
</xsd:complexType>
<xsd:complexType name="NUnitType">
    <xsd:choice>
        <xsd:element name="NUnitArbitrary" type="xsd:string" />
        <xsd:element name="NUnitEnum" type="NUnitEnumType" />
    </xsd:choice>
</xsd:complexType>
<xsd:simpleType name="NUnitEnumType">
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="gram" />
        <xsd:enumeration value="g" />
      <xsd:enumeration value="ton" />
        <xsd:enumeration value="microgram" />
        <xsd:enumeration value="mcg" />
        <xsd:enumeration value="milligram" />
        <xsd:enumeration value="mg" />
        <xsd:enumeration value="kilogram" />
        <xsd:enumeration value="kg" />
        <xsd:enumeration value="joule" />
        <xsd:enumeration value="kilojoule" />
        <xsd:enumeration value="calorie" />

        <xsd:enumeration value="InternationalUnit" />
        <xsd:enumeration value="IU" />
        <xsd:enumeration value="" />
    </xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="IUnitType">
    <xsd:choice>
        <xsd:element name="IUnitArbitrary" type="xsd:string" />
        <xsd:element name="IUnitEnum" type="IUnitEnumType" />
    </xsd:choice>
</xsd:complexType>
<xsd:simpleType name="IUnitEnumType">
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="bag" />
        <xsd:enumeration value="ton" />
        <xsd:enumeration value="barrel" />
        <xsd:enumeration value="bottle" />
        <xsd:enumeration value="box" />
        <xsd:enumeration value="bunch" />
        <xsd:enumeration value="bushel" />
        <xsd:enumeration value="can" />
        <xsd:enumeration value="case" />
        <xsd:enumeration value="centimeter" />
        <xsd:enumeration value="cm" />
        <xsd:enumeration value="clove" />
        <xsd:enumeration value="cup" />
        <xsd:enumeration value="C" />
        <xsd:enumeration value="dash" />
        <xsd:enumeration value="drum" />
        <xsd:enumeration value="ear" />

        <xsd:enumeration value="gallon" />
        <xsd:enumeration value="gal" />
        <xsd:enumeration value="gram" />
        <xsd:enumeration value="g" />
        <xsd:enumeration value="handful" />
        <xsd:enumeration value="inch" />
        <xsd:enumeration value="in" />
        <xsd:enumeration value="jar" />
        <xsd:enumeration value="kilogram" />
        <xsd:enumeration value="kg" />
        <xsd:enumeration value="kilometer" />
        <xsd:enumeration value="k" />
        <xsd:enumeration value="lb" />
        <xsd:enumeration value="liter" />
        <xsd:enumeration value="li" />
        <xsd:enumeration value="meter" />
        <xsd:enumeration value="m" />
        <xsd:enumeration value="mile" />
        <xsd:enumeration value="mi" />
        <xsd:enumeration value="milliliter" />
        <xsd:enumeration value="ml" />
        <xsd:enumeration value="millimeter" />
        <xsd:enumeration value="mm" />
        <xsd:enumeration value="ounce" />
        <xsd:enumeration value="oz" />
        <xsd:enumeration value="package" />
        <xsd:enumeration value="pkg" />
        <xsd:enumeration value="part" />
        <xsd:enumeration value="peck" />
        <xsd:enumeration value="piece" />
        <xsd:enumeration value="pinch" />
        <xsd:enumeration value="pint" />
        <xsd:enumeration value="pt" />
        <xsd:enumeration value="pound" />
        <xsd:enumeration value="quart" />
        <xsd:enumeration value="qt" />
        <xsd:enumeration value="shot" />
        <xsd:enumeration value="slice" />
        <xsd:enumeration value="sprig" />
        <xsd:enumeration value="stick" />
        <xsd:enumeration value="splash" />
        <xsd:enumeration value="tablespoon" />
        <xsd:enumeration value="tbsp" />
        <xsd:enumeration value="T" />
        <xsd:enumeration value="teaspoon" />
        <xsd:enumeration value="tsp" />
        <xsd:enumeration value="t" />
        <xsd:enumeration value="yard" />
        <xsd:enumeration value="yd" />
        <xsd:enumeration value="" />
    </xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="CategoryType">
    <xsd:choice>
        <xsd:element name="CategoryArbitrary" type="xsd:string" />
        <xsd:element name="CategoryEnum" type="CategoryEnumType" />
    </xsd:choice>
</xsd:complexType>
<xsd:simpleType name="CategoryEnumType">
     <xsd:restriction base="xsd:string">
        <xsd:enumeration value="appetizer" />
        <xsd:enumeration value="beef" />
        <xsd:enumeration value="beverage" />
        <xsd:enumeration value="bread" />
        <xsd:enumeration value="cocktail" />
        <xsd:enumeration value="dairy" />
        <xsd:enumeration value="dessert" />
        <xsd:enumeration value="meat" />
        <xsd:enumeration value="pork" />
        <xsd:enumeration value="poultry" />
        <xsd:enumeration value="sauce" />
        <xsd:enumeration value="seafood" />
        <xsd:enumeration value="shellfish" />
        <xsd:enumeration value="soup" />
        <xsd:enumeration value="steak" />
        <xsd:enumeration value="tofu or soy" />
        <xsd:enumeration value="veal" />
        <xsd:enumeration value="vegetarian" />
        <xsd:enumeration value="quick and easy" />
        <xsd:enumeration value="just for fun" />
        <xsd:enumeration value="picnic" />
        <xsd:enumeration value="winter favorite" />
        <xsd:enumeration value="spring favorite" />
         <xsd:enumeration value="summer favorite" />
        <xsd:enumeration value="autumn favorite" />
        <xsd:enumeration value="sports themed" />
        <xsd:enumeration value="super bowl" />
        <xsd:enumeration value="holiday" />
        <xsd:enumeration value="christmas" />
        <xsd:enumeration value="halloween" />
        <xsd:enumeration value="thanksgiving" />
        <xsd:enumeration value="july 4" />
        <xsd:enumeration value="new year" />
        <xsd:enumeration value="easter" />
        <xsd:enumeration value="hannukah" />
        <xsd:enumeration value="yom kippur" />
        <xsd:enumeration value="rosh hashanah" />
        <xsd:enumeration value="kwanzaa" />
        <xsd:enumeration value="breakfast" />
        <xsd:enumeration value="lunch" />
        <xsd:enumeration value="brunch" />
        <xsd:enumeration value="dinner" />
        <xsd:enumeration value="weekend" />
        <xsd:enumeration value="college student" />
        <xsd:enumeration value="ethnic" />
        <xsd:enumeration value="african" />
        <xsd:enumeration value="american" />
        <xsd:enumeration value="asian" />
        <xsd:enumeration value="cajun" />
        <xsd:enumeration value="canadian" />
        <xsd:enumeration value="chinese" />
        <xsd:enumeration value="creole" />
        <xsd:enumeration value="european" />
        <xsd:enumeration value="french" />
        <xsd:enumeration value="german" />
        <xsd:enumeration value="greek" />
        <xsd:enumeration value="hawaiian" />
        <xsd:enumeration value="italian" />
        <xsd:enumeration value="japanese" />
        <xsd:enumeration value="kosher" />
        <xsd:enumeration value="mediterranean" />
         <xsd:enumeration value="mexican" />
         <xsd:enumeration value="middle eastern" />
        <xsd:enumeration value="polish" />
        <xsd:enumeration value="russian" />
         <xsd:enumeration value="south american" />
        <xsd:enumeration value="spanish" />
        <xsd:enumeration value="thai" />
        <xsd:enumeration value="ukranian" />
            </xsd:restriction>
                 </xsd:simpleType>

          </xsd:schema>

I olso have an stylesheet but it was alrady with files and i have not done any changes to it so that why i dont post it. 我也有一个样式表,但是它带有文件的标记,并且我没有对其进行任何更改,所以为什么我不发布它。 My files are uploaded so you can see how my recipes.xml looklike : http://dayoda01.hostkart.net/recipes(1).xml 我的文件已上传,因此您可以看到我的recipes.xml外观: http ://dayoda01.hostkart.net/recipes(1).xml

My qustion is: What did i misunderstood? 我的问题是:我误解了什么? im prety sure error lays in my linking to XML Shema. 我确实确定错误在于我与XML Shema的链接。

When you wish to provide location hints for an XSD that does not uses namespaces, you have to use the noNamespaceSchemaLocation attribute. 当您希望为不使用名称空间的XSD提供位置提示时,必须使用noNamespaceSchemaLocation属性。

Example (from the linked resource): 示例(来自链接的资源):

<person xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="http://adventure-works.com/schemas/person.xsd">
   <name>John</name>
   <height>59</height>
</person>

I've cleaned up the XML: 我清理了XML:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="reml.xsl" type="text/xsl"?>
<reml version="0.5" language="eng" country="us" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="reml.xsd">
    <menu name="Menu">
        <userData></userData>

        <meal name="Meatballs">
            <userData></userData>
            <mealItem name="Swedish meatballs" servings="9" prepTime="30 min">
                <userData></userData>
                <createDate>2013-09-26</createDate>
                <updateDate>2013-09-29</updateDate>
                <location locality="Sweden"/>
                <difficulty>Normal</difficulty>
                <procedure>
                    <procedureText>In a large bowl, beat eggs and milk. Add bread; mix gently and         stand for 5
                        minutes. Add beef, onion, baking powder, salt and pepper; mix well (mixture
                        will be soft). Shape into 1-in. balls.
                        In a large skillet, brown meatballs, a d
                        few at a time, in shortening. Place in an
                        ungreased 3-q. baking dish. In a
                        bowl, stir soups and milk until smooth; pour
                        over meatballs. Bake, uncovered,
                        at 350° for 1 hour. Sprinkle with parsley.
                    </procedureText>
                </procedure>
                <fb>
                    <usertext>Hej text från user</usertext>
                </fb>
                <author name="Taste of Home " emailAddress="maxin@kth.se"/>
                <nutrition calories="399"/>
                <ingredient name="Eggs" quantity-integer="4">
                    <IUnit>
                        <IUnitArbitrary></IUnitArbitrary>
                    </IUnit>
                </ingredient>
                <ingredient name="milk" quantity-integer="1">
                    <IUnit>
                        <IUnitArbitrary>cup</IUnitArbitrary>
                    </IUnit>
                </ingredient>
                <ingredient name="torn white bread" quantity-integer="8">
                    <IUnit>
                        <IUnitArbitrary>slice</IUnitArbitrary>
                    </IUnit>
                </ingredient>
                <ingredient name="ground beef" quantity-integer="2">
                    <IUnit>
                        <IUnitArbitrary>pound</IUnitArbitrary>
                    </IUnit>
                </ingredient>

                <IUnit>
                    <IUnitArbitrary>cup</IUnitArbitrary>
                </IUnit>

                <ingredient name="pepper" quantity-integer="4">
                    <IUnit>
                        <IUnitArbitrary>teaspoon</IUnitArbitrary>
                    </IUnit>
                </ingredient>
                <ingredient name="shortening" quantity-integer="2">
                    <IUnit>
                        <IUnitArbitrary>tablespoon</IUnitArbitrary>
                    </IUnit>
                </ingredient>
                <ingredient name="condensed cream of chicken soup, undiluted" quantity-integer="2">
                    <IUnit>
                        <IUnitArbitrary>can</IUnitArbitrary>
                    </IUnit>
                </ingredient>
                <ingredient name="condensed cream of mushroom soup, undiluted" quantity-integer="2">
                    <IUnit>
                        <IUnitArbitrary>can</IUnitArbitrary>
                    </IUnit>
                </ingredient>
                <ingredient name="evaporated milk" quantity-integer="1">
                    <IUnit>
                        <IUnitArbitrary>can</IUnitArbitrary>
                    </IUnit>
                </ingredient>
                <ingredient name="Minced fresh parsley" quantity-integer="2">
                    <IUnit>
                        <IUnitArbitrary>ton</IUnitArbitrary>
                    </IUnit>
                </ingredient>
                <category>
                    <CategoryArbitrary>Swedish dishes</CategoryArbitrary>
                </category>
                <feedback>
                    <usertext> *Jag tycker bla bla * asdasd </usertext>
                </feedback>
            </mealItem>

        </meal>
    </menu>
</reml>

With the provided XSD (and the hints as illustrated) I get the following error when validating it: 使用提供的XSD(以及所示的提示),在验证它时出现以下错误:

Error occurred while loading [], line 53 position 6 The element 'mealItem' has invalid child element 'IUnit'. List of possible elements expected: 'ingredient, category, schedule'. linking-xml-to-an-xml-schema-xsd.xml is XSD 1.0 invalid.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM