diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
| commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
| tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/xsltprocessor/basic_example/index.html | |
| parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
| download | translated-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.html | 49 |
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"><?xml version="1.0"?> +<?xml-stylesheet type="text/xsl" href="example.xsl"?> +<Article> + <Title>My Article</Title> + <Authors> + <Author>Mr. Foo</Author> + <Author>Mr. Bar</Author> + </Authors> + <Body>This is my article text.</Body> +</Article></pre> + +<p>XSL スタイルシート (example.xsl) :</p> + +<pre class="brush:xml"><?xml version="1.0"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:output method="text"/> + + <xsl:template match="/"> + Article - <xsl:value-of select="/Article/Title"/> + Authors: <xsl:apply-templates select="/Article/Authors/Author"/> + </xsl:template> + + <xsl:template match="Author"> + - <xsl:value-of select="." /> + </xsl:template> + +</xsl:stylesheet></pre> +<p>ブラウザの出力:</p> +<pre>Article - My Article +Authors: +- Mr. Foo +- Mr. Bar +</pre> |
