دروس XML

الصفحة الرئيسية لـ XML مقدمة XML كيفية استخدام XML شجرة XML بناء جملة XML عناصر XML سمات XML مساحات أسماء XML عرض XML طلب XML HttpRequest محلل XML XML DOM XML XPath XML XSLT XML XQuery XML XLink مدقق XML XML DTD مخطط XML خادم XML أمثلة XML مسابقة XML شهادة XML

XML AJAX

مقدمة أجاكس أجاكس XMLHttp طلب AJAX استجابة AJAX ملف AJAX XML أجاكس بي إتش بي أجاكس آسيا والمحيط الهادئ قاعدة بيانات أجاكس تطبيقات أجاكس أمثلة AJAX

XML DOM

مقدمة حول DOM عقد DOM الوصول إلى DOM معلومات عقدة DOM قائمة عقدة DOM عبور DOM التنقل في DOM DOM احصل على القيم DOM تغيير العقد DOM إزالة العقد استبدل DOM Nodes DOM إنشاء العقد DOM أضف العقد عقد استنساخ DOM أمثلة DOM

دروس XPath

مقدمة XPath عقد XPath بناء جملة XPath محاور XPath مشغلي XPath أمثلة XPath

XSLT التعليمي

XSLT مقدمة لغات XSL تحويل XSLT XSLT <template> XSLT <قيمة> XSLT <للجميع> XSLT <ترتيب> XSLT <if> XSLT <اختر> XSLT تطبيق XSLT على العميل XSLT على الخادم XSLT تحرير XML أمثلة XSLT

XQuery تعليمي

XQuery مقدمة مثال XQuery XQuery FLWOR XQuery HTML شروط XQuery بناء جملة XQuery XQuery إضافة XQuery حدد وظائف XQuery

XML DTD

مقدمة DTD مكعبات بناء DTD عناصر DTD سمات DTD عناصر DTD مقابل Attr كيانات DTD أمثلة DTD

مخطط XSD

مقدمة XSD XSD كيف XSD <المخطط عناصر XSD سمات XSD قيود XSD

مجمع XSD

عناصر XSD XSD فارغ عناصر XSD فقط نص XSD فقط XSD مختلط مؤشرات XSD XSD <أي> XSD <أي سمة> تبديل XSD مثال XSD

بيانات XSD

سلسلة XSD تاريخ XSD XSD الرقمية XSD متفرقات مرجع XSD

خدمات الويب

خدمات XML XML WSDL صابون XML XML RDF XML RSS

مراجع

أنواع عقدة DOM عقدة DOM قائمة عقدة DOM DOM NamedNodeMap مستند DOM عنصر DOM سمة DOM نص DOM DOM CDATA تعليق DOM DOM XMLHttpRequest محلل DOM عناصر XSLT وظائف XSLT / XPath

عنصر سمة مخطط XML


❮ مرجع مخطط XML الكامل

التعريف والاستخدام

يحدد عنصر السمة سمة.

معلومات العنصر

  • العناصر الأصلية: attributeGroup ، schema ، complexType ، تقييد (كلاهما simpleContent و complexContent) ، الامتداد (كلاهما simpleContent و complexContent)

بناء الجملة

<attribute
default=string
fixed=string
form=qualified|unqualified
id=ID
name=NCName
ref=QName
type=QName
use=optional|prohibited|required
any attributes
>

(annotation?,(simpleType?))

</attribute>

(تعلن العلامة أن العنصر يمكن أن يحدث صفرًا أو مرة واحدة داخل عنصر السمة)

Attribute Description
default Optional. Specifies a default value for the attribute. Default and fixed attributes cannot both be present
fixed Optional. Specifies a fixed value for the attribute. Default and fixed attributes cannot both be present
form Optional. Specifies the form for the attribute. The default value is the value of the attributeFormDefault attribute of the element containing the attribute. Can be set to one of the following:
  • "qualified" - indicates that this attribute must be qualified with the namespace prefix and the no-colon-name (NCName) of the attribute
  • unqualified - indicates that this attribute is not required to be qualified with the namespace prefix and is matched against the (NCName) of the attribute
id Optional. Specifies a unique ID for the element
name Optional. Specifies the name of the attribute. Name and ref attributes cannot both be present
ref Optional. Specifies a reference to a named attribute. Name and ref attributes cannot both be present. If ref is present, simpleType element, form, and type cannot be present
type Optional. Specifies a built-in data type or a simple type. The type attribute can only be present when the content does not contain a simpleType element
use Optional. Specifies how the attribute is used. Can be one of the following values:
  • optional - the attribute is optional (this is default)
  • prohibited - the attribute cannot be used
  • required - the attribute is required
any attributes Optional. Specifies any other attributes with non-schema namespace

مثال 1

<xs:attribute name="code">

<xs:simpleType>
  <xs:restriction base="xs:string">
    <xs:pattern value="[A-Z][A-Z]"/>
  </xs:restriction>
</xs:simpleType>

</xs:attribute>

يشير المثال أعلاه إلى أن السمة "code" لها قيود. القيمة الوحيدة المقبولة هي حرفان من الأحرف الكبيرة من a إلى z.

مثال 2

للإعلان عن سمة باستخدام تعريف سمة موجود داخل نوع معقد ، استخدم السمة ref:

<xs:attribute name="code">
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:pattern value="[A-Z][A-Z]"/>
    </xs:restriction>
  </xs:simpleType>
</xs:attribute>

<xs:complexType name="someComplexType">
  <xs:attribute ref="code"/>
</xs:complexType>

مثال 3

يمكن أن تحتوي السمات على قيمة افتراضية أو تحديد قيمة ثابتة. يتم تعيين قيمة افتراضية تلقائيًا للسمة عندما لا يتم تحديد قيمة أخرى. في المثال التالي القيمة الافتراضية هي "EN":

<xs:attribute name="lang" type="xs:string" default="EN"/>

يتم أيضًا تعيين قيمة ثابتة للسمة تلقائيًا عندما لا يتم تحديد قيمة أخرى. ولكن على عكس القيم الافتراضية ؛ إذا حددت قيمة أخرى غير القيمة الثابتة ، فسيتم اعتبار المستند غير صالح. في المثال التالي القيمة الثابتة هي "EN":

<xs:attribute name="lang" type="xs:string" fixed="EN"/>

مثال 4

جميع السمات اختيارية بشكل افتراضي. لتوضيح أن السمة اختيارية ، استخدم السمة "use":

<xs:attribute name="lang" type="xs:string" use="optional"/>

لجعل السمة مطلوبة:

<xs:attribute name="lang" type="xs:string" use="required"/>

❮ مرجع مخطط XML الكامل