Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
多个html作为输出和一个xsl_Html_Xml_Xslt_Hyperlink - Fatal编程技术网

多个html作为输出和一个xsl

多个html作为输出和一个xsl,html,xml,xslt,hyperlink,Html,Xml,Xslt,Hyperlink,我正在使用XSLT将XML转换为HTML。 的输出应有两个相互链接的HTML文件。 在第一个html中会有一个数据列表,一旦我点击一个特定的数据,我就会在其他html文件中获得该特定数据的详细信息。我需要为此使用xslt 我使用Saxon生成了多个HTML,但我能够执行链接功能。有什么办法吗 我的输入是这样的 <a:file> <a:id>33</a:id> <a:name>hello</a:name> <a:school>

我正在使用XSLT将XML转换为HTML。 的输出应有两个相互链接的HTML文件。 在第一个html中会有一个数据列表,一旦我点击一个特定的数据,我就会在其他html文件中获得该特定数据的详细信息。我需要为此使用xslt

我使用Saxon生成了多个HTML,但我能够执行链接功能。有什么办法吗

我的输入是这样的

<a:file>
<a:id>33</a:id>
<a:name>hello</a:name>
<a:school>mumbai public</a:school>
<a:marks>80</a:marks>
</a:file>

33
你好
孟买公众
80

Saxon 9或任何XSLT 2.0处理器都可以使用一个样式表生成多个结果文档,至于链接两个文档,这并不困难,您只需使用一个HTML
a
元素和一个
href
属性链接到另一个文档即可

如果您需要有关特定数据的帮助,请发布一个小但有代表性的XML输入示例以及您想要创建的HTML

[编辑]

假设您有一个包含两个
a:file
元素的输入文档,并且希望创建一个主HTML文档,列出所有
a:names
链接到单独的文件,列出详细信息,您可以按如下方式解决该问题:

<xsl:template match="/">
  <xsl:apply-templates select="//a:file" mode="doc"/>
  <html>
    <head>
      <title>Example</title>
    </head>
    <body>
      <h1>Data list</h1>
      <ul>
        <xsl:apply-templates select="//a:file"/>
      </ul>
    </body>
  </html>
</xsl:template>

<xsl:template match="a:file">
  <li>
    <a href="{a:id}.html">
      <xsl:value-of select="a:name"/>
    </a>
  </li>
</xsl:template>

<xsl:template match="a:file" mode="doc">
  <xsl:result-document href="{a:id}.html">
    <html>
      <head>
        <title>Details of <xsl:value-of select="a:name"/></title>
      </head>
      <body>
        <table>
          <thead>
            <tr>
             <xsl:apply-templates mode="thead"/>
            </tr>
          </thead>
          <tbody>
            <tr>
             <xsl:apply-templates mode="doc"/>
            </tr>
          </tbody>
        </table>
      </body>
    </html>
  </xsl:result-document>
</xsl:template>

<xsl:template match="a:file/*" mode="doc">
  <td>
    <xsl:value-of select="."/>
  </td>
</xsl:template>

<xsl:template match="a:file/*" mode="thead">
  <th>
   <xsl:value-of select="local-name()"/>
  </th>
</xsl:template>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Example</title>
   </head>
   <body>
      <h1>Data list</h1>
      <ul>
         <li><a href="33.html">hello</a></li>
      </ul>
   </body>
</html>




<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Details of hello</title>
   </head>
   <body>
      <table>
         <thead>
            <tr>

               <th>id</th>

               <th>name</th>

               <th>school</th>

               <th>marks</th>

            </tr>
         </thead>
         <tbody>
            <tr>

               <td>33</td>

               <td>hello</td>

               <td>mumbai public</td>

               <td>80</td>

            </tr>
         </tbody>
      </table>
   </body>
</html>

因此,这对我来说很好,无论是文件数量还是浏览器内部的链接都是如此。

是的,我使用a和href进行了同样的操作,但是如何在第二个html上显示特定记录的信息。假设我点击了一个名为“详细信息”的链接,那么当我点击详细信息时,我应该只得到一个特定的信息,而不是所有的信息。在这一页上,我显示了所有的名字,当我点击名字时,我应该被重定向到另一页,显示完整的细节。我已经编辑了我的答案,并添加了一个代码示例,展示了如何处理这个问题,它将主要转换结果生成为显示所有项的HTML文档,然后链接到显示单个项详细信息的进一步结果文档。您可以使用Saxon 9或其他XSLT 2.0处理器(如AltovaXML或XmlPrime)运行该结果。如果您想了解有关如何使用Saxon 9运行样式表的详细信息,请咨询。我只得到一个输出文件,其余什么都没有
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:a="http://example.com/a"
  exclude-result-prefixes="a"
  version="2.0">

<xsl:template match="/">
  <xsl:apply-templates select="//a:file" mode="doc"/>
  <html>
    <head>
      <title>Example</title>
    </head>
    <body>
      <h1>Data list</h1>
      <ul>
        <xsl:apply-templates select="//a:file"/>
      </ul>
    </body>
  </html>
</xsl:template>

<xsl:template match="a:file">
  <li>
    <a href="{a:id}.html">
      <xsl:value-of select="a:name"/>
    </a>
  </li>
</xsl:template>

<xsl:template match="a:file" mode="doc">
  <xsl:result-document href="{a:id}.html">
    <html>
      <head>
        <title>Details of <xsl:value-of select="a:name"/></title>
      </head>
      <body>
        <table>
          <thead>
            <tr>
             <xsl:apply-templates mode="thead"/>
            </tr>
          </thead>
          <tbody>
            <tr>
             <xsl:apply-templates mode="doc"/>
            </tr>
          </tbody>
        </table>
      </body>
    </html>
  </xsl:result-document>
</xsl:template>

<xsl:template match="a:file/*" mode="doc">
  <td>
    <xsl:value-of select="."/>
  </td>
</xsl:template>

<xsl:template match="a:file/*" mode="thead">
  <th>
   <xsl:value-of select="local-name()"/>
  </th>
</xsl:template>

</xsl:stylesheet>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Example</title>
   </head>
   <body>
      <h1>Data list</h1>
      <ul>
         <li><a href="33.html">hello</a></li>
      </ul>
   </body>
</html>




<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Details of hello</title>
   </head>
   <body>
      <table>
         <thead>
            <tr>

               <th>id</th>

               <th>name</th>

               <th>school</th>

               <th>marks</th>

            </tr>
         </thead>
         <tbody>
            <tr>

               <td>33</td>

               <td>hello</td>

               <td>mumbai public</td>

               <td>80</td>

            </tr>
         </tbody>
      </table>
   </body>
</html>