Rahul Agarwal wrote:

I'm using XSLT processor in one of my pipeline. I'm having following block of code -

Rahul,

You are saying that you get an error when the "Request" node does not exist. What is the error message you are getting? A couple of comments about the code snippet you sent:

1) In your code you have:

    <xsl:variable name="NodeValue" select="..."/>
    <xsl:if test="$NodeValue = ''">
        <xsl:variable name="NodeValue" select="..."/>
    </xsl:if>

You should get an error for the second <xsl:variable> as you are declaring a new variable with the same name as another one that is already in scope (NodeValue declared in the first line).

2) To check if a node exists, I suggest you use the exists() function. The main reason to use this function is code clarity. So I would write something like:

    <xsl:variable name="RequestValue" as="attribute()?"
        select="/Root/ApplicationX/Request/@value"/>
    <xsl:variable name="NodeValue" as="xs:string"
        select="if (exists($RequestValue) then $RequestValue
        else /Root/ApplicationX/Request/@value"/>

Note the "as" attributes on the variables. It is good practice to always indicate the expected type in your XSLT code. Even just using simple types, element(), attribute() with a cardinality will most likely save you a lot of time down the road.

Alex


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
orbeon-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/orbeon-user

Reply via email to