Problem when trying to get value outside from details' tag

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem when trying to get value outside from details' tag

Lescano Blanco, Mack
Hi guys:

I have problems with this configuration
The xml input is:

<invoices>
<invoice>
<supplier>123</supplier>
<item>
<no>1</no>
<product>456</product>
<supplier2>123</supplier2>
</item>
<item>
<no>2</no>
<product>789</product>
<supplier2>123</supplier2>
</item>
</invoice>
<invoice>
<supplier>111</supplier>
<item>
<no>1</no>
<product>456</product>
<supplier2>111</supplier2>
</item>
<item>
<no>2</no>
<product>789</product>
<supplier2>111</supplier2>
</item>
</invoice>
</invoices>

And this is my smooks config

<dao:locator beanId="productBean" lookup="searchProduct" dao="locator" lookupOnElement="invoices/invoice/item" onNoResult="NULLIFY" uniqueResult="true">
<dao:params>
<dao:value name="coSupplier" data="invoices/invoice/supplier" decoder="Integer"/>
<dao:value name="coProduct" data="invoices/invoice/item/product" decoder="Integer"/>
</dao:params>
</dao:locator>


The problem is that "invoices/invoice/supplier" is not working approperly.

I'd like that you can help me. I attach my POC.

Regards


NOTICE: Protect the information in this message in accordance with the company's security policies. If you received this message in error, immediately notify the sender and destroy all copies.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

example08.zip (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Sql reader used with smooks datasource

Lescano Blanco, Mack
Hi guys, I need your help

Is it possible in smooks that a JavaXMLReader implementation can use a configured datasource?.
I implemented a sql reader but I can not bound to the context of the datasource configured in #document.

Can you help me?

Thanks


smooks.xml
<import file="../db/datasource.xml" />

<reader class="com.smooks.SqlListMapReader">
<params>
<param name="sqlStatement"><![CDATA[
select
pds.ELEMENT_1,
pds.ELEMENT_2,
pds.ELEMENT_3,
pds.ELEMENT_4,
pds.ELEMENT_5,
pds.ELEMENT_6,
PDS.TRAN_DATE,
(pds.ACCOUNT_DESCRIPTION || ' ' || pds.ST_CODE) as ACCOUNT_DESCRIPTION,
pds.DR_CR,
pds.ACCT_AMT
from
PDL_DATA_STAGE_CODA_MOCK pds
where
1 = 1
--and TRUNC(pds.TRAN_DATE) = :feCorte
]]></param>
</params>
</reader>


datasource.xml
<?xml version="1.0"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:ds="http://www.milyn.org/xsd/smooks/datasource-1.3.xsd">
<ds:direct bindOnElement="#document"
datasource="DBStars3LoadDS"
driver="oracle.jdbc.driver.OracleDriver"
url="xxx"
username="xxx"
password="xxx"
autoCommit="false" />
</smooks-resource-list>






NOTICE: Protect the information in this message in accordance with the company's security policies. If you received this message in error, immediately notify the sender and destroy all copies.
Reply | Threaded
Open this post in threaded view
|

Re: Sql reader used with smooks datasource

Tom Fennelly
Hmmm... I'd suspect that your problem is that the reader is created before that datasource i.e. the datasource does not exist at the time of reader creation.  You should be able to debug it and see.

On 23/09/2013 16:28, Lescano Blanco, Mack wrote:
Hi guys, I need your help

Is it possible in smooks that a JavaXMLReader implementation can use a configured datasource?.
I implemented a sql reader but I can not bound to the context of the datasource configured in #document.

Can you help me?

Thanks


smooks.xml
<import file="../db/datasource.xml" />

<reader class="com.smooks.SqlListMapReader">
<params>
<param name="sqlStatement"><![CDATA[
select
pds.ELEMENT_1,
pds.ELEMENT_2,
pds.ELEMENT_3,
pds.ELEMENT_4,
pds.ELEMENT_5,
pds.ELEMENT_6,
PDS.TRAN_DATE,
(pds.ACCOUNT_DESCRIPTION || ' ' || pds.ST_CODE) as ACCOUNT_DESCRIPTION,
pds.DR_CR,
pds.ACCT_AMT
from
PDL_DATA_STAGE_CODA_MOCK pds
where
1 = 1
--and TRUNC(pds.TRAN_DATE) = :feCorte
]]></param>
</params>
</reader>


datasource.xml
<?xml version="1.0"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:ds="http://www.milyn.org/xsd/smooks/datasource-1.3.xsd">
<ds:direct bindOnElement="#document"
datasource="DBStars3LoadDS"
driver="oracle.jdbc.driver.OracleDriver"
url="xxx"
username="xxx"
password="xxx"
autoCommit="false" />
</smooks-resource-list>






NOTICE: Protect the information in this message in accordance with the company's security policies. If you received this message in error, immediately notify the sender and destroy all copies.

Reply | Threaded
Open this post in threaded view
|

Re: Sql reader used with smooks datasource

Lescano Blanco, Mack
Hi Tom:
Yes You are right, when I debug that line
Connection conn = AbstractDataSource.getConnection(datasource, execContext);

I obtain the variable conn as null, but I dont know if it's possible to get the configuration of DirectDataSource in the reader.

Regards


From: "Tom Fennelly" <[hidden email]>
To: [hidden email]
Sent: Monday, September 23, 2013 3:52:02 PM
Subject: Re: [milyn-user] Sql reader used with smooks datasource

Hmmm... I'd suspect that your problem is that the reader is created before that datasource i.e. the datasource does not exist at the time of reader creation.  You should be able to debug it and see.

On 23/09/2013 16:28, Lescano Blanco, Mack wrote:
Hi guys, I need your help

Is it possible in smooks that a JavaXMLReader implementation can use a configured datasource?.
I implemented a sql reader but I can not bound to the context of the datasource configured in #document.

Can you help me?

Thanks


smooks.xml
<import file="../db/datasource.xml" />

<reader class="com.smooks.SqlListMapReader">
<params>
<param name="sqlStatement"><![CDATA[
select
pds.ELEMENT_1,
pds.ELEMENT_2,
pds.ELEMENT_3,
pds.ELEMENT_4,
pds.ELEMENT_5,
pds.ELEMENT_6,
PDS.TRAN_DATE,
(pds.ACCOUNT_DESCRIPTION || ' ' || pds.ST_CODE) as ACCOUNT_DESCRIPTION,
pds.DR_CR,
pds.ACCT_AMT
from
PDL_DATA_STAGE_CODA_MOCK pds
where
1 = 1
--and TRUNC(pds.TRAN_DATE) = :feCorte
]]></param>
</params>
</reader>


datasource.xml
<?xml version="1.0"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:ds="http://www.milyn.org/xsd/smooks/datasource-1.3.xsd">
<ds:direct bindOnElement="#document"
datasource="DBStars3LoadDS"
driver="oracle.jdbc.driver.OracleDriver"
url="xxx"
username="xxx"
password="xxx"
autoCommit="false" />
</smooks-resource-list>






NOTICE: Protect the information in this message in accordance with the company's security policies. If you received this message in error, immediately notify the sender and destroy all copies.



NOTICE: Protect the information in this message in accordance with the company's security policies. If you received this message in error, immediately notify the sender and destroy all copies.
Reply | Threaded
Open this post in threaded view
|

Re: Sql reader used with smooks datasource

Tom Fennelly
I don't think that'll be your easiest path.  The readers are kind of a special case.  I think you'd be better just setting up the DB connection params yourself separately within the reader code (and forgetting about the DirectDataSource etc).

On 24/09/2013 00:28, Lescano Blanco, Mack wrote:
Hi Tom:
Yes You are right, when I debug that line
Connection conn = AbstractDataSource.getConnection(datasource, execContext);

I obtain the variable conn as null, but I dont know if it's possible to get the configuration of DirectDataSource in the reader.

Regards


From: "Tom Fennelly" [hidden email]
To: [hidden email]
Sent: Monday, September 23, 2013 3:52:02 PM
Subject: Re: [milyn-user] Sql reader used with smooks datasource

Hmmm... I'd suspect that your problem is that the reader is created before that datasource i.e. the datasource does not exist at the time of reader creation.  You should be able to debug it and see.

On 23/09/2013 16:28, Lescano Blanco, Mack wrote:
Hi guys, I need your help

Is it possible in smooks that a JavaXMLReader implementation can use a configured datasource?.
I implemented a sql reader but I can not bound to the context of the datasource configured in #document.

Can you help me?

Thanks


smooks.xml
<import file="../db/datasource.xml" />

<reader class="com.smooks.SqlListMapReader">
<params>
<param name="sqlStatement"><![CDATA[
select
pds.ELEMENT_1,
pds.ELEMENT_2,
pds.ELEMENT_3,
pds.ELEMENT_4,
pds.ELEMENT_5,
pds.ELEMENT_6,
PDS.TRAN_DATE,
(pds.ACCOUNT_DESCRIPTION || ' ' || pds.ST_CODE) as ACCOUNT_DESCRIPTION,
pds.DR_CR,
pds.ACCT_AMT
from
PDL_DATA_STAGE_CODA_MOCK pds
where
1 = 1
--and TRUNC(pds.TRAN_DATE) = :feCorte
]]></param>
</params>
</reader>


datasource.xml
<?xml version="1.0"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:ds="http://www.milyn.org/xsd/smooks/datasource-1.3.xsd">
<ds:direct bindOnElement="#document"
datasource="DBStars3LoadDS"
driver="oracle.jdbc.driver.OracleDriver"
url="xxx"
username="xxx"
password="xxx"
autoCommit="false" />
</smooks-resource-list>






NOTICE: Protect the information in this message in accordance with the company's security policies. If you received this message in error, immediately notify the sender and destroy all copies.



NOTICE: Protect the information in this message in accordance with the company's security policies. If you received this message in error, immediately notify the sender and destroy all copies.