1

いくつかの xml ファイルをまとめて、xslt 変換を使用して xhtml に出力しようとしています。index.xml という名前の xml ファイルを指定して、次のように使用する必要がある他のファイルを定義します。

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="merge.xsl"?>

<dic:dictionary xmlns:dic = "dictionary">
<dic:Logo>Logo</dic:Logo>
<dic:Author>User Name</dic:Author>
<dic:EnglishWords>english</dic:EnglishWords>
<dic:SwedishTranslation>swedish</dic:SwedishTranslation>
<dic:SwedishWords>swedish</dic:SwedishWords><br/>
<dic:EnglishTranslation>english</dic:EnglishTranslation>
</dic:dictionary>

次に、私の変換では、次のようなロゴのテンプレート宣言があります。

<!--Logo-->
 <xsl:template match = "dic:index//Logo">
 <html>
     <head>
        <link rel="stylesheet" type="text/css" href="Style.css" />
     </head>
     <body>
        <div id = "Logo">
            <xsl:apply-templates select="document(concat(.,'.svg'))"/>
        </div>
    </body>
  <xsl:apply-templates/>
</html></xsl:template>

svg ファイル自体は次のようになります。

<?xml version="1.0" standalone="no"?>

<?xml-stylesheet href="Style.css" type="text/css"?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
     width="180px" height="70px" viewBox="0 0 180 70" 
     enable-background="new 0 0 180 70" xml:space="preserve" 
     preserveAspectRatio="xMinYMin meet">

<line fill="none" stroke="#000000" x1="0" y1="71.533" x2="35.036" y2="5.109"/>
<line fill="none" stroke="#000000" x1="91.971" y1="15.767" x2="91.971" y2="71.533"/>
<line fill="none" stroke="#000000" x1="146.357" y1="5.109" x2="177.372" y2="71.533"/>
<line fill="none" stroke="#000000" x1="0" y1="71.533" x2="177.372" y2="71.533"/>
<line fill="none" stroke="#000000" x1="17.518" y1="58.108" x2="82.481" y2="58.108"/>
<line fill="none" stroke="#000000" x1="101.459" y1="58.108" x2="161.866" y2="58.108"/>
<line fill="none" stroke="#000000" x1="82.481" y1="58.108" x2="91.971" y2="71.533"/>
<line fill="none" stroke="#000000" x1="101.459" y1="58.108" x2="91.971" y2="71.533"/>

</svg>

ただし、このアプローチは他の xml ファイルでは機能しますが、この svg ファイルでは機能しません。出力としてロゴという単語しか得られません。私はいたるところを見回してきましたが、これを行う方法の良い例は見当たりません。また、次のCSSスタイルシートを適用しようとすると

#Logo{
width: 300px ;
margin-left: auto ;
margin-right: auto ;
}

それも機能しません... cssを機能させるには...?

これに関するヘルプや情報をいただければ幸いです。

どうもありがとうございました。

4

2 に答える 2

0

<xsl:copy-of select="document(concat(., '.svg'))"/>の代わりに単純にしないのはなぜapply-templatesですか?それとも、何らかの方法で SVG を変換しますか? また、SVG ドキュメントへのパスまたはファイル名が XML 入力サンプルのどこに含まれているかが明確ではありません。

于 2013-01-21T14:57:23.213 に答える
0

これを試してください:

<!--Logo-->
<xsl:template match = "dic:dictionary/dic:Logo">
 <html>
     <head>
        <link rel="stylesheet" type="text/css" href="Style.css" />
     </head>
     <body>
        <div id = "Logo">
            <xsl:copy-of select="document(concat(.,'.svg'))/*"/>
        </div>
    </body>
 </html>
</xsl:template>

最後に を削除し<xsl:apply-templates>(これが「ロゴ」テキストを再現しているものです)、<xsl:copy-of>SVG ファイルの内容をコピーするために使用する必要があります。

于 2013-01-21T15:50:35.557 に答える