• ベストアンサー

XMLをxalanでXSL-FOに変換する

book.xmlとbook.xslでbook.foに変換にxalanで実行しました。 >java org.apache.xalan.xslt.Process -in book.xml -xsl book.xsl -out book.fo ところが、以下のようにエラーが出ました。 Exception in thread "main" java.lang.ClassCastException: org.apache.xalan.res.XSLTErrorResources_ja at org.apache.xalan.xslt.Process.main(Process.java:209) 何が原因なのでしょうか?xalan-j_2_4_1のxalan.jarとxercesImpl.jarにはCLASSPATH設定をしています。 <book.xml> <?xml version="1.0" encoding="Shift_JIS" ?> <?xml:stylesheet type="text/xsl" href="book.xsl" ?> <書籍管理> <書籍情報 ID="1"> <書籍名>スタイルシート辞典 第2版</書籍名> <著者>安川英明</著者> <出版社>翔泳社</出版社> <価格>1800</価格> </書籍情報> ・・・ <書籍管理> 文字数が多くなってすべてbook.xslがかけませんでした。 テーブル形式で表示するようしたいのです。 <xsl:template match="書籍管理"><fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> ・・・ <fo:table> <fo:table-column column-width="50mm"/> ・・・ <fo:table-body><fo:table-row><fo:table-cell><fo:block>書籍名</fo:block></fo:table-cell>・・・</fo:table-row> <xsl:apply-templates/> </fo:table-body> </fo:table> </fo:flow></fo:page-sequence> </fo:root></xsl:template> <xsl:template match="書籍情報"> <fo:table-row><xsl:apply-templates/></fo:table-row> </xsl:template> <xsl:template match="書籍名"> <fo:table-cell><fo:block><xsl:value-of select='.'/></fo:block></fo:table-cell> </xsl:template>

  • XML
  • 回答数3
  • ありがとう数17

質問者が選んだベストアンサー

  • ベストアンサー
  • jo-ji
  • ベストアンサー率72% (26/36)
回答No.3

No.2で回答した者です。 とりあえず、java.net.MalformedURLException: no protocol: book.xslとメッセージが出ているのだから、XSLTの書き方を疑うよりも、URL(つまりパス)を疑うべきだと思います。 以下の実験をしてみたところ、同じエラーが出ました。 (1) 問題なく動作するXSLTスタイルシートを用意 (2) 日本語の名前の付いたフォルダを作り、そこにファイルを入れてみる (3) Xalanを呼び出す 日本語の名前の付いたフォルダに直接含まれていなくても、パスの途中に日本語の名前のフォルダがある(「デスクトップ」とか)とエラーになるようです。 したがって、パスの途中に日本語の名前のフォルダがないかどうか、チェックしてみて下さい。 ちなみに私は、日本語名や空白を含んだ名前のフォルダがパスに含まれない位置に、ファイルやツールをなるべく置くようにしています。コンピュータを使う場合の心がけのようなものです。

machitaka
質問者

お礼

ありがとうございます。 おっしゃった通り日本語名フォルダが有った為、エラーが出ていたようです。 FOファイルが無事作成できました。 最後行の心がけ私も実行します!

その他の回答 (2)

  • jo-ji
  • ベストアンサー率72% (26/36)
回答No.2

もしかして、Java2 SDK 1.4を使ってませんか? その場合は、Java実行時のオプションで、例えばxalan.jarとxercesImpl.jarがc:\xml_tool\xalan-j_2_4_0\binの中にある場合だと、以下のように指定すると、解決するかもしれません。 java -Djava.endorsed.dirs=c:\xml_tool\xalan-j_2_4_0\bin org.apache.xalan.xslt.Process -in book.xml -xsl book.xsl -out book.fo 私はこのエラーになったことがないのですが、参考URLにあるApacheのメーリングリストのアーカイブの中をClassCastExceptionで検索して、xalanに関係のありそうなところを見ると、この問題と対処法が載っていました。 Java2 1.4には標準でXML処理のインターフェイス(JAXP)の実装が組み込まれたために、最新のXerces, Xalanを使っているつもりでも、重複するクラスについてSDKに含まれる方を参照してしまうようです。1.4以上を使っている方で最新のXerces, Xalanを確実に使いたい場合には、今回のような問題がたとえなかったとしても、-Djava.endorsed.dirsでjarファイルのあるディレクトリを指定した方が良いようです。

参考URL:
http://marc.theaimsgroup.com/
machitaka
質問者

補足

確かにJava2 SDK 1.4を使っています。 教えていただいたように実行すると前のようなエラーは出なくなりました。 今度は、次のようなエラーが出たのですが、 XSLの書き方が間違っているからでしょうか? 何かおかしな点ありますか? (Location of error unknown)XSLT エラー (javax.xml.transform.TransformerConfigura tionException): javax.xml.transform.TransformerException: java.net.MalformedURLE xception: no protocol: book.xsl <?xml version="1.0" encoding="Shift_JIS"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0"> <xsl:template match="書籍管理"> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="ja"> <fo:layout-master-set> <fo:simple-page-master master-name="page" page-height="300mm" page-width="300mm" margin-top="10mm" margin-bottom="10mm" margin-left="20mm" margin-right="20mm"> <fo:region-body margin-top="0mm" margin-bottom="10mm" margin-left="0mm" margin-right="0mm"/> <fo:region-after extent="10mm"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="page"> <fo:flow flow-name="xsl-region-body"> <fo:block font-weight="bold" font-size="36pt" line-height="48pt" font-family="MSGothic" color="blue"> 書籍情報 </fo:block> <fo:table background-color="#cfffcf"> <fo:table-column column-width="55mm"/> <fo:table-column column-width="30mm"/> <fo:table-column column-width="30mm"/> <fo:table-column column-width="30mm"/> <fo:table-column column-width="45mm"/> <fo:table-column column-width="40mm"/> <fo:table-column column-width="30mm"/> <fo:table-body> <fo:table-row> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block font-size="18pt">書籍名</fo:block> </fo:table-cell> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block font-size="18pt">著者</fo:block> </fo:table-cell> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block font-size="18pt">出版社</fo:block> </fo:table-cell> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block font-size="18pt">価格</fo:block> </fo:table-cell> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block font-size="18pt">ISBN番号</fo:block> </fo:table-cell> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block font-size="18pt">分類</fo:block> </fo:table-cell> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block font-size="18pt">所有者</fo:block> </fo:table-cell> </fo:table-row> <xsl:apply-templates/> </fo:table-body> </fo:table> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> <xsl:template match="書籍情報"> <fo:table-row background-color="#ffffcf"> <xsl:apply-templates/> </fo:table-row> </xsl:template> <xsl:template match="書籍名"> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block><xsl:value-of select='.'/></fo:block> </fo:table-cell> </xsl:template> <xsl:template match="著者"> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block><xsl:value-of select='.'/></fo:block> </fo:table-cell> </xsl:template> <xsl:template match="出版社"> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block><xsl:value-of select='.'/></fo:block> </fo:table-cell> </xsl:template> <xsl:template match="価格"> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block><xsl:value-of select='.'/></fo:block> </fo:table-cell> </xsl:template> <xsl:template match="ISBN番号"> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block><xsl:value-of select='.'/></fo:block> </fo:table-cell> </xsl:template> <xsl:template match="分類"> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block><xsl:value-of select='.'/></fo:block> </fo:table-cell> </xsl:template> <xsl:template match="所有者"> <fo:table-cell border-width="1mm" border-style="solid"> <fo:block><xsl:value-of select='.'/></fo:block> </fo:table-cell> </xsl:template> </xsl:stylesheet>

  • tekebon
  • ベストアンサー率62% (36/58)
回答No.1

原因はClassCastExceptionですので「データ型があってないよ」ってことなんですが... Processクラスはapacheの提供するクラスでなのでバグなんですかねー.. ためしにソースをDLして209行目付近を見てみました ResourceBundle resbundle = (XSLMessages.loadResourceBundle( org.apache.xml.utils.res.XResourceBundle.ERROR_RESOURCES)); でAPIドキュメントを見てみると ResourceBundle XSLMessages.loadResourceBundle(String) String XResourceBundle.ERROR_RESOURCES となっているので問題なさそうです...うーむ ためしに自分のマシンにはいってるjaxpからxslファイルからhtmlへ 変換してみましたが問題なく変換できました。 そこで、 ・一度ほかのサンプルファイルを作成して実行してみる(FOじゃないやつとか) ・ほかのバージョンをDLして実行してみる と確認してみてはいかがでしょうか? あんまりまとまってないですねスミマセン

関連するQ&A

  • XSLで、XMLの空タグを制御したい。

    値がないXML文書に、 <exsample /> こう書かれてしまうものを、 <exsample></exsample> このように出力したいのですが、出来ずでした。 以下は、私のやり方です。 ■ XSL <?xml version="1.0" encoding="Shift_JIS"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xslt"> <xsl:output method="xml" encoding="Shift_JIS" indent="yes" xalan:indent-amount="4"/> <xsl:template match="/"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> ■ XML <?xml version="1.0" encoding="Shift_JIS"?> <root> <section> <category> <exsample1>value</exsample1> <exsample /> </category> </section> </root> ご教授、よろしくお願いいたします。

    • ベストアンサー
    • XML
  • XMLでの改行について

    XMLでの改行について ASPにてXMLを作成し、XSL(FO)にて帳票形式を作成し、TomcatにてPDFを作成しています。 ASP側にて、  Set objXmlNode = objXmlDoc.CreateElement("CV0")  Set objXmlText = objXmlDoc.createTextNode("文字" & vbCrLf & "文字" & vbCrLf& "文字")   objXmlNode.appendChild(objXmlText)  objTrNode.appendChild objXmlNode のようにXMLを作成し、XSL(FO)には、 <xsl:template match="CV0"> <fo:table-cell border-width="0.5mm" border-style="solid" padding="1mm" height="30mm"> <fo:block font-size="12pt" font-family="MSMincho" text-align="center"> <xsl:value-of select='.'/> </fo:block> </fo:table-cell> </xsl:template> のように表記しておりますが、帳票を見ると、 「文字 文字 文字」 になるはずが、 「文字 文字文字」 となってしまいます。 原因として何が考えられるのでしょうか? 回答のほど、よろしくお願いします。

    • 締切済み
    • XML
  • xslのdocument関数で読込んだ2つのxmlをxsl:sortしたい

    次のXSLで動作させています。 <?xml version="1.0" encoding="Shift_JIS"?> <xsl:stylesheet xml:space="default" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"> <xsl:output method="text" /> <xsl:template match="/"> <xsl:for-each select="document('取り込むXMLファイル')//z:row"> <xsl:value-of select="@取り出したい属性の名前" /> </xsl:for-each> <xsl:for-each select="//z:row"> <xsl:value-of select="@取り出したい属性の名前" /> </xsl:for-each> </xsl:template> </xsl:stylesheet> ここまでは出来たのですが、xsl:sortでまとめてsortするにはどうすればいいのでしょうか?

    • ベストアンサー
    • XML
  • xsl:variable の使用方法

    こんにちは xml,xsl を今日はじめて使う初心者です。 変数を使おうとして下記のようなメッセージが出てしまいます。 >ここではキーワード xsl:variable を使用できません。 どうすればよろしいでしょう? area.xls: <?xml version="1.0" encoding="Shift_JIS"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <html> (中略) </html> </xsl:template> <xsl:template match="変換結果"> <table align="left" border="1" width="1500" cellspacing="0" cellpadding="0"> <tr> (中略) </tr> <tr> (中略) <xsl:comment>合計 </xsl:comment> <th>数量</th> (中略) </tr> <xsl:variable name="coLor" select="white" /> <xsl:for-each select="row" order-by="+column0"> <tr bgcolor="$coLor"> <td width="200" align="right"> <xsl:value-of select="column0" /> </td> (中略) </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> ************************************************************* area.xml <?xml version="1.0" encoding="Shift_Jis"?> <?xml-stylesheet type="text/xsl" href="area.xsl" ?> <変換結果> <row row-Num='1'><column0>,4536163880211</column0> (中略) </row> </変換結果>

    • ベストアンサー
    • XML
  • XSL内でJavaScriptを記述し、JavaScript内でXMLデータを取得するには・・・

    大変困っていますのでよろしくお願いします。 XSLのファイル内でJavaScriptを記述し、JavaScriptでxmlの要素を取得操作したいのですが、とり方がわかりません。 ご教授のほどをよろしくお願いします。 ================================================================== sample.xsl ------------------------------------------------------------------ <?xml version="1.0" encoding="Shift_JIS"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head> <title>XML: 基本サンプル</title> </head> <body> <p align="center">サンプル</p> <xsl:apply-templates select="information/value/applicationinfo" /> </body> </html> </xsl:template> <xsl:template match="value/applicationinfo"> <Script Language = "JavaScript"> <xsl:comment> <![CDATA[ document.write("<xsl:value-of select=\"componentname\" />"); ]]> </xsl:comment> </Script> <table border="1"> <tr> <td><xsl:value-of select="componentname" /></td> </tr> </table> </xsl:template> </xsl:stylesheet> ================================================================== 下のテーブルでは要素を表示することはできます。 このやり方では駄目なのでしょうか?

    • ベストアンサー
    • XML
  • XML/XSLでテンプレートの適用がうまくいかない

    同じツリーの深さで異なる要素名のノードがあるXMLだと期待通りにテンプレートが適用できない という問題に付き当たっています。 例えば    / +------+ poem  poem のような構成だとmatch=poem、value-of select="text"などで各poemの歌詞を表示させることが できます。 一方、以下の構成で同じ事をやろうとすると各poemの歌詞に加えてyearのnumのValueまで 列挙されてしまいます。poemの中身だけ出すにはどうすればよいでしょうか? 以下に例を書きます。     / +--------------+ list         year +------+      +----+ poem poem    Num Num 例えば以下のURLなどを参照してやっております。 http://www6.airnet.ne.jp/manyo/xml/xslt/step15.html XSLはこんな感じです。 <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="poem"> <tr> <td><xsl:value-of select="poet" /></td> <td><xsl:value-of select="yomi" /></td> </tr> <br /> </xsl:template> 手持ちのXMLを変換したく、その勉強のため上記のような構成のXMLを扱う方法を 知りたいと思っています。 よろしくお願いします。

    • 締切済み
    • XML
  • XSL変換したが画像が表示できません

    下記のXMLの画像データを表示するためXSL変換したが画像が表示できません ちなみに同drに設置しています。  PHOT.XML <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="style.xsl"?> <photos>  <photo url="http://www.kahokanko.com/demo/10.jpg"/>  <photo url="http://www.kahokanko.com/demo/19.jpg"/>  <photo url="http://www.kahokanko.com/demo/31.jpg"/> </photos> STYLE.XSL <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  <xsl:template match="/">  <html>   <head>    <title>サンプル</title>    <link rel="styleSheet" type="text/css" href="./xx.css" />   </head>   <body>    <h1>画像を表示</h1>    <div>     <xsl:apply-templates />    </div>   </body>   </html>  </xsl:template>  <xsl:template match="photo">   <p class="album">    <img>     <xsl:attribute name="src">      <xsl:value-of select="@url" />     </xsl:attribute>    </img>   </p>  </xsl:template> </xsl:stylesheet>

  • XMLをXSLを使いHTMLに変換したいのですが・・・・

    あるXML形式のXSL用に次のようにスタイルシートを作成致しました。(例) <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" version="4.01" encoding="UTF-8" indent="yes" /> <xsl:template match="/"> <html lang="ja"> <head> <title>○○情報</title> </head> <body><xsl:apply-templates select="ProductInfo"/></body> </html> </xsl:template> <xsl:template match="Responce/Details"/> <h2><xsl:value-of select="Hid"/></h2> <h2><xsl:value-of select="TotalItems"/></h2> <h2><xsl:value-of select="TotalPages"/></h2> <h3><xsl:value-of select="ItemID"/></h3> <h3><xsl:value-of select="ShopID"/></h3> <h3><xsl:value-of select="ProductName"/></h3> <h3><xsl:value-of select="Price"/></h3> <h3><xsl:value-of select="ImageUrlSmall"/></h3> <h3><xsl:value-of select="ImageUrlMedium"/></h3> <h3><xsl:value-of select="mageUrlLarge"/></h3> <h3><xsl:value-of select="URL"/></h3> <h3><xsl:value-of select="MobileURL"/></h3> <h3><xsl:value-of select="Manufacture"/></h3> <h3><xsl:value-of select="Availability"/></h3> <h3><xsl:value-of select="Stock"/></h3> <h3><xsl:value-of select="StockInfinity"/></h3> <h3><xsl:value-of select="ItemDetail"/></h3> <h3><xsl:value-of select="SalesStatus"/></h3> <h3><xsl:value-of select="CategoryID"/></h3> </xsl:template> </xsl:stylesheet> とスタイルシートを作成いたしました。 変換するHMLは <?xml version="1.0" encoding="UTF-8" ?> <?xml-stylesheet type="text/xsl" href="○○.xsl"?> - <ProductInfo> - <Responce> <Hid>○○○○</Hid> <TotalItems>○○○○</TotalItems> <TotalPages>○○○○</TotalPages> - <Details> <ItemID>○○○○</ItemID> <ShopID>○○○○</ShopID> <ProductName>○○○○</ProductName> <Price>○○○○</Price> <Manufacture>○○○○</Manufacture> <Availability>○○○○</Availability> <Stock>0○○○○</Stock> <StockInfinity>○○○○</StockInfinity> <ItemDetail>○○○○</ItemDetail> <SalesStatus>○○○○</SalesStatus> <CategoryID>○○○○</CategoryID> </Details> </Responce> </ProductInfo> 以下<Details>のみ複数繰り返しされます。 この通りに作成したのですが、XMLファイルをウインドウに表示しようとしてもエラーが報告されます。 XSLに繰り返し用のタグを入れても、まったく表示されません。 ちなみにIE7を使用しています。 もし間違っている箇所が分かる方がいらっしゃいましたら、教えていただけませんか? よろしくお願いいたします。

    • ベストアンサー
    • XML
  • xml→htmlへの変換&ページ分割したい

    まず、下記のxml、xslによりhtmlページを出力しています。 ■test.xml <?xml version="1.0" encoding="UTF-8"?> <all> <index file_id="a"> <product file_id="a-01"> <yoso>ああああああああああああああああ</yoso> </product> <product file_id="a-02"> <yoso>いいいいいいいいいいいいいいいい</yoso> </product> <product file_id="a-03"> <yoso>うううううううううううううううう</yoso> </product> <product file_id="a-04"> <yoso>ああああああああああああああああ</yoso> </product> <product file_id="a-05"> <yoso>いいいいいいいいいいいいいいいい</yoso> </product> <product file_id="a-06"> <yoso>うううううううううううううううう</yoso> </product> </index> <index file_id="b"> <product file_id="b-01"> <yoso>ああああああああああああああああ</yoso> </product> <product file_id="b-02"> <yoso>いいいいいいいいいいいいいいいい</yoso> </product> <product file_id="b-03"> <yoso>うううううううううううううううう</yoso> </product> <product file_id="b-04"> <yoso>うううううううううううううううう</yoso> </product> </index> <index file_id="c"> <product file_id="c-01"> <yoso>ああああああああああああああああ</yoso> </product> <product file_id="c-02"> <yoso>いいいいいいいいいいいいいいいい</yoso> </product> <product file_id="c-03"> <yoso>うううううううううううううううう</yoso> </product> </index> </all> ■ind.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0" xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect" extension-element-prefixes="redirect"> <xsl:output method="html" encoding="UTF-8"/> <xsl:template match="index"> <!-- 出力ファイル名 --> <xsl:variable name="filename" select="concat('html/',@file_id, '/index.html')"/> <!-- 出力開始 --> <redirect:open select="$filename"/> <redirect:write select="$filename"> <html> <head> <title><xsl:value-of select="@file_id"/></title> </head> <body> <h1><xsl:value-of select="@file_id"/></h1> <xsl:apply-templates /> </body> </html> </redirect:write> <redirect:close select="$filename"/> <!-- 変換報告 --> <xsl:value-of select="concat('『',$filename,'』変換完了')"/> </xsl:template> <xsl:template match="product"> <a> <xsl:attribute name="href"> <xsl:value-of select="concat(@file_id,'.html')" /> </xsl:attribute> <xsl:value-of select="@file_id" /> </a><br /> </xsl:template> </xsl:stylesheet> ■環境 ・xalan-j_2_7_1 ・j2sdk1.4.2_16 ・windowsxp コマンドプロンプトにより下記を実行すると java org.apache.xalan.xslt.Process -in test.xml -xsl ind.xsl html/a/index.html html/b/index.html html/c/index.html が出力されます。 つまりは各カテゴリ(a,b,c)のproduct要素をまとめた インデックスページが出力されます。 ここまでが現状です。 やりたいのは以下です。 上記だとproductの数にかかわらず1ページのindex.htmlに 出力されます。 test.xmlは数が少ないのでいいですが、 仮に1000個あった場合、どんでもないことになってしまうので、 ページ分割をしたいと思っています。(< 1 2 3 4 > みたいな!) ですが、何をどうしたらよいのか皆目見当が付きません。 1ページを10個までとしてそれ以上は次ページに出力みたいなことはできるのでしょうか。 html/a/index.html html/a/index2.html html/a/index3.htmlみたいにです。。。 上記のxslだとmatchするtemplates(index)は3つだけなので、 xalanが書き出すのは3ぺーじだけです。 この書き出す回数をたとえばcount(product div 10)とかにできれば、 なにかみえてきそうなきもするんですが、、、、 長々と申し訳ありませんが、 ご協力お願いします。

    • ベストアンサー
    • XML
  • xml+xslでの変換内容をtextareaへ

    お世話になります。 xml+xslでhtmlに変換する際、その変換内容をtextareaにも表示させるようにしたいのです。 使用ブラウザ:FireFox。現状はFirebugでDOMツリーを手動で参照してる状況です。 現在は、ノードをtextareaに表示しようとすると[object DocumentFragment]とだけ出てしまい、DocumentFragmentという概念あることは分かり、色々調べcreateElement()やcreateTextNode()など、その他思いつく限りの事でテストしてみてるのですが、どうにもノードをHTMLタグとしてtextareaに表示させる事が出来ません。 以下にポイントとなるソースを掲示しますので、どなた様か、お助け願えませんでしょうか --test.html---- <html><head> <meta content="text/html; charset=utf8" http-equiv="content-type"> <title>JS+xslt</title> <script type="text/javascript"> function tramsformlists(xmlFile, xslFile, resultNodeID){ var xml, xslt, newDoc; if(document.all){ xml = new ActiveXObject("Microsoft.XMLDOM"); xslt = new ActiveXObject("Microsoft.XMLDOM"); }else { xml = document.implementation.createDocument("", "", null); xslt = document.implementation.createDocument("", "", null); } xml.async = false; xslt.async = false; xml.load(xmlFile); xslt.load(xslFile); if(document.all){ document.getElementById(resultNodeID).innerHTML = xml.transformNode(xslt); }else { var xsltp = new XSLTProcessor(); xsltp.importStylesheet(xslt); newDoc = xsltp.transformToFragment(xml, window.document); var df = document.createDocumentFragment(); cloneDoc= newDoc.cloneNode(true); document.getElementById("Div"+resultNodeID).innerHTML = ""; document.getElementById("Div"+resultNodeID).appendChild(newDoc); t = document.msg_form.TextareaTest.value; document.msg_form.TextareaTest.value =t + df.appendChild(cloneDoc); } } </script> </head><body> <form name="msg_form"> <ul> <li> <input type="button" value="Menu" onclick="tramsformlists('test0.xml','test0.xsl','Test')"><br> <div id="DivTest"></div> <textarea cols="50" rows="10" id="TextareaTest">あああああああ</textarea> </li> </ul> </form> </body></html> --test0.xml-- <?xml version="1.0" encoding="utf-8"?> <root> <nolink_logo> </nolink_logo> </root> --test0.xsl-- <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="utf-8"/> <xsl:template match="root"> <xsl:apply-templates select="nolink_logo"/> </xsl:template> <xsl:template match="nolink_logo"> <xsl:call-template name="Test" /> </xsl:template> <xsl:template name="Test"> <xsl:variable name="menu" select="document('test1.xml')/root"/> <div>画像を表示 <xsl:for-each select="$menu"> <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="url[1]"/> </xsl:attribute> <xsl:attribute name="target">_blank</xsl:attribute> <xsl:element name="img"> <xsl:attribute name="src"> <xsl:value-of select="img[1]"/> </xsl:attribute> </xsl:element> </xsl:element> </xsl:for-each> </div> </xsl:template> </xsl:stylesheet> --test1.xml-- <?xml version="1.0" encoding="utf-8"?> <root> <img>http://domain/image2.gif</img> <url>http://domain/test.html</url> </root>