xslt中的ANCHOR标签HREF [英] ANCHOR tag HREF in xslt

查看:77
本文介绍了xslt中的ANCHOR标签HREF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我需要您的帮助来使用xslt调用锚标记.我的xml文件中都有我所有的脚注内容,并且已对它们进行编号.这些数字也将出现在我的xml文件的主要内容中.因此,当我单击内容中的数字时,它应该带我到xml文件中下面列出的相应脚注数字.

有人遇到过这种情况吗?

如果是这样,请让我知道或将我带到相关文章中以获取一些知识.

提前谢谢.

Hi all,
I need your help for invoking anchor tags using xslt. I have all my footnotes contents below in my xml file and they are numbered. These numbers will also be in the main content of my xml file. So when i click on the number inside content, it should take me to the respective footnote number listed below in xml file.

Does anyone came across such case?

If so, kindly let me know or route me to the related article to get some knowledge.

Thanks in advance.

xml file sample:
<Text>
<Section>
 <Clause>
  <Para>
   <Para>
    <Footnote> [1] </Footnote>
   </Para>
  </Para>
 </Clause>

 <Explanation>
  <Footnote> [2] </Footnote> 
 </Explanation>
</Section>

<Footnotes>
 <Link>[1]</Link>
 <Linkcont>
 	<Foot1>dated January 6, 1994 : </Foot1>
 </Linkcont>
 <Link>[2]</Link>
 <Linkcont><Foot2>Inserted by Act </Foot2></Linkcont>
</Footnotes>
</Text>


我应该以以下方式编写xslt.脚注内容将显示在页面上方,脚注内容将显示在页面下方.
[1]
[2]


[1]
1994年1月6日:
[2]
依法插入.

如果我单击上方的[1],它将带我到屏幕底部,即脚注内容. [1]日期:1994年1月6日:
同样,如果我单击[2],它应该带我到脚注[2],由Act插入.
希望这很清楚,否则请让我知道,以使其更易于理解.


I should write xslt in the following manner. Footnote content will be displayed above and footnotes contents will be displayed below the page.
[1]
[2]


[1]
dated January 6, 1994 :
[2]
Inserted by Act.

if i click on [1] above it should take me to the bottom of my screen that is footnotes content. [1] dated January 6, 1994 :
Similarly if i click on [2] it should take me to footnotes [2] Inserted by Act.
Hope this is clear, if not please let me know to make it further more easier to understand.

推荐答案

1.手动编写所需的HTML.
2.编写一个XSLT,将XML转换为HTML
我认为听起来很简单明了.
如果您在编写预期的HTML方面遇到困难,请提出一个相应的问题.
如果您在生成锚点名称时遇到麻烦,请查看 generate-id() [ ^ ]函数.

顺便说一句:按照我的口味,您的XML结构不好.如果您可以控制它,我强烈建议您获得更好的结构(例如,这样您就可以使用链接ID而不是generate-id()函数来建立链接),例如

1. Write the expected HTML manually.
2. Write an XSLT that converts the XML into that HTML
Sounds quite simple and straight forward, I think.
If you struggle with writing the expected HTML, ask a respective question.
If you struggle with generating the anchor name, look at the generate-id()[^] function.

BTW: your XML is badly structured for my taste. If you have that under control, I would strongly suggest to get a better structure (i.e. so that you can use the link id instead of generate-id() function to make the links), e.g.

<?xml version="1.0" encoding="utf-8"?>

<Text>
  <Section>
    <Clause>
      <Para>
        Some <Footnote Ref="1">text</Footnote> and so on.
      </Para>
    </Clause>

    <Explanation>
      Some other <Footnote Ref="2">text</Footnote> etc.
    </Explanation>
  </Section>

  <Footnotes>
    <Note Id="1">dated January 6, 1994 :</Note>
    <Note Id="2">Inserted by Act.</Note>
  </Footnotes>
</Text>



使用以下XSLT,您将获得一个链接的HTML,如下所示:



With the following XSLT, you get a linked HTML as shown further down:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"

>
  <xsl:output method="html" indent="yes"/>

  <xsl:template match="/">
    <html>
      <head><xsl:call-template name="SetStyles"/></head>
      <body>
        <xsl:call-template name="WriteText"/>
        <xsl:call-template name="WriteFootnotes"/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="Footnote">
    <xsl:variable name="Id" select="@Ref"/>
    <xsl:variable name="Link" select="concat('#',


Id)" > < xsl:variable 名称 =" 选择 //文字/脚注/注释[@Id =
Id)"/> <xsl:variable name="Tip" select="/Text/Footnotes/Note[@Id=


Id]" > < xsl:value-of 选择 =" / > < sup > < a =" footnoteref" href ="
Id]"/> <xsl:value-of select="."/> <sup><a class="footnoteref" href="{


这篇关于xslt中的ANCHOR标签HREF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆