2

これは本当に簡単だと確信していますが、単純なものが欠けているだけですが...

ホーム ページ (index.html) があり、(xml データを表示するために) .xsl ファイルである別のページにリンクしたいと考えています。私はそれを行うためにこのコードを使用しています:

<h1><a href="catalogue_overview.xsl">VIEW CATALOGUE</a></h1>

.xsl ファイルを単独で (Dreamweaver を使用して) 開くと、(xml ファイルからの) データが正常に開き、表示されます。

index.htmlページのリンクから開くと<h><p>タグなどに含まれるフォーマットされていないテキストが表示されるだけです。フォーマットもxmlデータもありません。

私は何を間違っていますか?

.xsl ファイルについて認識できるように、index.html ファイルに何かを伝える必要がありますか?

私はこれを間違っていますか?

同じ方法でPHPファイルにリンクしていますが、うまくいくようです。

役立つ場合に備えて、コードを投稿します。

XML ファイル

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="catalogue_overview.xsl"?>

<catalogue>
    <record>
        <catId>001</catId>
        <title>Fungus</title>
        <location>NP</location>
        <photographer>Me</photographer>
        <equipment>Canon EOS 40D</equipment>
        <caption>Small fungus of the genus Fungaroidiae on a log</caption>
        <notes>This is a very rare species of fungus</notes>
        <date>10/8/2012</date>
        <imageUrl>images/IMG_1684.jpg</imageUrl>
    </record>
</catalogue>

XSL ファイル

<?xml version="1.0" encoding="UTF-8"?><!-- DWXMLSource="catalogue.xml" -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="catalogue">
    <html> 
      <head> 
        <title>Photo Catalogue</title>

        <link rel="stylesheet" type="text/css" href="css/style.css"/>

     </head>
     <body>

     <h1 align="center"> Photo Catalogue</h1>
     <h2 align="center"> Catalogue Overview </h2>
     <p align="center"> This is an overview of the photo catalogue. It enables the user to have a quick and easy browse through the images and their information.</p>
     <hr/>

      <xsl:apply-templates/>

     </body>
    </html>

   </xsl:template>

    <xsl:template match="catId">
        <h2> Catalogue ID: <span style="color:2A588F"><xsl:apply-templates/>  </span> </h2>
    </xsl:template>

    <xsl:template match="title">
        <h3> Title: <span style="color:2A588F"><xsl:apply-templates/>  </span> </h3>
    </xsl:template>

    <xsl:template match="location">
        <p> Location: <span style="color:2A588F"><xsl:apply-templates/>  </span> </p>
    </xsl:template>

    <xsl:template match="photographer">
        <p> Photographer: <span style="color:2A588F"><xsl:apply-templates/>  </span> </p>
    </xsl:template>

    <xsl:template match="equipment">
        <p> Equipment: <span style="color:2A588F"><xsl:apply-templates/>  </span> </p>
    </xsl:template> 

    <xsl:template match="caption">
        <p> Caption: <span style="color:2A588F"><xsl:apply-templates/>  </span> </p>
    </xsl:template>

    <xsl:template match="notes">
        <p> Notes: <span style="color:2A588F"><xsl:apply-templates/>  </span> </p>
    </xsl:template>

    <xsl:template match="date">
        <p> Date: <span style="color:2A588F"><xsl:apply-templates/>  </span> </p>
    </xsl:template>

    <xsl:template match="imageUrl">
        <p>Image:<br/><img src="{.}" width="250"/></p>
        <hr/>
    </xsl:template>


 </xsl:stylesheet>

INDEX.HTML ファイル

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Photo Catalogue - HOME</title>

 <link rel="stylesheet" type="text/css" href="css/style.css"/


</head>

<body>

<div class="container">
<div class="content">
    <h1>Photo Catalogue</h1>
    <h2>Welcome to the Photo Catalogue</h2>
    <p>It is intended to be a simple tool to store you favourite photos for easy viewing. It uses XML to store the image details and this is retrieved, displayed and edited using a combination of XSL and PHP.</p>
    <h2>Navigation</h2>
    <p>Select the option you would like below to see its functionality...</p>

    <h1><a href="catalogue_overview.xsl">VIEW CATALOGUE</a></h1>
    <h1><a href="catalogueupdate.php">EDIT CATALOGUE</a></h1>

</div>
</div>
</body>
</html>

お役に立てれば

注: .php ファイルへのリンクは正常に機能しているようです。私はXAMPPを使い果たしています。

ありがとう

4

1 に答える 1

2

データを表示する XML ファイルにリンクする必要があります。これは、INDEX.HTML の変更を意味します

<h1><a href="catalogue_overview.xsl">VIEW CATALOGUE</a></h1>

<h1><a href="catalogue.xml">VIEW CATALOGUE</a></h1>

XML ファイルは XSL スタイルシートを参照します。

<?xml-stylesheet type="text/xsl" href="catalogue_overview.xsl"?>
于 2013-10-22T21:46:41.893 に答える