Hi,
I have a question
I am using XSLT 1.0 and I have a variable like this-
<xsl:variable name="colC" select="'2,3,5'"/>
And I have a C# code within the XSLT like
<msxsl:script language="C#" implements-prefix="user">
<msxsl:assembly name="System.Web" />
<msxsl:using namespace="System.Web" />
<![CDATA[
public string GetNo()
{
foreach(var cnt in colC)
{
return cnt.ToString();
}
}]]>
</msxsl:script>
All I want to know is, can I use the variable colC within my foreach loop, it is throwing an error as of now.
Also, say I have a comma separated variable
<xsl:variable name="idTest" select="'3,4'"/>
And I have the below XSLT code; If you see the below code, there are some conditions which I am checking, I am not sure when that will get satisfied, if it gets satisfied, I want to access the comma separated values; if the first condition gets satisfied I want to access the first value from idTest and whenever the condition gets satisfied, I want to access the comma separated values one after the other; is this possible. I am trying this logic for the past one week and I have not got any break through, could you please advice on this. Thanks.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"
xmlns:user="urn:my-scripts"
>
<xsl:output method="text" indent="yes" omit-xml-declaration="yes"/>
<xsl:include href="..\PFFunctions\PFXMLFunctions.xslt"/>
<xsl:key name="PIR" match="//XMLContent/PDI/DATA/CHILD" use="@PTDI_PTRNUM"/>
<xsl:key name="FDR" match="//XMLContent/FDDATA/DATA/CHILD" use="@PTDI_PTRNUM"/>
<xsl:variable name="idTest" select="'3,4'"/>
<xsl:param name="ParamPartnerKeyName" select="''"/>
<xsl:variable name="id-list" select="concat(',', $ParamPartnerKeyName, ',')"/>
<xsl:param name="Importvalues" select="''"/>
<xsl:variable name="id-listReimport" select="concat(',', $Importvalues, ',')"/>
<xsl:param name="Descvalues" select="''"/>
<xsl:variable name="id-listDesc" select="concat(',', $Descvalues, ',')"/>
<xsl:param name="DirectK1ReImport" select="''"/>
<xsl:param name="DirectK1HeaderInfo" select="''"/>
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$ParamPartnerKeyName=''">
<xsl:choose>
<xsl:when test="translate($DirectK1ReImport, $smallcase, $uppercase) = 'TRUE'">
<xsl:apply-templates select="XMLContent/FDDATA/DATA/CHILD[string(number(@PTDI_PTRNUM)) != 'NaN' and (@PTDI_PTRNUM != '0')]" mode="REIMP"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="XMLContent/FDDATA/DATA/CHILD[string(number(@PTDI_PTRNUM)) != 'NaN' and (@PTDI_PTRNUM != '0') and contains($id-list, concat(',', @PTDI_PTRNUM, ','))]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="translate($DirectK1ReImport, $smallcase, $uppercase) = 'TRUE'">
<xsl:apply-templates select="XMLContent/FDDATA/DATA/CHILD[string(number(@PTDI_PTRNUM)) != 'NaN' and (@PTDI_PTRNUM != '0') and contains($id-list, concat(',', @PTDI_PTRNUM, ','))]"
mode="REIMP"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="XMLContent/FDDATA/DATA/CHILD[string(number(@PTDI_PTRNUM)) != 'NaN' and (@PTDI_PTRNUM != '0') and contains($id-list, concat(',', @PTDI_PTRNUM, ','))]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="CHILD">
<xsl:variable name="RecordNo">
<xsl:value-of select="position()"/>
</xsl:variable>
<xsl:variable name="PartnerNo" select="@PTDI_PTRNUM"/>
<!-- Actual data starts here -->
<xsl:variable name="ColFB" select="@FDK1_BOYPPCT"/>
<xsl:variable name="ColFBd" select="normalize-space(//XMLContent/FDDATA/DATA/CHILD[4]/@FDK1_BOYPPCT)"/>
<xsl:choose>
<xsl:when test="contains($id-listReimport, concat(',', 'FDK1_BOYPPCT', ','))">
<xsl:choose>
<xsl:when test="translate($ColFB, $smallcase, $uppercase) != ''">
<xsl:text>"TEST NOTES","</xsl:text>
<xsl:value-of select="$RecordNo"/>
<xsl:text>","10","0","TEST NOTES AMOUNT","</xsl:text>
<xsl:value-of select ="$idTest"/>
<xsl:text>","O"
</xsl:text>
<xsl:text>"TEST NOTES","</xsl:text>
<xsl:value-of select="$RecordNo"/>
<xsl:text>","10","0","TEST NOTES DESCRIPTION","</xsl:text>
<xsl:value-of select="$ColFBd"/>
<xsl:text>","O"
</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
<!-- Fed: Col K -->
<xsl:variable name="ColFB1" select="@FDK1_BOYLPCT"/>
<xsl:variable name="ColFBd1" select="normalize-space(//XMLContent/FDDATA/DATA/CHILD[4]/@FDK1_BOYLPCT)"/>
<xsl:choose>
<xsl:when test="contains($id-listReimport, concat(',', 'FDK1_BOYLPCT', ','))">
<xsl:choose>
<xsl:when test="translate($ColFB1, $smallcase, $uppercase) != ''">
<xsl:text>"TEST NOTES","</xsl:text>
<xsl:value-of select="$RecordNo"/>
<xsl:text>","11","0","TEST NOTES AMOUNT","</xsl:text>
<xsl:value-of select ="$idTest"/>
<xsl:text>","O"
</xsl:text>
<xsl:text>"TEST NOTES","</xsl:text>
<xsl:value-of select="$RecordNo"/>
<xsl:text>","11","0","TEST NOTES DESCRIPTION","</xsl:text>
<xsl:value-of select="$ColFBd1"/>
<xsl:text>","O"
</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
<!-- Fed: Col L -->
<xsl:variable name="ColFB2" select="@FDK1_BOYCAP"/>
<xsl:variable name="ColFBd2" select="normalize-space(//XMLContent/FDDATA/DATA/CHILD[4]/@FDK1_BOYCAP)"/>
<xsl:choose>
<xsl:when test="contains($id-listReimport, concat(',', 'FDK1_BOYCAP', ','))">
<xsl:choose>
<xsl:when test="translate($ColFB2, $smallcase, $uppercase) != ''">
<xsl:text>"TEST NOTES","</xsl:text>
<xsl:value-of select="$RecordNo"/>
<xsl:text>","12","0","TEST NOTES AMOUNT","</xsl:text>
<xsl:value-of select ="$idTest"/>
<xsl:text>","O"
</xsl:text>
<xsl:text>"TEST NOTES","</xsl:text>
<xsl:value-of select="$RecordNo"/>
<xsl:text>","12","0","TEST NOTES DESCRIPTION","</xsl:text>
<xsl:value-of select="$ColFBd2"/>
<xsl:text>","O"
</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Rpaul