I have one alias file which is acting as a wraper to XML.

<Alias name='Type'>

generally this return MEConsumed or MEResource. I want the behaviour that if @subType=MEConsumed then it should return CON and when @subType=MEResource then it should return "REF".
Help me with this .. i am very new to all this


if ()
    then expression 
  if (@subType=MEResource)
  else expression

XPath has conditional statements, but XSLT might be easier to use since you only want to test two conditions. Then, you could use

<xsl:if test="{@subType=MEConsumed}">
<xsl:if test="{@subType=MEResource}"

Note, XSLT and XPath do not return statements like Java or other programming languages would. You'd want to set a variable and check it or set an attribute and check it.

Then again, their might be another way. Hope this helps even a little bit. :)

<Alias name='Type'>
<xsl:if test="{@subType=MEConsumed}">
<xsl:if test="{@subType=MEResource}"

on using this it throws an error::

The character '>' was expected. Error processing resource 'file://tc1016/New Folder/ME_FOLDER/Short-Term-Work/20_Anish/TcPu...

<xsl:if test="{@subType=MEConsumed}">
Please guide

<Alias name='Type'>
<xsl:if test="{@subType=MEConsumed}">
    <xsl:variable name="testvar" value="CON" />
<xsl:if test="{@subType=MEResource}"[B]>[/B] <!--here is where > was missing-->
<xsl:variable name="testvar" value="REF" />

You need to create a variable
<xsl:variable name="ids" select="@ids" /> <!-- For instance -->
Initialize it, and then use that in place of "variableName/testVar." If you are calling a template, pass it using xsl:with-param and call it in the template as xsl:param. Here is a detailed description of xsl:param

Yes that missing > i already placed. Still problem remains unchanged. I think the problem is related to introduce XSL syntax in XPATH.

<xsl:variable name="ids" select="@subType"/>
<xsl:call-template name="TY">
<xsl:with-param name="ids" />

<xsl:template match="TY">
<xsl:param name="ids" />
<xsl:when test="starts-with($ids,'MEConsumed')">
<xsl:value-of select="'CON'"/>
<xsl:when test="starts-with($ids,'MEResource')">
<xsl:value-of select="'REF'"/>


<xsl:value-of select="'NONE'"/>


Please help me asap.