tags:

views:

71

answers:

1

Hello,

I have a following xml file .

T0020.xml

SAFER 04.02 01.00 REPLACE 2009-09-01T00:00:00 CT 274845 US AR 55002 I 100 2007-11-06 2009-08-03

I have to insert xml data into following table

IRP_ACCOUNT

Field Name Field Type

FILE_NAME VARCHAR2(120) IRP_ACCOUNT_NUMBER VARCHAR2(32) IRP_ACCOUNT_TYPE VARCHAR2(1) IRP_CARRIER_ID_NUMBER VARCHAR2(12) IRP_BASE_COUNTRY VARCHAR2(12) IRP_BASE_STATE VARCHAR2(12) IRP_STATUS_CODE VARCHAR2(12) IRP_STATUS_DATE VARCHAR2(10) IRP_UPDATE_DATE VARCHAR2(10)

My code to insert xml Data into Database is ...

OracleXMLSave oracleXMLSave =new OracleXMLSave(conn, tableNamePro);

    //set XSL file.
    File xslFileName = new File(CviewFileReader.readFileFromClassPathAsURL(xslFolderLocation + "/" + rootNode.trim() + "/" + xslFileNamePro.trim() + ".xsl").getFile().substring(1).replace("%20", " "));
    Reader xsltReader=new FileReader(xslFileName);
    oracleXMLSave.setXSLT(xsltReader, null);

    //set fileNameParameterValueIn XLS file. so this value insert into database table as "FILE_VALUE" field.
    oracleXMLSave.setXSLTParam("FILE_NAME", "'" + onlyXMLfileName + "'");

    //set row separter value.
    oracleXMLSave.setRowTag(xmlRowTagVal);

    //set ignoreCase to true.
    oracleXMLSave.setIgnoreCase(true);        

     //give here XML file path
     FileInputStream xmlFileNameForInserting = new FileInputStream(xmlFileName.getAbsoluteFile());
     oracleXMLSave.insertXML(xmlFileNameForInserting);

My XSLT File for Inserting Data is ...

When applying this xslt to insert to Database only FILE_NAME value which has been passed through xslt parameter is not inserted into Database.

See below all value are inserted except FILE_NAME.

FILE_NAME IRP_ACCOUNT_NUMBER IRP_ACCOUNT_TYPE IRP_CARRIER_ID_NUMBER IRP_BASE_COUNTRY IRP_BASE_STATE IRP_STATUS_CODE IRP_STATUS_DATE IRP_UPDATE_DATE


55002 I 274845 US AR 100 2007-11-06 2009-08-03

I have stuck on this point Pls help me....still any confusion then let me know...

Thanks in Advance.

A: 

Where exactly do you put the <xsl:element> part? Did you declare <xsl:param name="FILE" /> in your stylesheet?

Michael Krelin - hacker
ya following declaration i have made <xsl:param name="FILE_NAME" select="T0019/IFTA_ACCOUNT/FILE_NAME" />above <xsl:template match="/"> .
Nisarg Mehta
<xsl:param name="FILE_NAME" select="T0020/IRP_ACCOUNT/FILE_NAME" value=""/><xsl:template match="/"> <xsl:element name="T0020"> <xsl:apply-templates select="* | T0020/IRP_ACCOUNT"/> </xsl:element> </xsl:template><xsl:template match="*"> <xsl:element name="{local-name()}"> <xsl:apply-templates select="@* | node()"/> </xsl:element> </xsl:template> <xsl:template match="@* | text() | comment() | processing-instruction()"> <xsl:copy/> </xsl:template>
Nisarg Mehta
<xsl:template match="T0020/IRP_ACCOUNT"> <xsl:element name="IRP_ACCOUNT"> <xsl:element name="FILE_NAME"> <xsl:value-of select="$FILE_NAME"/> </xsl:element> <xsl:element name="IRP_BASE_STATE"> <xsl:value-of select="IRP_BASE_STATE"/> </xsl:element> .... ..... .....</xsl:element> </xsl:template></xsl:stylesheet>
Nisarg Mehta
But what is `T0020` supposed to match in your sample document, to begin with?
Michael Krelin - hacker
Pls dont consider T0020 xslt statment,i have mistakenly paste it..my xslt i have pasted in my question pls consider that...Sorry for wrong posting bcoz of first time on this ...
Nisarg Mehta
Michael Can i provide u detail of Question if u didn't get that one ?
Nisarg Mehta
I'm not sure I follow you, the best you can do is state in details what is your input (minimal, but complete, both sample xml and xsl), what is expected output, etc.
Michael Krelin - hacker
I have posted same question on below link Please check this link as i am unable to edit my question properly.http://p2p.wrox.com/xslt/77578-xslt-parameter-value-not-inserted-into-database.html#post251473I will be waiting for your reply..
Nisarg Mehta