Xslt 获取超链接的url
我必须将xslt写入wordml(2007)文档。有如下超链接Xslt 获取超链接的url,xslt,xpath,xslt-1.0,xslt-2.0,Xslt,Xpath,Xslt 1.0,Xslt 2.0,我必须将xslt写入wordml(2007)文档。有如下超链接 < w:p w:rsidR="00FD086A" w:rsidRDefault="00425A76" w:rsidP="00FD086A"> < w: hyperlink r:id="rId4" w:history="1"> < w:r w:rsidR="00FD086A" w:rsidRPr="00425A76"> < w:rPr> < w:rStyle w:val="Hype
< w:p w:rsidR="00FD086A" w:rsidRDefault="00425A76" w:rsidP="00FD086A">
< w: hyperlink r:id="rId4" w:history="1">
< w:r w:rsidR="00FD086A" w:rsidRPr="00425A76">
< w:rPr>
< w:rStyle w:val="Hyperlink"/>
< /w:rPr>
< w:t>google</w:t>
< /w:r>
< /w:hyperlink>
< /w:p>
谷歌
我想获取链接名的url。在这里,我想得到“谷歌”链接的url。我知道它存在于关系中,但我无法使用xslt访问它。有人知道吗?(可能在写模板?)请帮帮我 假设声明了以下命名空间前缀:
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
xmlns:rel="http://schemas.openxmlformats.org/package/2006/relationships"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
以下XPath可用于使用w:hyperlink/@r:id
的值来选择URL的值(本例中的硬编码值为“rId5”):
您可以在w:hyperlink
上的模板匹配上下文中使用它来生成HTML锚元素,如下所示:
<xsl:template match="w:hyperlink">
<a href="{/pkg:package
/pkg:part
/pkg:xmlData
/rel:Relationships
/rel:Relationship[@Id=current()/@r:id]/@Target}">
<xsl:apply-templates/>
</a>
</xsl:template>
您的XML与您的描述不匹配。网址在哪里?关系在哪里?url位于普通word 2007文档的“关系”中。。是这样的。你真是太棒了!这很有魅力!我希望我能投票赞成这个答案。但我需要更多的名声。这真是太棒了^_^我还有一个问题。你也能看看吗^_^
<xsl:template match="w:hyperlink">
<a href="{/pkg:package
/pkg:part
/pkg:xmlData
/rel:Relationships
/rel:Relationship[@Id=current()/@r:id]/@Target}">
<xsl:apply-templates/>
</a>
</xsl:template>