aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/xsltprocessor/basic_example/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/xsltprocessor/basic_example/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/ja/web/api/xsltprocessor/basic_example/index.html')
-rw-r--r--files/ja/web/api/xsltprocessor/basic_example/index.html49
1 files changed, 49 insertions, 0 deletions
diff --git a/files/ja/web/api/xsltprocessor/basic_example/index.html b/files/ja/web/api/xsltprocessor/basic_example/index.html
new file mode 100644
index 0000000000..3d5b98e875
--- /dev/null
+++ b/files/ja/web/api/xsltprocessor/basic_example/index.html
@@ -0,0 +1,49 @@
+---
+title: Basic Example
+slug: Web/API/XSLTProcessor/Basic_Example
+tags:
+ - XSLT
+translation_of: Web/API/XSLTProcessor/Basic_Example
+---
+<div>{{英語版章題("Basic Example")}}</div>
+<h2 id=".E5.9F.BA.E6.9C.AC.E7.9A.84.E3.81.AA.E4.BE.8B" name=".E5.9F.BA.E6.9C.AC.E7.9A.84.E3.81.AA.E4.BE.8B">基本的な例</h2>
+<p>最初の例は、ブラウザで XSLT 変換の設定の基本を実演します。 この例は、人が読むことのできる書式で書かれた記事についての情報 (タイトル、著者の一覧、本文) を含む XML ドキュメントを取得します。</p>
+<p>図 1 は基本的な XSLT の例のソースです。XML ドキュメント (example.xml) は記事についての情報を含んでいます。<code>?xml-stylesheet?</code> で処理を指示すると、その href 属性を通して XSLT スタイルシートへリンクします。</p>
+<p>XSLT スタイルシートは、最終的な出力を生成するためのすべてのテンプレートを含む、<code>xsl:stylesheet</code> 要素で開始します。図 1 の例には二つのテンプレートがあります。一つはルートノードに対応し、一つは Author ノードに対応します。ルートノードが出力する記事のタイトルにテンプレートが一致すると、(<code>apply-templates</code> を通して) Authors ノードの子の、すべての Author ノードに対応するテンプレートが処理されます。</p>
+<p>図 1 : 簡単な XSLT の例</p>
+<p>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;My Article&lt;/Title&gt;
+ &lt;Authors&gt;
+ &lt;Author&gt;Mr. Foo&lt;/Author&gt;
+ &lt;Author&gt;Mr. Bar&lt;/Author&gt;
+ &lt;/Authors&gt;
+ &lt;Body&gt;This is my article text.&lt;/Body&gt;
+&lt;/Article&gt;</pre>
+
+<p>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>ブラウザの出力:</p>
+<pre>Article - My Article
+Authors:
+- Mr. Foo
+- Mr. Bar
+</pre>