Hi!! I am doing the following- <xsl:template name="Process"> <xsl aram name="X1" ></xsl aram> <xsl aram name="X2" ></xsl aram> <xsl:variable name="merger"> <xsl:value-of select="$X1"/> <xsl:value-of select="$X2"/> </xsl:variable> <xsl:for-each select="$merger/item"> <xsl:choose> <xsl:when test="$X1/item = 'someValue'">do should check in X1</xsl:when> <xsl:when test="some condition">this should check condition in merger</xsl:when> </xsl:choose> </xsl:for-each> </xsl:template> When I try this, I am getting the TRUE to the condition $X1/item = 'someValue' condition even if 'someValue' is in $merger and not in $X1. Can't I access $X1 like this while traversing $merger with for-each? Thanks in advance. Tina
Alongwith being a good coder, try to be a good professional as well!
It is not very clear what is required fron this test stub. Just to clearify more if $X1 = "one" $X2 = "two" Then $merger becomes "onetwo" so your context node in the for loop becomes "onetwo/item". Hence when you check for "$X1/item in your for loop you are checking for the node "onetwo/item/one/item". Is this what you are try to imply!
No Tina, This kind of runtime creation of names is not possible here. I think you're trying to keep the option of specifying some element name at runtime and calling the template 'Process' with the 2 params containing 2 parts of the name, concatenating which you're planning to construct the element name. Well, this kind of an operation is not possible. In fact, in some cases, even XMLSPY gives you an error, stating 'Invalid XPath expression'. Hope this helps. Dhananjay
Joined: Mar 13, 2003
Thank you Dhananjay. Actually any given time, I have a hierarchy of elements. So I get the hierarchy in the X1 variable and the current in the X2 variable. If some Id value is true for the whole hierarchy then and then only I create a structure for X2 values(the current one) The values in the hierarchy can be of 4 types only and so can repeat. like- X1 Type1 (Id1) Type2 (Id2) X2 Type1 (Id3) Thank you to you all. Tina