带有django模板变量的xslt

时间:2014-03-10 12:26:36

标签: python xml django xslt xml-parsing

以下是我的XSLT文件和xml

我正在使用python-Django处理它,

    sheet=<pathtoxsltfile>
    style = libxml2.parseFile(sheet)
    style = libxslt.parseStylesheetDoc(style)
    result = style.applyStylesheet(xml, None)
    markup = style.saveResultToString(result)

想在xslt中的锚标记处添加locationID的值。

<locationID>94</locationID>位于xml第66行

并且

<a href="">see me!</a>标记位于XSLT的第223行。

我试过这个但没有用,

<a href="<xsl:value-of disable-output-escaping="yes" select="locationID"/>">see me!</a>

2 个答案:

答案 0 :(得分:1)

你可以这样做:

{{ locations.0.locationID }}

答案 1 :(得分:0)

试过这个,

<xsl:element name="a">
    <xsl:attribute name="href">
        <xsl:value-of select="locationID "/>
    </xsl:attribute>
    <xsl:value-of select="locationID"/>
</xsl:element>

它有效。