<xsl:apply-templates mode="block2sequence" select="NewDataSet/Table[CTD_CTD_PKG_ID =$PackageId][position()=1] and NewDataSet/Table[CTD_SEQ_NUM =$strXSLMsgType][position()=1]"/>
why cant i use two conditions in above select condition, can any one suggest me
I guess this is to mean, “why can’t the two conditions be specified in the same predicate?“
The answer is that the expression:
isn’t equivalent at all to the 1st expression above.
The first expression selects the first
Tablechild ofNewDataSetsuch that the string value of itsCTD_CTD_PKG_IDchild is equal to the string value of$PackageId. In this case we don’t know which child (at which position) ofNewDataSetwill be selected — any child that happens to be the first with the specified properties, will be selected.On the other side, the latter expression selects the first
Tablechild ofNewDataSetonly if the string value of itsCTD_CTD_PKG_IDchild is equal to the string value of$PackageId. In this case, if anything is selected, it would be the firstTablechild.If you want an equivalent expression to the first one, that has only one predicate, one such expression is:
Update: The OP has published a code snippet:
This code will cause an error thrown at compile time by the XSLT processor.
The value of the
selectattribute is a boolean (expr1 and expr2), however templates in XSLT 1.0 and XSLT 2.0 can only be applied on nodes. A boolean isn’t a node — hence the error.Solution:
My first guess is that you want templates to be applied on both nodes. If this is so, then use:
My second guess is that you want templates applied only on the first of the two nodes. If this is so, then use:
Notes:
Please, learn how to ask a question — provide all relevant data and explain — in the question, not in subsequent comments.
Did you know that
[1]is equivalent to[position()=1]and is shorter?