質問編集履歴

2

追記2(xml,xsl,変換後のxml)

2015/06/21 11:31

投稿

yamanoharu0129
yamanoharu0129

スコア47

test CHANGED
File without changes
test CHANGED
@@ -153,3 +153,125 @@
153
153
 
154
154
 
155
155
  ![イメージ説明][WIDTH:519](95ee0bf6b28e2de4779693d46b7b0570.jpeg)
156
+
157
+
158
+
159
+
160
+
161
+ 追記2
162
+
163
+ XMLです。すみません、忘れていたのですが、xslで変換しています…
164
+
165
+ ```lang-<?xml version="1.0" encoding="Shift_JIS" ?>
166
+
167
+ <cars>
168
+
169
+ <car>
170
+
171
+ <name>乗用車</name>
172
+
173
+ <price>150</price>
174
+
175
+ </car>
176
+
177
+ <car>
178
+
179
+ <name>トラック</name>
180
+
181
+ <price>500</price>
182
+
183
+ </car>
184
+
185
+ <car>
186
+
187
+ <name>オープンカー</name>
188
+
189
+ <price>200</price>
190
+
191
+ </car>
192
+
193
+ </cars>
194
+
195
+ ```
196
+
197
+
198
+
199
+ xslが
200
+
201
+ ```lang-<?xml version="1.0" encoding="Shift_JIS" ?>
202
+
203
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
204
+
205
+ <xsl:output method="xml" encoding="Shift_JIS" />
206
+
207
+ <!-- 文書 -->
208
+
209
+ <xsl:template match="/">
210
+
211
+ <xsl:processing-instruction name="xml-stylesheet">
212
+
213
+ type="text/css" href="sample.css"
214
+
215
+ </xsl:processing-instruction>
216
+
217
+ <root>
218
+
219
+ <xsl:apply-templates select="cars" />
220
+
221
+ </root>
222
+
223
+ </xsl:template>
224
+
225
+ <!-- 車リスト -->
226
+
227
+ <xsl:template match="cars">
228
+
229
+ <cars>車リストを処理しました。</cars>
230
+
231
+ <xsl:apply-templates select="car" /><!-- 次の変換対象を指定 -->
232
+
233
+ </xsl:template>
234
+
235
+ <!-- 車 -->
236
+
237
+ <xsl:template match="car">
238
+
239
+ <car>車を一台消しました。</car>
240
+
241
+ <xsl:apply-templates select="name" /> <!--次の変換対象を指定 -->
242
+
243
+ <xsl:apply-templates select="price" /><!-- 次の変換対象を指定 -->
244
+
245
+ </xsl:template>
246
+
247
+ <xsl:template match="name">
248
+
249
+ <name>車名を処理しました。</name>
250
+
251
+ </xsl:template>
252
+
253
+ <xsl:template match="price">
254
+
255
+ <price>価格を処理しました。</price>
256
+
257
+ </xsl:template>
258
+
259
+ </xsl:stylesheet>
260
+
261
+ ```
262
+
263
+ 変換後のxmlが
264
+
265
+ ```lang-<?xml version="1.0" encoding="Shift_JIS"?><?xml-stylesheet
266
+
267
+ type="text/css" href="sample.css"
268
+
269
+ ?>
270
+
271
+ <root><cars>車リストを処理しました。</cars><car>車を一台消しました。</car><name>車名を処理しました。</name><price>価格を処理しました。</price><car>車を一台消しました。</car><name>車名を処理しました。</name><price>価格を処理しました。</price><car>車を一台消しました。</car><name>車名を処理しました。</name><price>価格を処理しました。</price></root>
272
+
273
+ コード
274
+
275
+ ```
276
+
277
+ です。質問に際し、重要なところを書き忘れてしまい申し訳ありません。

1

スクショ付随

2015/06/21 11:31

投稿

yamanoharu0129
yamanoharu0129

スコア47

test CHANGED
File without changes
test CHANGED
@@ -143,3 +143,13 @@
143
143
  レイアウトのイメージは以下の通りです。
144
144
 
145
145
  ![イメージ説明][WIDTH:456](cc6cf5a41b5e57b202660104dfef49d5.png)
146
+
147
+
148
+
149
+ 追記
150
+
151
+ すみません、これです。
152
+
153
+
154
+
155
+ ![イメージ説明][WIDTH:519](95ee0bf6b28e2de4779693d46b7b0570.jpeg)