Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have in XML file like this

<ViewFields> 
<FieldRef Name="Approval Status" /> 
<FieldRef Name="Requirement Status" /> 
<FieldRef Name="Development Status" /> 
<FieldRef Name="Testing Status" />
</ViewStatus>

I have the following XSL code to get FieldRef values.

<xsl:template name="FieldRef_body.Status" match="FieldRef[@Name='ViewFields/FieldRef[1]/@Name']" mode="body">
        <xsl:param name="thisNode" select="."/>
            <xsl:choose>
                <xsl:when test="$thisNode/@*[name()=current()/@Name] = 'Completed'">
                    <img src="/_layouts/images/IMNON.png" alt="Status: {$thisNode/@Status}"/>
                </xsl:when>
                <xsl:when test="$thisNode/@*[name()=current()/@Name] = 'In Progress'">
                    <img src="/_layouts/images/IMNIDLE.png" alt="Status: {$thisNode/@Status}"/>
                </xsl:when>
                <xsl:otherwise>
                    <img src="/_layouts/images/IMNBUSY.png" alt="Status: {$thisNode/@Status}"/>
                </xsl:otherwise>
            </xsl:choose>
    </xsl:template>

I am trying to LOOP through FieldRef*[x]* to get the values one by one, it's not returning anything. I want to assign FieldRef values to @Name variable through loop.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
148 views
Welcome To Ask or Share your Answers For Others

1 Answer

This is obvious:

  1. match="FieldRef[@Name='ViewFields/FieldRef[1]/@Name']". No Name attribute has as string value the string 'ViewFields/FieldRef[1]/@Name'. You most probably want an XPath expression here, not a string. Use match="FieldRef[@Name=ViewFields/FieldRef[1]/@Name]"

  2. There is no Name attribute in the provided XML document with string value "Completed" or with string value "In Progress".

  3. Also, there isn't any Status attribute at all in the XML document.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...