xml – 使用html中的xslt创建一个链接到其他html
发布时间:2020-12-16 23:28:01 所属栏目:百科 来源:网络整理
导读:我有以下xml代码: ?xml version="1.0" encoding="UTF-8"??xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"??xml-model href="http:
我有以下xml代码:
<?xml version="1.0" encoding="UTF-8"?> <?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?> <?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> <TEI xmlns="http://www.tei-c.org/ns/1.0"> <teiHeader/> <text> <head n="3">Capitulo primeyro</head> <pb facs="folio16r.jpg"/> <div> <p>... figurado <app> <lem>pollo</lem> <rdg wit="#A">pollo</rdg> <rdg wit="#B">pello</rdg> </app> Parayso ...</p> <p> ... <app> <lem>sacar?</lem> <rdg wit="#A">sacar?</rdg> <rdg wit="#B">ssaee</rdg> </app> ...</p> </div> <pb facs="folio16v.jpg"/> <div> <p> .... os fisicos <app> <lem>dessesperarom</lem> <rdg wit="#A">desseperarom</rdg> <rdg wit="#B">desesper?</rdg> </app> ... que assy <app> <lem>saa</lem> <rdg wit="#A">sooa</rdg> <rdg wit="#B">saa</rdg> </app> ...</p> </div> </body> </text> 使用我的XSL,我已经获得了3个不同的HTML(一个用于A,一个用于B,一个用于引理).我在应用程序的XSL中创建了一个模板: <xsl:template match="app"> <xsl:variable name="appNumber" select="count(preceding::app) + 1"/> <a href="#app_{$appNumber}"><xsl:apply-templates select="lem"/></a> </xsl:template> <xsl:template match="app" mode="footnote"> <xsl:variable name="appNumber" select="count(preceding::app) + 1"/> <li id="app_{$appNumber}"> <xsl:for-each select="rdg"> <i><xsl:apply-templates/></i><xsl:text> </xsl:text> <a> <xsl:attribute name="href"> <xsl:text>#</xsl:text> <xsl:apply-templates select="app"/> </xsl:attribute> <xsl:value-of select="substring-after(@wit,'#')"> </xsl:value-of> </a> <xsl:text> </xsl:text> <br/> <xsl:if test="position() lt last()"></xsl:if> </xsl:for-each> </li> </xsl:template> 现在我有这个HTML: <ul> <li id="app_1"><i>prophetas</i> <a href="#">Editor</a> <br /><i>prophetas</i> <a href="#">A</a> <br /></li> <li id="app_2"><i>pollo</i> <a href="#">Editor</a> <br /><i>pollo</i> <a href="#">A</a> <br /></li> <li id="app_3"><i>sacar?</i> <a href="#">Editor</a> <br /><i>sacar?</i> <a href="#">A</a> <br /></li> <li id="app_4"><i>dessesperarom</i> <a href="#">Editor</a> <br /><i>desseperarom</i> <a href="#">A</a> <br /></li> <li id="app_5"><i>saa</i> <a href="#">Editor</a> <br /><i>sooa</i> <a href="#">A</a> <br /></li> <li id="app_6"><i>ante</i> <a href="#">Editor</a> <br /><i>ante</i> <a href="#">A</a> <br /></li> </ul> 当你看到开始在li中创建一个链接但我没有得到我想要的.我想说的是链接从机智(#A或#B或#Editor)到另一个html中的相同文本点.例如,如果我正在查看A html,在应用程序中,单击B我想要转到B html中的相同文本点.任何人都可以帮忙吗? 解决方法
如果我做对了,这只是关于链接的正确组成.看来你有一个设备文件应该链接到每个设备条目上的不同源文件.实际上,你很亲密.试试这个:
<xsl:attribute name="href"> <xsl:value-of select="substring-after(@wit,'#')"/> <xsl:text>.html#app_</xsl:text> <xsl:value-of select="$appNumber"/> <xsl:apply-templates select="app"/> </xsl:attribute> 这将产生这样的链接: <a href="A.html#app_2">A</a> 我假设你已经一直在为自己找到它.我想回答这个问题,也许它对某些人来说仍然有用. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |