XSL/XSLT (558レス)
XSL/XSLT http://medaka.5ch.io/test/read.cgi/php/999654569/
上
下
前
次
1-
新
通常表示
512バイト分割
レス栞
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
メモ帳
(0/65535文字)
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 335 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.006s