Project

Profile

Help

XPTY0020 Error

Added by Anonymous almost 15 years ago

Legacy ID: #7470706 Legacy Poster: Toshihiko Makita (tmakita)

Dear Michael Kay, I'm struggling with error message "XPTY0020: Cannot select a node here: the context item is an atomic value". The stylesheet fragments are following. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:l="http://www.xxx.com/names/XSLT/Document/Layout" > ... <xsl:template match="l:attribute-set"> <xsl:element name="{string(@name)}"> <xsl:if test="@use-attribute-sets"> <xsl:for-each select="tokenize(string(@use-attribute-sets), ',\s*')"> <xsl:apply-templates select="//l:attribute-set[string(@name)=string(.)]" mode="use-attribute-sets"/> </xsl:for-each> </xsl:if> <xsl:apply-templates select="l:attribute"/> </xsl:element> </xsl:template> <xsl:template match="l:attribute-set" mode="use-attribute-sets"> <xsl:if test="@use-attribute-sets"> <xsl:for-each select="tokenize(string(@use-attribute-sets), ',\s*')"> <xsl:apply-templates select="//l:attribute-set[string(@name)=string(.)]" mode="use-attribute-sets"/> </xsl:for-each> </xsl:if> <xsl:apply-templates select="l:attribute"/> </xsl:template> Saxonb9-1-0-7j outputs this error for above two templates. As I'm not familiar with Saxon9, I cannot understand this error message. If I comment-out the xsl:if, the error messages do not appear. What is wrong with this stylesheet? Regards,


Replies (2)

RE: XPTY0020 Error - Added by Anonymous almost 15 years ago

Legacy ID: #7470894 Legacy Poster: Toshihiko Makita (tmakita)

This problem has solved and I understood the meaning of error message. Sorry for bother you. I rewrote the template as follows: <xsl:template match="l:attribute-set"> <xsl:variable name="currentElement" select="."/> <xsl:element name="{string(@name)}"> <xsl:if test="@use-attribute-sets"> <xsl:for-each select="tokenize(string(@use-attribute-sets), ',\s*')"> <xsl:call-template name="processUseAttributeSet"> <xsl:with-param name="prmAttributeSet" select="string(.)"/> <xsl:with-param name="prmCurrentElement" select="$currentElement"/> </xsl:call-template> </xsl:for-each> </xsl:if> <xsl:apply-templates select="l:attribute"/> </xsl:element> </xsl:template> <xsl:template name="processUseAttributeSet"> <xsl:param name="prmAttributeSet" select="''"/> <xsl:param name="prmCurrentElement" select="/.."/> <xsl:apply-templates select="root($prmCurrentElement)//l:attribute-set[string(@name)=$prmAttributeSet]" mode="use-attribute-sets"/> </xsl:template> <xsl:template match="l:attribute-set" mode="use-attribute-sets"> <xsl:variable name="currentElement" select="."/> <xsl:if test="@use-attribute-sets"> <xsl:for-each select="tokenize(string(@use-attribute-sets), ',\s*')"> <xsl:call-template name="processUseAttributeSet"> <xsl:with-param name="prmAttributeSet" select="string(.)"/> <xsl:with-param name="prmCurrentElement" select="$currentElement"/> </xsl:call-template> </xsl:for-each> </xsl:if> <xsl:apply-templates select="l:attribute"/> </xsl:template>

RE: XPTY0020 Error - Added by Anonymous almost 15 years ago

Legacy ID: #7471045 Legacy Poster: Toshihiko Makita (tmakita)

<xsl:for-each select="tokenize(string(@use-attribute-sets), ',\s*')"> should be <xsl:for-each select="tokenize(string(@use-attribute-sets), '[,\s]+')">

    (1-2/2)

    Please register to reply