XSL/XSLT (558レス)
XSL/XSLT http://medaka.5ch.io/test/read.cgi/php/999654569/
上
下
前
次
1-
新
通常表示
512バイト分割
レス栞
172: ぱむ [] 03/01/28 17:32 ID:IBfGocF/ cocoonのsitemap.xmapで2つ以上のxmlを1つのxslに適用したい場合は どうすればいいんですか? <map:generate src="aaa.xml"/> <map:generate src="bbb.xml"/> <map:transform src="ccc.xsl"/> とすると「適用出来るxmlは1つだけ」というエラーが出てしまいます。 だれか宜しくお願いします。 http://medaka.5ch.io/test/read.cgi/php/999654569/172
173: nobodyさん [] 03/01/29 13:27 ID:L9yee78Z xmlは死んだ http://medaka.5ch.io/test/read.cgi/php/999654569/173
174: nobodyさん [] 03/02/11 22:52 ID:K0N8t3Ee xmlは死んだ http://medaka.5ch.io/test/read.cgi/php/999654569/174
175: nobodyさん [] 03/02/12 17:42 ID:rtj1FkeB MS、XDocsの正式名称「InfoPath」発表 http://www.zdnet.co.jp/news/0302/12/nebt_21.html MicrosoftはInfoPathで作成したフォームを使い 医療電子データ交換用形式で送るデモも実施。 同社はXFormsではなくXSLTの採用を決定 http://medaka.5ch.io/test/read.cgi/php/999654569/175
176: nobodyさん [] 03/02/12 17:56 ID:gzTJY/OJ http://www.agemasukudasai.com/bloom/ http://medaka.5ch.io/test/read.cgi/php/999654569/176
177: nobodyさん [] 03/02/20 19:11 ID:ywFHezDA 名前空間接頭辞 foo と bar を使った xml 文書があります. ---------- <foo:root xmlns:foo="http://foo-namespace" xmlns:bar="http://bar-namespace"> <bar:e1>this is <foo:e2>a</foo:e2> pen. </bar:e1> </foo:root> ---------- これを以下の xslt に食わせて, foo に属する要素を全て bar の要素に変換します. ---------- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="http://foo-namespace" xmlns:bar="http://bar-namespace" version="1.0"> <xsl:output indent="yes" omit-xml-declaration="yes" /> <xsl:template match="foo:root"><bar:root><xsl:apply-templates select="*" /></bar:root></xsl:template> <xsl:template match="foo:e2"><bar:e2><xsl:value-of select="." /></bar:e2></xsl:template> <xsl:template match="@*|node()"><xsl:copy><xsl:apply-templates select="@*|node()" /></xsl:copy></xsl:template> </xsl:stylesheet> ---------- すると,以下のような xml 文書 (多少整形してあります) が得られるのですが, ---------- <bar:root xmlns:bar="http://bar-namespace" xmlns:foo="http://foo-namespace"> <bar:e1>this is <bar:e2>a</bar:e2> pen.</bar:e1> </bar:root> ---------- 結果として全く使われていない foo に対する宣言が文書に含まれてしまいます. exclude-result-prefixes="foo" を指定しても,bar:e1 要素に宣言が現れるだけで意味がありませんでした. これを取り除く (最適化?) することはできないのでしょうか. いや,実害はないんですけど気持ち悪くて... http://medaka.5ch.io/test/read.cgi/php/999654569/177
178: 177 [sage] 03/02/20 19:13 ID:??? 書き込むときに「改行が多い!!」って怒られちゃったので 改行削ったらソースが読みづらくなってしまいました……スマンコ http://medaka.5ch.io/test/read.cgi/php/999654569/178
179: nobodyさん [sage] 03/02/21 01:48 ID:??? >>177 で、変換は何で? http://medaka.5ch.io/test/read.cgi/php/999654569/179
180: 177 [sage] 03/02/21 10:10 ID:??? >>179 えーと,「何で変換する必要があるの?」という意味でしょうか. >>177で挙げた例は,現象が再現する最小限のソースでして (もっと短くできるかもしれませんが),実際は置き換え以外にも色々やってるんです... http://medaka.5ch.io/test/read.cgi/php/999654569/180
181: nobodyさん [sage] 03/02/22 22:09 ID:??? >>180 transformer は何?という意味 http://medaka.5ch.io/test/read.cgi/php/999654569/181
182: 177 [] 03/02/23 21:47 ID:ORn8WdNQ >>181 すいません,書き忘れました. xalan-java 2.4.D1 です. http://medaka.5ch.io/test/read.cgi/php/999654569/182
183: 山崎渉 [(^^)] 03/03/13 17:11 ID:??? (^^) http://medaka.5ch.io/test/read.cgi/php/999654569/183
184: nobodyさん [sage] 03/04/02 23:28 ID:??? ほすさげ http://medaka.5ch.io/test/read.cgi/php/999654569/184
185: nobodyさん [‘‘] 03/04/07 01:23 ID:??? (MS)XSL+JavaScriptで入力フォーム(UI)を作るという方法論は間違いだったと激しく後悔中。 素直に全部JavaScriptにするか、サーバサイドで作るべきだダタヨ。 http://medaka.5ch.io/test/read.cgi/php/999654569/185
186: nobodyさん [] 03/04/07 01:46 ID:uo8jDP5o ん。XForm ではなくて、XSLで? http://medaka.5ch.io/test/read.cgi/php/999654569/186
187: 山崎渉 [(^^)] 03/04/17 12:08 ID:??? (^^) http://medaka.5ch.io/test/read.cgi/php/999654569/187
188: nobodyさん [] 03/04/19 11:48 ID:4Vo7Hobj あの・・・XSLTってタグ自身を出力できない? 下の様にすると全タグについて定義しなくてはならなくなってしまう・・ <xsl:template match="ABCD"> <ABCD> <xsl:apply-template/> </ABCD> </xsl:template> やりたいことは xmlの一部のタグだけ変換したいのですが それ以外はそのままのタグで出力したいのです copy-of とか使うと編集できないし。。。 すごくくだらない質問ですみませんが教えていただけないでしょうか? http://medaka.5ch.io/test/read.cgi/php/999654569/188
189: nobodyさん [sage] 03/04/20 04:35 ID:??? >>188 <xsl:template match="ABCD"> <xsl:element name="{local-name()}"> <xsl:apply-template/> </xsl:element> </xsl:template> ABCD をワイルドカードにすると全部引っかかる。 http://medaka.5ch.io/test/read.cgi/php/999654569/189
190: 山崎渉 [(^^)sage] 03/04/20 06:00 ID:??? ∧_∧ ( ^^ )< ぬるぽ(^^) http://medaka.5ch.io/test/read.cgi/php/999654569/190
191: nobodyさん [] 03/05/19 12:22 ID:UmHfFrg2 いい書籍ない? オライリーのはわかりにくい。 http://medaka.5ch.io/test/read.cgi/php/999654569/191
192: 山崎渉 [(^^)] 03/05/22 02:00 ID:??? ━―━―━―━―━―━―━―━―━[JR山崎駅(^^)]━―━―━―━―━―━―━―━―━― http://medaka.5ch.io/test/read.cgi/php/999654569/192
193: 山崎渉 [(^^)] 03/05/28 17:20 ID:??? ∧_∧ ピュ.ー ( ^^ ) <これからも僕を応援して下さいね(^^)。 =〔~∪ ̄ ̄〕 = ◎――◎ 山崎渉 http://medaka.5ch.io/test/read.cgi/php/999654569/193
194: 山崎 渉 [(^^)] 03/07/15 11:14 ID:??? __∧_∧_ |( ^^ )| <寝るぽ(^^) |\⌒⌒⌒\ \ |⌒⌒⌒~| 山崎渉 ~ ̄ ̄ ̄ ̄ http://medaka.5ch.io/test/read.cgi/php/999654569/194
195: 山崎 渉 [(^^)sage] 03/08/02 02:37 ID:??? ∧_∧ ( ^^ )< ぬるぽ(^^) http://medaka.5ch.io/test/read.cgi/php/999654569/195
196: ぼるじょあ ◆ySd1dMH5Gk [(^^)] 03/08/02 05:19 ID:??? ∧_∧ ∧_∧ ピュ.ー ( ・3・) ( ^^ ) <これからも僕たちを応援して下さいね(^^)。 =〔~∪ ̄ ̄ ̄∪ ̄ ̄〕 = ◎――――――◎ 山崎渉&ぼるじょあ http://medaka.5ch.io/test/read.cgi/php/999654569/196
197: 山崎 渉 [(^^)] 03/08/15 22:59 ID:??? (⌒V⌒) │ ^ ^ │<これからも僕を応援して下さいね(^^)。 ⊂| |つ (_)(_) 山崎パン http://medaka.5ch.io/test/read.cgi/php/999654569/197
198: nobodyさん [] 03/09/07 21:17 ID:PQrT+UlA <x>a b c <y>d</y> e <y>f</y> <y>g</y> h</x> を <p>a b c <q>d</q> e <q>f</q> <q>g</q> h</p> に変換する XSL が分からん。for-each じゃ出来ないよね? http://medaka.5ch.io/test/read.cgi/php/999654569/198
199: nobodyさん [] 03/09/07 23:33 ID:X8dU+/Y3 xにマッチしてpにおきかえるテンプレートと yにマッチしてqにおきかえるテンプレートをかけばいいだけじゃんよ http://medaka.5ch.io/test/read.cgi/php/999654569/199
200: nobodyさん [sage] 03/09/09 01:09 ID:??? >>199 あー、徹夜明けでボケてた。 その通りです失礼 http://medaka.5ch.io/test/read.cgi/php/999654569/200
201: nobodyさん [] 03/09/26 10:15 ID:Hq0iAR6d <date>9月2日</date> <title>ちょっとここを通られた</title> <p>なぞの白い物体に我が家をあらされてしまった。</p> <p>訴訟を起こして謝罪と賠償を要求したい。</p> を <div class="section"> <h2><date>9月2日</h2> <div class="subsection"> <h3>ちょっとここを通られた</h3> <p>なぞの白い物体に我が家をあらされてしまった。</p> <p>訴訟を起こして謝罪と賠償を要求したい。</p> </div> </div> と変換するにはXSLTをどう書けばいいのでしょうか。 http://medaka.5ch.io/test/read.cgi/php/999654569/201
202: nobodyさん [sage] 03/09/26 11:50 ID:??? >>201 まず整形式にしろ。話はそれからだ。 http://medaka.5ch.io/test/read.cgi/php/999654569/202
203: nobodyさん [sage] 03/09/26 17:56 ID:??? >>202 すみません <h2><date>9月2日</h2> は <h2>9月2日</h2> の誤りです。 http://medaka.5ch.io/test/read.cgi/php/999654569/203
204: nobodyさん [sage] 03/09/26 22:18 ID:??? >>203 整形式にしなきゃいけないのは変換前のほうなんだが。 本当にやりたいことは別にあるんじゃないかとも思うが、 とりあえず、親要素を???とすれば、こんな感じ。 <xsl:template match="???"> <div class="section"> <xsl:apply-templates select="date" /> <div class="subsection"> <xsl:apply-templates select="title" /> <xsl:apply-templates select="p" /> </div> </div> </xsl:template> <xsl:template match="date"><h2><xsl:xsl:apply-templates /></h2></xsl:template> <xsl:template match="title"><h3><xsl:xsl:apply-templates /></h3></xsl:template> <xsl:template match="p"><p><xsl:xsl:apply-templates /></p></xsl:template> http://medaka.5ch.io/test/read.cgi/php/999654569/204
205: nobodyさん [sage] 03/10/10 20:26 ID:??? 俺はサイトの文法は <section> <title>TITLE</title> <sentences><p></p>....</sentences> <section> <title>子セクションTITLE</title> <sentences><p></p>....</sentences> </section> <section> <title>子セクションTITLE</title>(以下略&再帰的な文法) </section> </section> にしてる。 http://medaka.5ch.io/test/read.cgi/php/999654569/205
206: nobodyさん [sage] 03/10/14 00:50 ID:??? >>205 俺もそんな感じ http://medaka.5ch.io/test/read.cgi/php/999654569/206
207: nobodyさん [] 03/10/17 21:05 ID:ckGd54O2 質問です。 XSLTで、元の構造を保ったまま、 XMLのテキストを一部分だけ変えるというのは簡単に出来るのでしょうか? 例えば、簡単な例ですが、 <A> <B>hoge</B> </A> とあったときにhogeを何か別の文字列に変換したいという事です。 やはりその構造にあった、スタイルシートを書くしかないのでしょうか? http://medaka.5ch.io/test/read.cgi/php/999654569/207
208: nobodyさん [sage] 03/10/18 00:03 ID:??? >>207 どの要素内容のテキストのhogeも全部書き換えていいなら簡単。 でも、そのためにXSLTを使うなんて馬鹿げてる。 http://medaka.5ch.io/test/read.cgi/php/999654569/208
209: nobodyさん [sage] 03/10/18 14:56 ID:??? >>208 そういうことのためにXSLTがあるんじゃないの? それが馬鹿げてるってことはXSLT自体が馬鹿げてるってことだろ。 http://medaka.5ch.io/test/read.cgi/php/999654569/209
210: nobodyさん [sage] 03/10/19 10:59 ID:??? >>209 スキーマを換えるためにあると考えるのが普通だろ。 単なる置換とはぜんぜん違うよ。 http://medaka.5ch.io/test/read.cgi/php/999654569/210
211: nobodyさん [sage] 03/10/19 17:43 ID:??? XMLをXSLでHTMLに変換して、↓のような感じにしたいです。 何がしたいのかというとページ内リンクがしたくて、 c要素を変換した(1*)や(*2)などを押すと、 f要素の(*1)や(*2)に飛びたいのです。 <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="sample.xsl" type="text/XSL"?> <A> <b>テキスト1<c id="A" /></b> <b>テキスト2<c id="B" /></b> <b>テキスト3<c id="A" /></b> <b>テキスト4<c id="A" /></b> <e> <f id="A">参照テキスト</f> <f id="B">参照テキスト</f> </e> </a> ↓変換↓ テキスト1(*1) テキスト2(*2) テキスト3(*1) テキスト4(*1) (*1)参照テキスト (*2)参照テキスト http://medaka.5ch.io/test/read.cgi/php/999654569/211
212: 211の続き [sage] 03/10/19 17:44 ID:??? ページ内リンク自体は簡単にできるのですが、 (*1)、(*2)などの番号を振るのが難しいです。 f要素の番号は単純にnumberでカウントしているのですが、 c要素での番号が振れません。 xslはネットをうろついて見つけた近そうなものを 参考にしながら、こんな感じになっています。 ↓ http://medaka.5ch.io/test/read.cgi/php/999654569/212
213: 212の続き [sage] 03/10/19 17:48 ID:??? <?xml version="1.0" encoding="Shift_JIS"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" version="4.0" encoding="Shift_JIS" /> <xsl:template match="/"> <html><head><title>sample</title></head><body> <xsl:apply-templates /> </body></html> </xsl:template> <xsl:template match="b"> <div><xsl:apply-templates /></div> </xsl:template> <xsl:template match="c"> <xsl:variable name="ID" select="@id" /> <xsl:element name="a"> <xsl:attribute name="href">#<xsl:value-of select="@id" /></xsl:attribute> (*<xsl:number count="f" /><xsl:value-of select="../../e/f/@id[../@id=$ID]" />) </xsl:element> <xsl:apply-templates /> </xsl:template> http://medaka.5ch.io/test/read.cgi/php/999654569/213
214: 213の続き [sage] 03/10/19 17:49 ID:??? <xsl:template match="f"> <div> <xsl:element name="a"> <xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute> (*<xsl:number count="f" />) </xsl:element> <xsl:apply-templates /> </div> </xsl:template> </xsl:stylesheet> f要素にマッチングさせたnumberをとかを取得できればいいのかなーと思って、 いろいろと考えてみたのですが、↑まで書いたところで???になりました。 どなたかお知恵を貸してください。。。。 http://medaka.5ch.io/test/read.cgi/php/999654569/214
215: nobodyさん [] 03/11/29 01:53 ID:0RUQwDGu どうか皆様のお力をお借りしたく思います。 xmlが <item> <text> ああああああああああ ああああああああああ ああああああああああ </text> <text> いいいいい<em>イイイイイ</em> <br /> いいいいいいいいいい <br /> いいいいいいいいいい <br /> </text> </item> このように与えられていて、これを <!-- タグ付きで、そのまま出力 --> <p> ああああああああああ ああああああああああ ああああああああああ </p> <p> いいいいい<em>イイイイイ</em> <br /> いいいいいいいいいい <br /> いいいいいいいいいい <br /> </p> <!-- タグを削って 32bytes に切り詰め、最後の 3bytes を '...' に変換し、出力 --> <p>ああああああああああああああ ...</p> <p>いいいいいイイイイイいいいい ...</p> このように出力したいのですが、xslはどのように書けばよいのでしょうか。 http://medaka.5ch.io/test/read.cgi/php/999654569/215
216: 215 [sage] 03/11/30 02:13 ID:??? 「タグ付きで、そのまま出力」 は xsl:copy-of を使用して解決しました。 「タグを削って 32bytes に切り詰め、最後の 3bytes を '...' に変換し、出力」 は未解決です。 どなたか御協力を賜りたく思います。 http://medaka.5ch.io/test/read.cgi/php/999654569/216
217: nobodyさん [sage] 03/11/30 02:59 ID:??? 仕様書読んだことある? プログラミング言語の経験は? http://medaka.5ch.io/test/read.cgi/php/999654569/217
218: 215 [sage] 03/11/30 05:20 ID:??? 「タグを削って 32bytes に切り詰め、最後の 3bytes を '...' に変換し、出力」 も自己解決しました。 お騒がせして御免なさい。 >217 >仕様書 少しは読みますが、リファレンス的です。 >プログラミング言語 c/c++ を使う事が出来ます。 http://medaka.5ch.io/test/read.cgi/php/999654569/218
219: nobodyさん [] 04/01/02 03:53 ID:goN3d3Pm XSLTで1つのXMLファイル上に存在するn件のデータを50件ずつ表示を 行いたいんだけど、そういうことって簡単にできますか? どんな感じで実装すれば良いのかご存知の方教えてください。 javascriptでXSLTを触らないとダメなのかな・・。 http://medaka.5ch.io/test/read.cgi/php/999654569/219
220: nobodyさん [sage] 04/01/02 13:08 ID:??? >>219 トップレベルの xsl:param へ実行時にパラメータを渡せるから、 それで、a < position() and position() <= a + 50 とかすれ。 http://medaka.5ch.io/test/read.cgi/php/999654569/220
221: nobodyさん [] 04/01/02 14:59 ID:goN3d3Pm >>220 IEから外部パラメータとして与える方法を探したけどどうしてもわかりません。 普通に/list.xml&index=50とかURL書いても無視されるし。 http://medaka.5ch.io/test/read.cgi/php/999654569/221
222: nobodyさん [sage] 04/01/02 15:25 ID:??? >>221 クライアント側で変換させるなんて論外じゃねぇの http://medaka.5ch.io/test/read.cgi/php/999654569/222
223: nobodyさん [] 04/01/02 16:08 ID:goN3d3Pm >>222 え・・そうなんすか。 ホントXML全然知らないんで、とんちんかんなレスになっちゃうかも しれないけど、XSLTってユーザーの入力値にマッチした情報の抽出を行うとか、 そういう制御は得意かと思っていたんですが違うんですか? それはサーバサイドでやるべき事っていうことですか。 根本的なところを理解していなかったか・・_| ̄|〇ガックリ http://medaka.5ch.io/test/read.cgi/php/999654569/223
224: nobodyさん [sage] 04/01/02 18:25 ID:??? >>223 何が得意かとサーバでやるべきかどうかには何の関係もないと思うけど http://medaka.5ch.io/test/read.cgi/php/999654569/224
225: nobodyさん [sage] 04/01/10 22:17 ID:??? 保守。 ♥ ? ?x2665; http://medaka.5ch.io/test/read.cgi/php/999654569/225
226: nobodyさん [sage] 04/01/14 03:43 ID:??? 不具合か Mozillaでバッチリなのに IE で真っ白ってどういうことだ http://medaka.5ch.io/test/read.cgi/php/999654569/226
227: 225 [sage] 04/01/17 15:58 ID:??? 順番を入れ替えただけでうまくいくってのはどういうこった http://medaka.5ch.io/test/read.cgi/php/999654569/227
228: 227 [sage] 04/01/17 15:59 ID:??? 名前は226だった http://medaka.5ch.io/test/read.cgi/php/999654569/228
229: 226 227 228 [sage] 04/01/17 16:17 ID:??? >>221 外部パラメータを与えるxmlを用意すれば、やりたい事をかなえてくれる <?xml version="1.0" encoding="UTF-8" ?> <?xml-stylesheet version="1.0" encoding="UTF-8" type="text/xsl" href="page.xsl" ?> <page index="50"> </page> みたいな中身のないxmlを用意し、xslで <xsl:param name="index" select="/page/@index" /> をよませるのだ。 xslでは 220の <xsl:if test=" ( $index < position() ) and ( position() <= $index + 50 )"> を使う。 page.xml (中身あり) では<page index="0">、 page1.xml (中身なし) では<page index="50">、 page2.xml (中身なし) では<page index="100">、 page3.xml (中身なし) では<page index="150">、と書いておく。 page.xsl では <xsl:copy-of select="document( "page.xml" )/page/foo" /> みたいな、ドキュメントを指定した形で読み込む。 ( select="/page/foo" では不可能。<xsl:template match="/page/foo"> も恐らく無理 ) おすすめは xsl:for-each <xsl:template match="/page"> <xsl:param name="index" select="/page/@index" /> <xsl:for-each select="document( "page.xml" )/page/foo"> <xsl:if test=" ( $index < position() ) and ( position() <= $index + 50 )"> <xsl:copy-of select="current()" /> </xsl:if> </xsl:for-each> </xsl:template> と、こんな感じではないかな。 ところどころ間違いがあるかもしれないが、その辺は勘弁してくれ http://medaka.5ch.io/test/read.cgi/php/999654569/229
230: nobodyさん [] 04/01/26 15:30 ID:TZ0JMGYO データの格納をXMLに任せて、フォーム使ったCGI作りたいのですけど よいサンプルページないですか? 表示はXHTMLでやってます。 http://medaka.5ch.io/test/read.cgi/php/999654569/230
231: nobodyさん [] 04/01/27 19:27 ID:b8cLgywQ <item name="WebSite" href="URL" />のような一風変わったXMLがありまして, XSLを使ってリンクになっているHTMLを作りたいのですが, <a href="<xsl:value-of select="./@href">"><xsl:value-of select="./@name"/></a> のような記述をしますと,<が入れ子になっているのでエラーになってしまいます. <xsl:text>で囲って<に置き換えたりしても駄目でした. 一体,どの様にしたら良いのでしょうか?宜しくお願いします. http://medaka.5ch.io/test/read.cgi/php/999654569/231
232: nobodyさん [sage] 04/01/27 19:36 ID:??? >>230 スレ違い。 >>231 xsl:attribute 使え。その疑問が出てくるのは、もう一度 XML と XSLT に関 するキチンとした入門書を通読し直した方が良さげ。 > <a href="<xsl:value-of select="./@href">"><xsl:value-of select="./@name"/></a> 整形式じゃねーしよ。 http://medaka.5ch.io/test/read.cgi/php/999654569/232
233: 231 [sage] 04/01/27 20:03 ID:??? >>232 有難うございます.おっしゃる通り,@ITの記事を読んだだけの厨房です. xsl:attributeでググったらやり方が分かりました. 仕事で使う際は,本を読んで真面目に勉強させて頂きます. 有難うございました. 同じ疑問を持った方の参考に(いないかな〜),以下で可能だと思われます. <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="./@href"/> </xsl:attribute> <xsl:value-of select="./@name"/> </xsl:element> http://medaka.5ch.io/test/read.cgi/php/999654569/233
234: nobodyさん [sage] 04/01/28 02:23 ID:??? { } が使えるとかって知らないでしょ?マジで。 http://medaka.5ch.io/test/read.cgi/php/999654569/234
235: nobodyさん [sage] 04/01/28 15:19 ID:??? {./@href} で書けるのだが、<a href="..."> みたいな xhtml タグを xslt の中に書かないほうが良いらしい。 <a href="{./@href}"> <xsl:value-of select="./@name"/> </a> http://medaka.5ch.io/test/read.cgi/php/999654569/235
236: nobodyさん [sage] 04/01/28 21:56 ID:??? xmlをxslt使ってhtmlとかに変換して<a href...を作るには、もとのxmlで<a href=...なんて書けない。 235が正しい。 http://medaka.5ch.io/test/read.cgi/php/999654569/236
237: nobodyさん [sage] 04/01/29 01:45 ID:??? 何言ってんだか。一度は仕様書読めよ。 http://medaka.5ch.io/test/read.cgi/php/999654569/237
238: 232 [sage] 04/01/29 13:19 ID:??? 俺の解答不味かったか。{} じゃなく <xsl:attribute/> を教えたのは俺の趣味と Google で検索する時のことを考えてだったんだが、正直スマンかった。 で、>>235-236 の論点が良く分からんのだが、何が言いたいの? http://medaka.5ch.io/test/read.cgi/php/999654569/238
239: nobodyさん [sage] 04/01/29 13:43 ID:??? >>236 ( ゚д゚)ポカーン それはさておき、漏れは {} 使う派。 attributeは、条件(if)によって属性追加する時くらいしか使わない。 多岐分岐(choose〜when)で属性の値を変える場合は、 直前で変数用意して、{} で埋める。 だって、見やすいんだも〜ん http://medaka.5ch.io/test/read.cgi/php/999654569/239
240: nobodyさん [sage] 04/01/29 23:46 ID:??? xmlをxslt使ってhtmlとかに変換して<a href...を作るには、xslで<a href=...なんて書けない。 かな? http://medaka.5ch.io/test/read.cgi/php/999654569/240
241: nobodyさん [sage] 04/01/30 09:31 ID:??? >>240 なんで?(´Д`) http://medaka.5ch.io/test/read.cgi/php/999654569/241
242: nobodyさん [sage] 04/01/30 12:10 ID:??? in : <item name="2ちゃんねる" href="http://www.2ch.net/"/> xsl : <xsl:template match="item"> <a href="{@href}"><xsl:value-of select="@name"/></a> </xsl:template> out : <a href="http://www.2ch.net">2ちゃんねる</a> ってことじゃないのん? http://medaka.5ch.io/test/read.cgi/php/999654569/242
243: nobodyさん [sage] 04/01/30 21:21 ID:??? >>242 え? そんなことできるんだ。知らんかった。 http://medaka.5ch.io/test/read.cgi/php/999654569/243
244: nobodyさん [sage] 04/01/30 21:39 ID:??? >>243 (°Д°)ポカーン http://medaka.5ch.io/test/read.cgi/php/999654569/244
245: nobodyさん [sage] 04/01/30 22:40 ID:??? <xsl:copy-of> で コピーしたノードのタグに、 <hoge xmlns=""> みたいに空欄の名前空間がつくのだが、これはどういう事なのだろうか。 -- hoge.xml -- <?xml version="1.0" encoding="UTF-8" ?> <?xml-stylesheet version="1.0" encoding="UTF-8" type="text/xsl" href="./hoge.xsl" ?> <hoges> hoge is <hoge> HOGE </hoge>. </hoges> -- hoge.xsl -- <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/hoges"> <xsl:copy-of select="text() | * | @*" /> </xsl:template> </xsl:stylesheet> -- hoge.html -- hoge is <hoge xmlns="">HOGE </hoge>. 目標は、↓なのだが。 -- hoge.html -- hoge is <hoge> HOGE </hoge>. http://medaka.5ch.io/test/read.cgi/php/999654569/245
246: nobodyさん [sage] 04/01/31 01:39 ID:??? 出力をHTMLにしたいみたいだけど、とりあえず xsl:output method="html" とかしてみたら? http://medaka.5ch.io/test/read.cgi/php/999654569/246
247: ヽ(´ー`)ノ [sage] 04/01/31 12:03 ID:??? >>245 xsltproc(libxslt付属)だったら、望んだ出力になるが。バグじゃねーの? >>246 いや、それは関係ないだろ。 http://medaka.5ch.io/test/read.cgi/php/999654569/247
248: 245 [sage] 04/01/31 15:24 ID:??? う、msxmlのバグかな お騒がせしました。失礼いたします http://medaka.5ch.io/test/read.cgi/php/999654569/248
249: nobodyさん [sage] 04/02/01 01:23 ID:??? JRE1.4.2でもなるよ http://medaka.5ch.io/test/read.cgi/php/999654569/249
250: nobodyさん [sage] 04/02/21 13:19 ID:??? xsltからxsltを出力するときなんかで、{}という文字を含んだ属性を出力したいときにもattribute要素使うな。 一応{'{hoge}'}でいけると思うけどなんか変だし。 http://medaka.5ch.io/test/read.cgi/php/999654569/250
251: nobodyさん [] 04/02/21 19:00 ID:4PYw/lWY >>250 言ってる意味が良く分からないなぁ。 属性名に { } は使えないでしょ。 属性値に { } があっても上とは関係ないし。 http://medaka.5ch.io/test/read.cgi/php/999654569/251
252: nobodyさん [sage] 04/02/22 17:24 ID:??? みなさんXSLの作成は何でやってます? XSLってもともと可読性にかけるし、 IEだとキャッシュ読んだりエラーがわかりにくかったりしてデバッグが激しくし辛いのだが。 http://medaka.5ch.io/test/read.cgi/php/999654569/252
253: nobodyさん [sage] 04/02/22 18:13 ID:??? 可読性に欠けないプログラミング言語ってある? インデントとかコメントとか自分で工夫するもんじゃない? IE じゃなくて、msxsl.exe とか使うのもいいと思うよ。 http://medaka.5ch.io/test/read.cgi/php/999654569/253
254: ヽ(´ー`)ノ [sage] 04/02/22 18:14 ID:??? > みなさんXSLの作成は何でやってます? Emacs 使いなので Emacs で。 > XSLってもともと可読性にかけるし、 書き方が下手なだけだと思うが。 > IEだとキャッシュ読んだりエラーがわかりにくかったりしてデバッグが激しくし辛いのだが。 msxsl.exe http://medaka.5ch.io/test/read.cgi/php/999654569/254
255: nobodyさん [sage] 04/02/22 20:09 ID:??? >>252 Komodo http://medaka.5ch.io/test/read.cgi/php/999654569/255
256: 250 [sage] 04/02/23 13:14 ID:??? >>251 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"> <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/> <xsl:template match="/"> <axsl:stylesheet> <axsl:template match="/"> <foo bar="{'{aaa}'}"/> </axsl:template> </axsl:stylesheet> </xsl:template> </xsl:stylesheet> こういう場合。 今試してみたらxsltproc(Using libxml 20604, libxslt 10102 and libexslt 802)だとunmatched '}'とパースエラーが出て、xalan 2.3.1だと問題無く処理できる。 xsltprocでもattribute要素使えば処理できる。 >>252 xsltはxmlなので読みやすいようにスタイルシートを適用してブラウザで見るのが良いかと。 直接編集できないけど。リアルタイムでスタイルシートを適用してくれるxmlエディタならできるかな? エディタはEmacsでxml-lite-modeを使っている。xsltプロセッサはメインがxsltprocで変な動きをしたときはxalan。 タグの閉じ忘れがチェックできるだけでもだいぶ違うよ。 http://medaka.5ch.io/test/read.cgi/php/999654569/256
257: nobodyさん [] 04/02/25 08:26 ID:Hbu4YFmr XSLTって自分自身を出力するスタイルシートは書ける? http://medaka.5ch.io/test/read.cgi/php/999654569/257
258: nobodyさん [] 04/03/24 22:07 ID:QhqWFZPy xhtml文書をxsltprocで変換したいと思ってるんだけど、 xhtml側のnamespaceの状態よってマッチしたりしなかったりするので困ってる。 ----- test.xsl ----- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="html"/> </xsl:stylesheet> ----------------- [実行例] $ xsltproc.exe -v test.xsl test.xml 2>&1 | grep xsltProcessOneNode ----- test.xml ----- <?xml version="1.0"?> <html xmlns="http://www.w3.org/1999/xhtml"/> ----------------- xsltProcessOneNode: no template found for / xsltProcessOneNode: no template found for html このようにマッチしない。でも、namespaceを消したり名前を付けたりするとマッチする。 ----- test.xml ----- <?xml version="1.0"?> <html xmlns:xhtml="http://www.w3.org/1999/xhtml"/> ----------------- xsltProcessOneNode: no template found for / xsltProcessOneNode: applying template 'html' for html 何故?また回避策は? #現象が再現できる最小のソースです。validなxhtmlに対しても同様です。 http://medaka.5ch.io/test/read.cgi/php/999654569/258
259: nobodyさん [sage] 04/03/24 22:10 ID:??? 2行目×状態よって○状態によって xsltprocはCygwin版libxslt1.1.2-1です。 $ xsltproc --version Using libxml 20604, libxslt 10102 and libexslt 802 xsltproc was compiled against libxml 20604, libxslt 10102 and libexslt 802 libxslt 10102 was compiled against libxml 20604 libexslt 802 was compiled against libxml 20604 http://medaka.5ch.io/test/read.cgi/php/999654569/259
260: nobodyさん [sage] 04/03/29 11:53 ID:??? namespaceというのは要素の苗字に当たります。 xmlns="http://www.w3.org/1999/xhtml" と指定することは、この要素とその子孫要素の内プレフィックスの付いてないものの苗字は"http://www.w3.org/1999/xhtml"ですよと宣言することで、 xmlns:xhtml="http://www.w3.org/1999/xhtml" と指定することは、この要素とその子孫要素のうちxhtmlというプレフィックスが付いているものの苗字は"http://www.w3.org/1999/xhtml"ですよと宣言することです。 ですから1番目のtest.xmlのhtml要素はhttp://www.w3.org/1999/xhtmlという苗字を持ったhtml要素ということになります。 一方2番目のtest.xmlのhtml要素にはxhtmlというプレフィックスが無いため苗字無しのhtml要素となります。 test.xslでは苗字無しのhtml要素にマッチするようになっているため1番目のtest.xmlにはマッチしませんが2番目のtest.xmlではマッチします。 解決するためにはtest.xslのxsl:template要素にxmlns="http://www.w3.org/1999/xhtml"と宣言を加えるか、 xmlns:xhtml="http://www.w3.org/1999/xhtml"と宣言を加えてxsl:templateのmatch属性を"xhtml:html"とします。 これで苗字付きのhtml要素にマッチするようになります。 http://medaka.5ch.io/test/read.cgi/php/999654569/260
261: nobodyさん [sage] 04/03/29 12:55 ID:??? pc2鯖が消える前の>>258への解答ローカルで持ってるけど上げる? http://medaka.5ch.io/test/read.cgi/php/999654569/261
262: nobodyさん [sage] 04/03/29 13:12 ID:??? 貼っときますね 260 :nobodyさん :sage :04/03/26 13:09 ID:??? ----- test.xsl ----- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:h="http://www.w3.org/1999/xhtml"> <xsl:template match="/h:html"/> </xsl:stylesheet> ----------------- あるいは ----- test.xsl ----- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:h="http://www.w3.org/1999/xhtml"> <xsl:template match="/"><xsl:apply-templates select="h:html" /></xsl:template> <xsl:template match="h:html"/> </xsl:stylesheet> ----------------- とかどうですか。 xmlns:h=".." は xmlns=".." にしておいて match="/html" あるいは match="/h:html" などでもいいだろうけど。 http://medaka.5ch.io/test/read.cgi/php/999654569/262
263: nobodyさん [sage] 04/03/29 13:14 ID:??? 続き 261 :nobodyさん :sage :04/03/26 13:27 ID:??? >>260 で、できた!ありがとう! でも、なんでこうなるの? XML側にネームスペースがなかったり、名前付けされてたらマッチして、 デフォルトネームスペースがあるとマッチしない理屈がわかんない。 仕様?バグ?ポインタだけでも教えてもらえるとありがたい。 あと、>>260さんは何で知ってるの?(まさか、これFAQ?) http://medaka.5ch.io/test/read.cgi/php/999654569/263
264: nobodyさん [sage] 04/03/29 13:20 ID:??? 以上削除前の263でした。 262 :260 :sage :04/03/26 14:48 ID:??? >>260 の訂正 >xmlns:h=".." は xmlns=".." にしておいて >match="/html" あるいは match="html" などでもいいだろうけど。 >>261 test.xsl で xmlns:h="http://www.w3.org/1999/xhtml" が無い場合、 match="html" でマッチするのは 名前空間無し + "html" という要素だと思う。 で、XHTML のほうは <html xmlns="http://www.w3.org/1999/xhtml"> ... </html> なってたら、html 要素は内部的には 名前空間 "http://www.w3.org/1999/xhtml" + "html" になってる。 名前空間無し + "html" と 名前空間 "http://www.w3.org/1999/xhtml" + "html" は違ってる。なのでマッチしない。 そこで、>>260 に書いたみたく、XSLT の側でマッチさせる対象を後者の ような名前空間 + "html" なものになるよう指定しなきゃいけない。 <html xmlns:xhtml="http://www.w3.org/1999/xhtml"/> と書いた場合は、<html の html は「名前空間無し + "html"」になる。 プリフィックスで xhtml に "http://www.w3.org/1999/xhtml" を割りあててる から、これはデフォルトプリフィックス使ってる <html そのものには影響しない。 http://medaka.5ch.io/test/read.cgi/php/999654569/264
265: ”削除”後の260 [sage] 04/03/29 18:58 ID:??? (´・ω・`) http://medaka.5ch.io/test/read.cgi/php/999654569/265
266: nobodyさん [] 04/04/02 00:28 ID:I+SOWEa+ ・foo.xml <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="foo.xsl"?> <body> <ruby><rb>This</rb><rt>ディス</rt></ruby> <ruby><rb>is</rb><rt>イズ</rt></ruby> <ruby><rb>a</rb><rt>ア</rt></ruby> <ruby><rb>pen</rb><rt>ペン</rt></ruby>! </body> ・foo.xml <?xml version="1.0" encoding="Shift_JIS"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.or/Profiles/XHTML-transitional"> <xsl:output indent="yes" method="html"/><xsl:template match="/"> <html><body> <xsl:for-each select="body"> <xsl:for-each select="ruby"> <xsl:value-of select="rb" /> </xsl:for-each> </xsl:for-each> </body></html> </xsl:template> </xsl:stylesheet> で、 <html xmlns="http://www.w3.or/Profiles/XHTML-transitional"> <body>This is a pen!</body></html> と出力させたいんだけど、 <html xmlns="http://www.w3.or/Profiles/XHTML-transitional"> <body>Thisisapen</body></html> 実際にはこう。どなたか知恵をお貸しください。おながいします。 http://medaka.5ch.io/test/read.cgi/php/999654569/266
267: nobodyさん [sage] 04/04/02 03:16 ID:??? '!'あたりを見るとXSLを理解してないような。 <xsl:template match="/"> <html><body> <xsl:for-each select="(body|.//rb)/text()"> <xsl:choose> <xsl:when test=".='?'"> <xsl:text> </xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </body></html> </xsl:template> テストしてないので自信はないですが。頭と尻に余計なものがくっつくヨカン。 http://medaka.5ch.io/test/read.cgi/php/999654569/267
268: 267 [sage] 04/04/02 03:21 ID:??? 化けた。スマン。 <xsl:when test=".='&#10;'"> 全角を置き換えて。 http://medaka.5ch.io/test/read.cgi/php/999654569/268
269: 266 [sage] 04/04/02 20:40 ID:??? ありがとうございました。"!"は拾ってくれるようになりました。 <html xmlns="http://www.w3.or/Profiles/XHTML-transitional"><body> Thisisapen! </body></html> しかし、上のように単語間のスペースは拾われないみたいです。 おっしゃるとおりXSLTはまだかじりたてなので、自分でも調べてみます。 http://medaka.5ch.io/test/read.cgi/php/999654569/269
270: nobodyさん [sage] 04/04/02 20:50 ID:??? 自己レスです。xmlのほうのbodyタグに xml:space="preserv" と属性を加えたら期待通りの結果が得られました。 重ね重ねありがとうございました。 http://medaka.5ch.io/test/read.cgi/php/999654569/270
271: 267 [sage] 04/04/02 21:33 ID:??? <xsl:preserve-space>というタグがありますけど… あとxhtmlの識別子が間違ってますよ。 http://medaka.5ch.io/test/read.cgi/php/999654569/271
メモ帳
(0/65535文字)
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 287 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.011s