aboutsummaryrefslogtreecommitdiff
path: root/files/ar/web/api/xsltprocessor/basic_example/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ar/web/api/xsltprocessor/basic_example/index.html')
-rw-r--r--files/ar/web/api/xsltprocessor/basic_example/index.html57
1 files changed, 57 insertions, 0 deletions
diff --git a/files/ar/web/api/xsltprocessor/basic_example/index.html b/files/ar/web/api/xsltprocessor/basic_example/index.html
new file mode 100644
index 0000000000..19e3b75c8f
--- /dev/null
+++ b/files/ar/web/api/xsltprocessor/basic_example/index.html
@@ -0,0 +1,57 @@
+---
+title: مثال XSLT أساسي
+slug: Web/API/XSLTProcessor/Basic_Example
+tags:
+ - XSLT
+ - xsl
+translation_of: Web/API/XSLTProcessor/Basic_Example
+---
+<h2 dir="rtl" id="Basic_Example" name="Basic_Example">مثال أساسي</h2>
+
+<p dir="rtl">يوضح المثال الأول أساسيات تفعيل محول XSLT في المتصفح. سوف يقوم المثال على ملف XML يحتوي على معلومات (العنوان - قائمة المؤلفين - المحتوى) عن مقال. ثم يقوم بعرضه بهيئة صالحة للقراءة.</p>
+
+<p dir="rtl">يبين الشكل ١ مثال على شكل ملف المصدر الأساسي لـ XSLT. يحتوي ملف XML  (example.xml) على معلومات حول المقال. وباستخدام أمر المعالجة <code>?xml-stylesheet?</code> يتم ربط ملف example.xml بملف XSLT عن طريق صفة href.</p>
+
+<p dir="rtl">تبدأ صحيفة أنماط XSLT بالمكون <code>xsl:stylesheet</code> الذي يحوي كل القوالب المستخدمة في إنشاء المُخرَج المطلوب. يحتوي المثال في الشكل ١ على قالبين، أحدهما يُطَبَّق على عقدة التَفَرُّع الرئيسية والآخر يُطَبَّق على عقدة <code>Author</code>. يقوم القالب الذي يُطَبَّق على عقدة التَفَرُّع الرئيسية بإخراج عنوان المقال، ثم يقوم بعدها باستدعاء باقي القوالب (عن طريق <code>apply-templates</code>) التي تطابق عقدة <code>Author</code> وتكون فرعية عنها.</p>
+
+<p dir="rtl">الشكل ١: مثال XSLT بسيط</p>
+
+<p dir="rtl">ملف XML (example.xml):</p>
+
+<pre class="brush:xml">&lt;?xml version="1.0"?&gt;
+&lt;?xml-stylesheet type="text/xsl" href="example.xsl"?&gt;
+&lt;Article&gt;
+ &lt;Title&gt;مقالي&lt;/Title&gt;
+ &lt;Authors&gt;
+ &lt;Author&gt;السيد أحمد&lt;/Author&gt;
+ &lt;Author&gt;السيد محمد&lt;/Author&gt;
+ &lt;/Authors&gt;
+ &lt;Body&gt;هنا محتوي مقالي.&lt;/Body&gt;
+&lt;/Article&gt;</pre>
+
+<p style="direction: rtl;">صحيفة أنماط XSL (example.xsl):</p>
+
+<pre class="brush:xml">&lt;?xml version="1.0"?&gt;
+&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
+
+ &lt;xsl:output method="text"/&gt;
+
+ &lt;xsl:template match="/"&gt;
+ Article - &lt;xsl:value-of select="/Article/Title"/&gt;
+ Authors: &lt;xsl:apply-templates select="/Article/Authors/Author"/&gt;
+ &lt;/xsl:template&gt;
+
+ &lt;xsl:template match="Author"&gt;
+ - &lt;xsl:value-of select="." /&gt;
+ &lt;/xsl:template&gt;
+
+&lt;/xsl:stylesheet&gt;</pre>
+
+<p style="direction: rtl;">مُخرَج المتصفح:</p>
+
+<blockquote>
+<p dir="rtl">مقال - مقالي<br>
+ المؤلفون:<br>
+ - السيد أحمد<br>
+ - السيد محمد</p>
+</blockquote>