Tuesday, April 14, 2015

Index or paramter passed to XSL not working while using as xpath predicate

Some time we want to pass the index of a node as a parameter to XSL. Inside the xsl we want to use that particular index to get the right node from a complex xml document.

There are many blogs already explaining how we can achieve this.

But there is a small catch in that approach. Here I am trying to explain how we can over come that issue.

As described in other blogs, the steps to pass parameters are as shown below.

1) Defining a parameter.xsd.

Parameter.xsd
----------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://schemas.oracle.com/parameters"
            targetNamespace="http://schemas.oracle.com/parameters"
            elementFormDefault="qualified">
 <xsd:element name="parameters">
    <xsd:complexType>
      <xsd:sequence>    
              <xsd:element name="startIndex" type="xsd:string"/>
              <xsd:element name="endIndex" type="xsd:string"/>
            </xsd:sequence>  
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

2) Define a bpel variable of type parameter

 <variable name="parameters" element="ns3:parameters"/>

Note: Ensure you import the target names space in our BPEL file
 xmlns:ns3="http://schemas.oracle.com/parameters"

3) Initialize the values in the above variable
<assign name="Init">
        <copy>
                <from expression="number(3)"/>
                <to variable="parameters"
                    query="/ns3:parameters/ns3:startIndex"/>
            </copy>
 </assign>

4) Pass the  variable to xsl transform function.

 <from expression="ora:doXSLTransformForDoc('xsl/xForm_CustomerOrder_To_FulfillmentOrder.xsl', $inputVariable.payload, 'parameters', $parameters)"/>

5) Inside the xsl file extract the parameters and use it in the xpath expression to pick the right node.

 <xsl:variable name="startIndex" select="$parameters/ns1:parameters/ns1:startIndex"/>
 <xsl:variable name="endIndex" select="$parameters/ns1:parameters/ns1:endIndex"/>

 Inside the xsl file  if you are using this parameter value as positional search. e.g  CustomerOrder/OrderLine[$startindex]  it will not work


To make it working we need to type cast the above  values to number while assigning to the xsl variable

 <xsl:variable name="startIndex" select="number($parameters/ns1:parameters/ns1:startIndex)"/>
 <xsl:variable name="endIndex" select="number($parameters/ns1:parameters/ns1:endIndex)"/>

Then it will work for positional search. If it is a text based search then this type casting is not required.

How to prevent auto compilation in JDev 12c. How to stop Live Issues Tab popping up

It is very noisy that the auto compilation prevents us modifying the code as the window of Live Issues tab keeps on coming up.

I read in few blogs that this issue can be resolved by setting the SaveAction properties to null in the Jdev->Tools->Preferences



But even after setting this in my JDev the code was getting auto compiled and the Live Issues tab was keeps on coming.

So the simplest way to solve this is to divide your screen. Just drag the Live Issues tab down to your Process tab. In such a way that the Live issues will be shown at the bottom of the page. This will help you to work on the code and watch the issues simultaneously