19 April 2015

Access attribute of list in ADF

I want to display 2 rows/records using PanelForm side-by-side in ADF. The records are something like this:  1st record will have old version of the data and 2nd record will have new version of the data. Both versions of data has to be displayed side-by-side to give a view to user for verifying it.

Solution:
1. Assume the data control is having the rows under "list" element.
2. Drag-and-Drop "list" element to ADF form.
3. You will get a popup for to select the UI Control. Select "Table/List view" -> ADF Table(readonly). This will create bindings for "list"


4. Now, use the following expression to access the 2nd row's attribute "col1"

bindings.list.children[1].col1


5. Now the output looks like this:



18 April 2015

No projects displayed in Jdeveloper

I couldn't see any projects under Applications/ Application Navigator in JDeveloper. It looks like this:


In this case, just goto Window -> Reset Windows To Factory Settings then the project files will be displayed.

17 April 2015

Filter unique records among 2 collections in XML using XSLT

Here is my usecase: I have two collections. First collection is having large no.of records and other one is having few records. Here is the xsd for these 2 collections:

Here is the sample xsd file that I have used for XSLT mapping:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://beta.example.org"
            xmlns:a="http://beta.example.org" targetNamespace="http://beta.example.org" elementFormDefault="qualified">
    <xsd:element name="employees">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="employee" type="a:employee" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:complexType name="employee">
        <xsd:sequence>
            <xsd:element name="name" type="xsd:string"/>
            <xsd:element name="salary" type="xsd:integer"/>
            <xsd:element name="age" type="xsd:integer"/>
            <xsd:element name="id" type="xsd:integer"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="person">
        <xsd:sequence>
            <xsd:element name="id" type="xsd:integer"/>
            <xsd:element name="name" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="persons">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="person" type="a:person" maxOccurs="unbounded" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="output">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="worker" type="a:employee" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

Here I have used 2 collections: employees and persons as input to XSLT and "output" as outcome of XSLT. Now, I want to eliminate employees whose IDs are matching with IDs in persons. Here is the XSLT I have created for achieving this:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
    <xsl:param name="input2"/>
    <xsl:variable name="values" >
        ,<xsl:for-each select="$input2/ns0:persons/ns0:person"><xsl:value-of select="./ns0:id"/>,</xsl:for-each>
    </xsl:variable>
    <!-- document('')/xsl:stylesheet/ns0:persons/ns0:person/ns0:id
    $input2/ns0:persons/ns0:person/ns0:id
    -->
    <xsl:template match="/">
        <ns0:output>
            <xsl:for-each select="/ns0:employees/ns0:employee">
            <xsl:if test="not(contains($values, concat(',', current()/ns0:id, ',')))">
                <ns0:worker>
                    <ns0:id>
                        <xsl:value-of select="current()/ns0:id"/>
                    </ns0:id>
                </ns0:worker>
                </xsl:if>
            </xsl:for-each>
        </ns0:output>
    </xsl:template>

Details of this implementation:
I have created a variable values which will have all the IDs of persons eg. ",1,2,3,". Then employees iterated and checks for it's ID in values. If not, then that record will be mapped to output.