本文介绍了难以使超链接在XML文档中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我对xml和xsl很新,所以这可能非常简单。我有一个包含一些数据的xml文件和一个xsl文件,可以将其处理成一个网页。什么不起作用的是超链接。我已经阅读了关于xlink如何工作的无穷无尽的页面,但对我来说它不是。没有错误,只是纯文本,没有超链接。我正在运行Firefox 2.0.0.3,但也尝试在IE7中获得完全相同的结果。 这是一些样本xml,从w3schools取消并略微按摩。我希望有人可以指出我哪里出错。 谢谢 Rob [html ]<?xml version =" 1.0" encoding =" ISO-8859-1"?> <?xml-stylesheet type =" text / xsl" href =" bookstore.xsl"?> < bookstore xmlns:xlink =" http://www.w3.org/1999/xlink"> < book> < description xlink:type =" simple" xlink:href =" ../ RPS / ComingUp.xml"> Text1 < / description> < /预订> < book> < description xlink:type =" simple" xlink:href =" http://www.cam.ac.uk" xlink:show =" new"> Text2< / description> < / book> < / bookstore> [/ html] 和一些相应的xsl [html]<?xml version =" 1.0" encoding =" ISO-8859-1"?> < xsl:stylesheet version =" 1.0" xmlns:xsl =" http://www.w3.org/1999/XSL/Transform"> < xsl:template match =" /"> < html> < head> < meta http-equiv =" Content-Language" content =" en-gb">< / meta> < meta http-equiv =" Content-Type"含量=" text / html的; charset = windows-1252">< / meta> < title>书店< / title> < link rel =" stylesheet"类型= QUOT;文本/ CSS" href =" ../ rps.css">< / link> < / head> < body> ; < xsl:for-each select =" bookstore / book"> < xsl:value-of select =" description" /> < br /> < / xsl:for-each> < / body> < / html> < / xsl:template> < / xsl:stylesheet> [/ html] 渐弱: 请使用html或代码标签作为源代码。谢谢,主持人。解决方案 感谢您的建议。可悲的是,当我运行你的代码时,我只得到一个空白页面。当我删除if测试时,页面显示超链接,这是明确的进展。不幸的是,链接只是指向xml文件,而不是指向我在xlink:href属性中指定的URL,即file:/// E:/www/TryOut/book2.xml"而不是,例如,http://www.cam.ac.uk"。 谢谢 Rob I''m quite new to xml and xsl, so this could be quite simple. I have an xml file with some data in it and an xsl file to process it into a web page. What doesn''t work is hyperlinks. I''ve read endless pages about how xlink works, but for me it just doesn''t. No errors, just plain text and no hyperlinks. I''m running Firefox 2.0.0.3 but have also tried in IE7, getting exactly the same result.Here is some sample xml, lifted from w3schools and slightly massaged. I hope someone can point out where I''m going wrong.ThanksRob[html]<?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="bookstore.xsl"?><bookstore xmlns:xlink="http://www.w3.org/1999/xlink"><book> <description xlink:type="simple" xlink:href="../RPS/ComingUp.xml"> Text1 </description></book><book> <description xlink:type="simple" xlink:href="http://www.cam.ac.uk" xlink:show="new">Text2</description></book></bookstore>[/html]and some corresponding xsl[html]<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"> <html> <head> <meta http-equiv="Content-Language" content="en-gb"></meta> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></meta> <title>Bookstore</title> <link rel="stylesheet" type="text/css" href="../rps.css"></link> </head> <body> <xsl:for-each select="bookstore/book"><xsl:value-of select="description"/><br/> </xsl:for-each> </body> </html></xsl:template></xsl:stylesheet>[/html] Waning: Please use html or code tags for source code. Thanks, moderator. 解决方案 这篇关于难以使超链接在XML文档中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-31 08:13