我想使用wikipedia API来查找法文页面,包括英文版中缺少的''Template:Infobox Scientifique''。所以,我的想法是处理与XPROC以下文件:使用xslt,xpath:document()和mediawiki的Recusive转换
和下面的XSLT样式表:
<?xml version='1.0' ?>
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version='1.0'
>
<xsl:output method='text' indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="api"/>
</xsl:template>
<xsl:template match="api">
<xsl:for-each select="query/embeddedin/ei">
<xsl:variable name="title" select="translate(@title,' ','_')"/>
<xsl:variable name="english-title">
<xsl:call-template name="englishTitle"><xsl:with-param name="title" select="@title"/></xsl:call-template>
</xsl:variable>
<xsl:value-of select="$english-title"/><xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template name="englishTitle">
<xsl:param name="title"/>
<xsl:variable name="uri1" select="concat('http://fr.wikipedia.org/w/api.php?action=query&format=xml&prop=langlinks&lllimit=500&titles=',translate($title,' ','_'))"/>
<xsl:message><xsl:value-of select="$uri1"/></xsl:message>
<xsl:message>count=<xsl:value-of select="count(document($uri1,/api/query/pages/page/langlinks/ll))"/></xsl:message>
</xsl:template>
</xsl:stylesheet>
的XSLT提取出所有包含该模板的文章,每篇文章我想调用维基百科获得维基之间的链接。这里,模板englishTitle调用xpath函数document()。
但它总是说count(ll)=1
而有很多节点。 (例如http://fr.wikipedia.org/w/api.php?action=query&format=xml&prop=langlinks&lllimit=500&titles=Carl_Sagan)。
我不能处理由文件()函数返回的节点?
谢谢,它的工作:-) – Pierre 2009-07-14 18:55:32