xslを使ってxmlをHTMLに変換するファイル変換プロジェクトをやっています。xslを使ってxmlに変換する必要があります。私の最初のプロセスは終わっています。しかし、私は変換の2番目の部分に構造化されています..その変換を行う可能性はありますか?私はあなたに最初のプロセスの正確な流れを教えます...xsltを使用してHTMLでxmlを作成する
これは私のサンプルxmlですファイル: tabl.xml:これは私のサンプルXSLファイル
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xml" href="testxsl.xsl"?>
<mainpara>
<epigraph>
<para>Though successful research demands a deep
<emphasis role="italic">trained</emphasis>
<emphasis role="italic">taught</emphasis> to regard.
</para>
<para>Kuhn (1976, p. 66)</para>
</epigraph>
<blockquote role="extract">
<para>Though successful research demands a deep commitment to the status quo.
<emphasis role="italic">trained</emphasis>
<emphasis role="italic">taught</emphasis>
</para>
</blockquote>
</mainpara>
です:
testme.xslが
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="mainpara">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="epigraph">
<div>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="para">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="blockquote">
<b>
<xsl:apply-templates/>
</b>
</xsl:template>
</xsl:stylesheet>
これは私のサンプルJavaファイルです。これを編集した後に、今私は、このhtmlファイルを編集します
<html>
<body>
<div>
<p>Though successful research demands a deep commitment to the status quo, innovation
</p>
<p>Kuhn (1976, p. 66)</p>
</div>
<b>
<p>Though successful research demands a deep commitment to the status quo
</p>
</b>
</body>
</html>
:これは私の生成されたHTMLファイルである
Main.java
import java.io.File;
import java.io.InputStream;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public class Main {
public static void simpleTransform(String sourcePath, String xsltPath,
String resultDir) {
TransformerFactory tFactory = TransformerFactory.newInstance();
try {
Transformer transformer =
tFactory.newTransformer(new StreamSource(new File(xsltPath)));
transformer.transform(new StreamSource(new File(sourcePath)),
new StreamResult(new File(resultDir)));
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
System.setProperty("javax.xml.transform.TransformerFactory",
"net.sf.saxon.TransformerFactoryImpl");
simpleTransform("E:/bh/tabl.xml","E:/bh/testme.xsl", "E:/bh/me.html");
//simpleTransform("E:/bh/me.html","E:/bh/11111.xsl","E:/bh/tab.xml"); //This is i need
}
}
htmlファイルこれをxmlファイルまたはxhtmlファイルに再度変換する必要があります。これは逆の処理が必要です。私はそれが可能なのはxslを変更することだけだと思います。そのhtmlに基づいてxslを作成することは可能ですか?そのxslファイルを作成したら、上記のjavaプログラムでxslファイルを渡します(メインJavaプログラムのその行をコメントしました)。そのxslファイルを作成する必要があります。
私を助けてください..私は事前に
おかげ