tags:

views:

88

answers:

1

hello,

i want to make that type of xsl file which remove the namespace value as well as adding parameter value in xml file. here is my latest xsl file, which removed the namespace but didn't add param value into "t0019/ifta_account" template. so when data transfer from xml to database at that time file name not set into (xml_ifta_account) table. we are try transferring xml data into table using java xsu api.

EDIT(Jim Garrison): Reformatted, removed ordered list due to bug in Markdown Engine http://meta.stackoverflow.com/questions/19624/bug-in-markdown-formatter/19799#19799
END-OF-EDIT

(note: xsl file param value set from outside when xsl file is call. using this xsl file we adding data from xml to database.)

xml file : (name of xml file: user_if_account.xml)

    <T0019 XMLNS:XSI="HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE" XSI:SCHEMALOCATION="HTTP://WWW.SAFERSYS.ORG/NAMESPACES/T0019V1 T0019V1.XSD" XMLNS="HTTP://WWW.SAFERSYS.ORG/NAMESPACES/T0019V1"&gt;

          <XSL:PARAM NAME="FILE_NAME" SELECT="T0019/IFTA_ACCOUNT/FILE_NAME" />

          <IFTA_ACCOUNT> 
             <IFTA_CARRIER_ID_NUMBER>705</IFTA_CARRIER_ID_NUMBER> 
             <IFTA_BASE_COUNTRY>US</IFTA_BASE_COUNTRY>
          </IFTA_ACCOUNT>

          <IFTA_ACCOUNT> 
             <IFTA_CARRIER_ID_NUMBER>706</IFTA_CARRIER_ID_NUMBER> 
             <IFTA_BASE_COUNTRY>US</IFTA_BASE_COUNTRY>
          </IFTA_ACCOUNT>

    </T0019>

table structure:(xml_ifta_account)

    FILE_NAME                   VARCHAR2(120)
    IFTA_CARRIER_ID_NUMBER      VARCHAR2(12)
    BASE-COUNTY                 VARCHAR2(2)

XSL file

    <XSL:TEMPLATE MATCH="/">
         <XSL:ELEMENT NAME="T0019">
             <XSL:APPLY-TEMPLATES SELECT="* | T0019/IFTA_ACCOUNT">
             </XSL:APPLY-TEMPLATES>
         </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>

    <XSL:TEMPLATE MATCH="T0019/IFTA_ACCOUNT">

        <XSL:ELEMENT NAME="IFTA_ACCOUNT">

            <XSL:ELEMENT NAME="FILE_NAME">
                <XSL:VALUE-OF SELECT="$FILE_NAME"/>
            </XSL:ELEMENT>

            <XSL:ELEMENT NAME="IFTA_CARRIER_ID_NUMBER">
                <XSL:VALUE-OF SELECT="IFTA_CARRIER_ID_NUMBER"/>
            </XSL:ELEMENT>

            <XSL:ELEMENT NAME="IFTA_CARRIER_ID_NUMBER">
                <XSL:VALUE-OF SELECT="IFTA_CARRIER_ID_NUMBER"/>
            </XSL:ELEMENT>

        </XSL:ELEMENT>

    </XSL:TEMPLATE>

Wanted output : XML_IFTA_ACCOUNT

    FILE_NAME           IFTA_CARRIER_ID_NUMBER     BASE-COUNTY   
    USER_IF_ACCOUNT     705                        US
    USER_IF_ACCOUNT     706                        US

please please please help me. if any other confusion then let me know.

A: 

I want to insert data into database table using XSLT file. My problem is as follow :

  1. I have one XML file which contain some namespace but its create problem when i parsing this XML file using XSU JAVA API classes which is basically use for insert data from XML to ORACLE database.

and my SECOND problem is i also want to add one external parameter value "FILE_NAME" into Oracle database table. Which is not into XML file contain. Which is actually XML file name. Which i must be set from external level.

so i want to make that type of XSL file which basically use for remove problematic namespace value from XML as well as set param value which is "FILE_NAME" value, which value i set send from outside the XSL file. Here is the code :

     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);

        //now set FileInputStream Parameter for Inserting XML data to Oracle table.D:\CCVIEW\TRANS XSLT FILES\PROCESS XML
      //  FileInputStream xmlFileNameForInserting = new FileInputStream(CviewFileReader.readFileFromClassPathAsURL(xmlFolderLocationForProcessXmlFile).getFile().substring(1).replace("%20", " "));

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

so please tell me that how is it possible that inserting data from XML to oracle

Saumil