xml - xsl:copy-of : could not compile select expression -
i trying transform xml file using xsl stylesheet.
xml file
<?xml version="1.0" encoding="utf-8"?> <msg> <ent key="key1"> <text>error: not find </text> <translation>another error similar previous one.</translation> </ent> </msg>
xsl file
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="msg"> <xsl:for-each select="ent"> <xsl:variable name="current_key" select="@key"/> <xsl:variable name="match" select="$translations/msg/ent[@key = $current_key]"/> <xsl:choose> <xsl:when test="$match , normalize-space($match/text) = normalize-space(.) , (not(@translate) or @translate = true())"> <xsl:copy> <xsl:copy-of select="$match/(@key|translation/text())|@context"/> </xsl:copy> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:template> </xsl:stylesheet>
@translate
1 of attributes have not included in example xml file.
i using perl transformation. use script mentioned in answer, when following error,
invalid expression compilation error: file test.xsl line 11 element copy-of xsl:copy-of : not compile select expression '$match/(@key|translation/text())|@context' @ transform.pl line 10
why select
expression causing problem?
using $match/(@key|translation/text())
allowed in xpath 2.0 used in xslt 2.0 perl use xslt 1.0 processor libxslt. need spell out $match/@key | $match/translation/text()
.
Comments
Post a Comment