XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Nisarg MehtaSubject: Value of File Name is not accessing through XSLT
Author: Nisarg Mehta
Date: 23 Dec 2009 06:16 AM
Originally Posted: 23 Dec 2009 04:37 AM
We have following XSLT file through which we are inserting xml file data
to Database.We have used

<xsl:param name="FILE_NAME" select="T0020/IRP_ACCOUNT/FILE_NAME"/>

to insert xml file name into the Table
<xsl:element name="FILE_NAME">
<xsl:value-of select="$FILE_NAME"/>
</xsl:element>

Which is not inserted into table ...

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="FILE_NAME" select="T0020/IRP_ACCOUNT/FILE_NAME"/>

<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()">
<xsl:copy/>
</xsl:template>


<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_CARRIER_ID_NUMBER">
<xsl:value-of select="IRP_CARRIER_ID_NUMBER"/>
</xsl:element>
.....
.....

</xsl:element>

</xsl:template>

</xsl:stylesheet>

but when we try to insert file name with the use of XSLT Param
it is not inserted into database pls help..

If you need more details i can provide so....

Postnext
Ivan PedruzziSubject: Value of File Name is not accessing through XSLT
Author: Ivan Pedruzzi
Date: 04 Jan 2010 12:05 PM

Can you share a sample of your input XML?


Ivan Pedruzzi
Stylus Studio Team

Postnext
Nisarg MehtaSubject: Value of File Name is not accessing through XSLT
Author: Nisarg Mehta
Date: 04 Jan 2010 11:56 PM
ya sure ,we have following many files as input

<?xml version="1.0" encoding="ISO-8859-1"?>
<T0020
xsi:schemaLocation="http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.safersys.org/namespaces/T0020V1">
<INTERFACE>
<NAME>SAFER</NAME>
<VERSION>04.02</VERSION>
</INTERFACE>
<TRANSACTION>
<VERSION>01.00</VERSION>
<OPERATION>REPLACE</OPERATION>
<DATE_TIME>2009-09-01T00:00:00</DATE_TIME>
<TZ>CT</TZ>
</TRANSACTION>
<IRP_ACCOUNT>
<IRP_CARRIER_ID_NUMBER>274845</IRP_CARRIER_ID_NUMBER>
<IRP_BASE_COUNTRY>US</IRP_BASE_COUNTRY>
<IRP_BASE_STATE>AR</IRP_BASE_STATE>
<IRP_ACCOUNT_NUMBER>55002</IRP_ACCOUNT_NUMBER>
<IRP_ACCOUNT_TYPE>I</IRP_ACCOUNT_TYPE>
<IRP_STATUS_CODE>100</IRP_STATUS_CODE>
<IRP_STATUS_DATE>2007-11-06</IRP_STATUS_DATE>
<IRP_UPDATE_DATE>2009-08-03</IRP_UPDATE_DATE>
<IRP_NAME>
<NAME_TYPE>LG</NAME_TYPE>
<NAME>A P SUPPLY CO</NAME>
<IRP_ADDRESS>
<ADDRESS_TYPE>PH</ADDRESS_TYPE>
<STREET_LINE_1>1400 N OATS</STREET_LINE_1>
<STREET_LINE_2/>
<CITY>TEXARKANA</CITY>
<STATE>AR</STATE>
<ZIP_CODE>71854</ZIP_CODE>
<COUNTY>MILLER</COUNTY>
<COLONIA/>
<COUNTRY>US</COUNTRY>
</IRP_ADDRESS>
<IRP_ADDRESS>
<ADDRESS_TYPE>MA</ADDRESS_TYPE>
<STREET_LINE_1>P O BOX 1927</STREET_LINE_1>
<STREET_LINE_2/>
<CITY>TEXARKANA</CITY>
<STATE>AR</STATE>
<ZIP_CODE>75504</ZIP_CODE>
<COUNTY/>
<COLONIA/>
<COUNTRY>US</COUNTRY>
</IRP_ADDRESS>
</IRP_NAME>
</IRP_ACCOUNT>
</T0020>

So our requirement is that we want mapping from XML to Database
(below table XML_ACCOUNT).

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

IRP_NAME and NAME_TYPE will be inserted into another table(XML_NAME) .
same as Address.

for that we have applied two XSLT

[1] first XSLT will remove namespace from XML file and copy all other Data to Intermediate XML file say Process.XML.
<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>
[2] then we applied another XSLT on Process.XML to insert data to Database .

Note: here FILE_NAME parameter is set by the application,which insert
file name of XML file.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<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="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_CARRIER_ID_NUMBER">
<xsl:value-of select="IRP_CARRIER_ID_NUMBER"/>
</xsl:element>

<xsl:element name="IRP_BASE_COUNTRY">
<xsl:value-of select="IRP_BASE_COUNTRY"/>
</xsl:element>

<xsl:element name="IRP_BASE_STATE">
<xsl:value-of select="IRP_BASE_STATE"/>
</xsl:element>

<xsl:element name="IRP_ACCOUNT_NUMBER">
<xsl:value-of select="IRP_ACCOUNT_NUMBER"/>
</xsl:element>

<xsl:element name="IRP_ACCOUNT_TYPE">
<xsl:value-of select="IRP_ACCOUNT_TYPE"/>
</xsl:element>

<xsl:element name="IRP_STATUS_CODE">
<xsl:value-of select="IRP_STATUS_CODE"/>
</xsl:element>

<xsl:element name="IRP_STATUS_DATE">
<xsl:value-of select="IRP_STATUS_DATE"/>
</xsl:element>

<xsl:element name="IRP_UPDATE_DATE">
<xsl:value-of select="IRP_UPDATE_DATE"/>
</xsl:element>

</xsl:element>

</xsl:template>
</xsl:stylesheet>



At this point everything worked fine but then we tried to merge both XSLT which will do two thing :
[1]It will remove namespace (which cause problem while inserting data )and
[2] Insert Data to Database .

That merged XSLT i have already mentioned in question.

Than FILE_NAME which was passed from Application as XSLT Parameter is not inserted into Database.I don't know what problem is there.

So for that we need your help.I hope my question is little bit clear to you.

Thanks a lot for helping out.Thanks in advance.




Postnext
Nisarg MehtaSubject: Value of File Name is not accessing through XSLT
Author: Nisarg Mehta
Date: 05 Jan 2010 12:15 AM
ya sure ,we have following many files as input

<?xml version="1.0" encoding="ISO-8859-1"?>
<T0020
xsi:schemaLocation="http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.safersys.org/namespaces/T0020V1">
<INTERFACE>
<NAME>SAFER</NAME>
<VERSION>04.02</VERSION>
</INTERFACE>
<TRANSACTION>
<VERSION>01.00</VERSION>
<OPERATION>REPLACE</OPERATION>
<DATE_TIME>2009-09-01T00:00:00</DATE_TIME>
<TZ>CT</TZ>
</TRANSACTION>
<IRP_ACCOUNT>
<IRP_CARRIER_ID_NUMBER>274845</IRP_CARRIER_ID_NUMBER>
<IRP_BASE_COUNTRY>US</IRP_BASE_COUNTRY>
<IRP_BASE_STATE>AR</IRP_BASE_STATE>
<IRP_ACCOUNT_NUMBER>55002</IRP_ACCOUNT_NUMBER>
<IRP_ACCOUNT_TYPE>I</IRP_ACCOUNT_TYPE>
<IRP_STATUS_CODE>100</IRP_STATUS_CODE>
<IRP_STATUS_DATE>2007-11-06</IRP_STATUS_DATE>
<IRP_UPDATE_DATE>2009-08-03</IRP_UPDATE_DATE>
<IRP_NAME>
<NAME_TYPE>LG</NAME_TYPE>
<NAME>A P SUPPLY CO</NAME>
<IRP_ADDRESS>
<ADDRESS_TYPE>PH</ADDRESS_TYPE>
<STREET_LINE_1>1400 N OATS</STREET_LINE_1>
<STREET_LINE_2/>
<CITY>TEXARKANA</CITY>
<STATE>AR</STATE>
<ZIP_CODE>71854</ZIP_CODE>
<COUNTY>MILLER</COUNTY>
<COLONIA/>
<COUNTRY>US</COUNTRY>
</IRP_ADDRESS>
<IRP_ADDRESS>
<ADDRESS_TYPE>MA</ADDRESS_TYPE>
<STREET_LINE_1>P O BOX 1927</STREET_LINE_1>
<STREET_LINE_2/>
<CITY>TEXARKANA</CITY>
<STATE>AR</STATE>
<ZIP_CODE>75504</ZIP_CODE>
<COUNTY/>
<COLONIA/>
<COUNTRY>US</COUNTRY>
</IRP_ADDRESS>
</IRP_NAME>
</IRP_ACCOUNT>
</T0020>

So our requirement is that we want mapping from XML to Database
(below table XML_ACCOUNT).

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

IRP_NAME and NAME_TYPE will be inserted into another table(XML_NAME) .
same as Address.

for that we have applied two XSLT

[1] first XSLT will remove namespace from XML file and copy all other Data to Intermediate XML file say Process.XML.
<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>
[2] then we applied another XSLT on Process.XML to insert data to Database .

Note: here FILE_NAME parameter is set by the application,which insert
file name of XML file.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<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="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_CARRIER_ID_NUMBER">
<xsl:value-of select="IRP_CARRIER_ID_NUMBER"/>
</xsl:element>

<xsl:element name="IRP_BASE_COUNTRY">
<xsl:value-of select="IRP_BASE_COUNTRY"/>
</xsl:element>

<xsl:element name="IRP_BASE_STATE">
<xsl:value-of select="IRP_BASE_STATE"/>
</xsl:element>

<xsl:element name="IRP_ACCOUNT_NUMBER">
<xsl:value-of select="IRP_ACCOUNT_NUMBER"/>
</xsl:element>

<xsl:element name="IRP_ACCOUNT_TYPE">
<xsl:value-of select="IRP_ACCOUNT_TYPE"/>
</xsl:element>

<xsl:element name="IRP_STATUS_CODE">
<xsl:value-of select="IRP_STATUS_CODE"/>
</xsl:element>

<xsl:element name="IRP_STATUS_DATE">
<xsl:value-of select="IRP_STATUS_DATE"/>
</xsl:element>

<xsl:element name="IRP_UPDATE_DATE">
<xsl:value-of select="IRP_UPDATE_DATE"/>
</xsl:element>

</xsl:element>

</xsl:template>
</xsl:stylesheet>



At this point everything worked fine but then we tried to merge both XSLT which will do two thing :
[1]It will remove namespace (which cause problem while inserting data )and
[2] Insert Data to Database .

That merged XSLT i have already mentioned in question.

Than FILE_NAME which was passed from Application as XSLT Parameter is not inserted into Database.I don't know what problem is there.

So for that we need your help.I hope my question is little bit clear to you.

Thanks a lot for helping out.Thanks in advance.




Postnext
Ivan PedruzziSubject: Value of File Name is not accessing through XSLT
Author: Ivan Pedruzzi
Date: 05 Jan 2010 11:55 AM
Hi Steven,

You don't need two style-sheets for this, see the attached transformation.


Ivan Pedruzzi
Stylus Studio Team


Documentt.xsl

Postnext
Nisarg MehtaSubject: Value of File Name is not accessing through XSLT
Author: Nisarg Mehta
Date: 06 Jan 2010 09:14 AM
Thanks Ivan for the wonderful help.
I have one more question regarding this and i am posting in same thread.

When mapping from XML to Database ,we have come across one problem that when XML file is too large(more than 10 mb)then while mapping to Database we got exeption of Java heap space.So we are trying to split
XML file which is longer in size.

So i have applied following XSLT to split large XML file .

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:t="http://www.safersys.org/namespaces/T0020V1"
version="2.0">
<xsl:output method="xml"/>
<xsl:output method="xml" indent="yes" name="xml"/>
<xsl:variable name="accounts" select="t:T0020/t:IRP_ACCOUNT"/>
<xsl:template match="/">
<xsl:for-each select="$accounts">
<xsl:variable name="pos" select="position()"/>


<xsl:variable name="filename"
select="concat('output1/',position(),'.xml')" />

<xsl:value-of select="$filename" /> <!-- Creating -->
<xsl:result-document href="{$filename}" format="xml">
<T0020>
<xsl:copy-of select="descendant-or-self::t:IRP_ACCOUNT"/>
</T0020>
</xsl:result-document>


</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

So the multiple XML file created like this....

<?xml version="1.0" encoding="UTF-8"?>
<T0020 xmlns:t="http://www.safersys.org/namespaces/T0020V1">
<IRP_ACCOUNT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.safersys.org/namespaces/T0020V1">
<IRP_CARRIER_ID_NUMBER>1243056</IRP_CARRIER_ID_NUMBER>
<IRP_BASE_COUNTRY>US</IRP_BASE_COUNTRY>
<IRP_BASE_STATE>AR</IRP_BASE_STATE>
<IRP_ACCOUNT_NUMBER>61634</IRP_ACCOUNT_NUMBER>
<IRP_ACCOUNT_TYPE>I</IRP_ACCOUNT_TYPE>
<IRP_STATUS_CODE>100</IRP_STATUS_CODE>
<IRP_STATUS_DATE>2004-04-19</IRP_STATUS_DATE>
<IRP_UPDATE_DATE>2009-06-18</IRP_UPDATE_DATE>
<IRP_NAME>
<NAME_TYPE>LG</NAME_TYPE>
<NAME>JOHN R COOPER</NAME>
<IRP_ADDRESS>
<ADDRESS_TYPE>PH</ADDRESS_TYPE>
<STREET_LINE_1>1794 COYOTE RD</STREET_LINE_1>
<STREET_LINE_2/>
<CITY>SALEM</CITY>
<STATE>AR</STATE>
<ZIP_CODE>72576</ZIP_CODE>
<COUNTY>FULTON</COUNTY>
<COLONIA/>
<COUNTRY>US</COUNTRY>
</IRP_ADDRESS>
</IRP_NAME>
</IRP_ACCOUNT>
</T0020>

Here problem is IRP_ACCOUNT is coming with name space and we want xml files to contains more <IRP_ACCOUNT> data not just one as right
now only coming one IRP_ACCOUNT information per one file.

Thanks in Advance for Wonderful help.



Postnext
Ivan PedruzziSubject: Value of File Name is not accessing through XSLT
Author: Ivan Pedruzzi
Date: 06 Jan 2010 11:14 AM

Typical positional grouping...


Ivan Pedruzzi
Stylus Studio Team


Documentpositional-grouping.xsl

Postnext
Nisarg MehtaSubject: Value of File Name is not accessing through XSLT
Author: Nisarg Mehta
Date: 08 Jan 2010 06:54 AM
Thanks a lot for your help.
You have given solution in t.xsl which removes the problem of namespace.
we have following lines in xslt declaration.

<xmlns:t="http://www.safersys.org/namespaces/T0020V1">

and we used following lines to map xml fields to Database .
<xsl:apply-templates select="t:T0020/t:IRP_ACCOUNT" />

Can you please tell me how does it resolve my problem ?
What does prefix t: called in XSLT ?



Postnext
Ivan PedruzziSubject: Value of File Name is not accessing through XSLT
Author: Ivan Pedruzzi
Date: 08 Jan 2010 02:42 PM

See XSLT FAQ at
http://www.dpawson.co.uk/xsl/sect2/N5536.html

Ivan Pedruzzi
Stylus Studio Team

Posttop
Nisarg MehtaSubject: Value of File Name is not accessing through XSLT
Author: Nisarg Mehta
Date: 23 Feb 2010 02:20 AM
Thanks Ivan ,Thanks a lot for your help.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.