我想使用Wikipedia API查找法语页面,包括英语版本中缺少的“ SQLTemplate:Infobox Scientifique”。因此,我的想法是使用xproc处理以下文档:
和以下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提取了包含模板的所有文章,对于每一个我想调用Wikipedia以获得Wiki之间链接的文章。在这里,模板englishTitle调用xpath函数document()
。
但是它总是说count(ll)=1
,而节点很多。 (例如http://fr.wikipedia.org/w/api.php?action=query&format=xml&prop=langlinks&lllimit=500&titles=Carl_Sagan。)>
我无法处理document()
函数返回的节点吗?
我想使用Wikipedia API查找法语页面,包括英语版本中缺少的“ SQLTemplate:Infobox Scientifique”。因此,我的想法是使用...
您应该尝试: