tags:

views:

79

answers:

1

We have XML file like below...

<?xml version='1.0'?>
<T0020 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd"
    xmlns="http://www.safersys.org/namespaces/T0020V1"&gt;

    <IRP_ACCOUNT>
        <IRP_CARRIER_ID_NUMBER>1213561</IRP_CARRIER_ID_NUMBER>
        <IRP_BASE_COUNTRY>US</IRP_BASE_COUNTRY>
        <IRP_BASE_STATE>AL</IRP_BASE_STATE>
        <IRP_ACCOUNT_NUMBER>15485</IRP_ACCOUNT_NUMBER>
        <IRP_ACCOUNT_TYPE>I</IRP_ACCOUNT_TYPE>
        <IRP_STATUS_CODE>0</IRP_STATUS_CODE>
        <IRP_STATUS_DATE>2004-02-23</IRP_STATUS_DATE>
        <IRP_UPDATE_DATE>2007-03-09</IRP_UPDATE_DATE>
        <IRP_NAME>
            <NAME_TYPE>LG</NAME_TYPE>
            <NAME>WILLIAMS TODD</NAME>
            <IRP_ADDRESS>
                <ADDRESS_TYPE>MA</ADDRESS_TYPE>
                <STREET_LINE_1>P O BOX 1210</STREET_LINE_1>
                <STREET_LINE_2/>
                <CITY>MARION</CITY>
                <STATE>AL</STATE>
                <ZIP_CODE>36756</ZIP_CODE>
                <COUNTY/>
                <COLONIA/>
                <COUNTRY>US</COUNTRY>
            </IRP_ADDRESS>
        </IRP_NAME>
    </IRP_ACCOUNT>
</T0020>

In order to Insert this XML data to database ,we have used two XSLT. First XSLT will remove name space from XML file and convert this XML to some intermediate XML(say Process.xml) file on some temporary location.

then we were taking that intermediate xml(without namespace lines) and applied another XSL to map xml field to Database.

Then we have found solution and we have used only one XSLT which does bode [1] Remove namespace and [2] Mapping XML field to Database to insert data.

Our final style sheet contain following lines

xmlns:t="http://www.safersys.org/namespaces/T0020V1"&gt;

and we used following to map field to Database

  <xsl:template match="/">
       <xsl:element name="T0020">
           <xsl:apply-templates select="t:T0020/t:IRP_ACCOUNT" /> 
      </xsl:element>
 </xsl:template>

how did our problem solved with this approach ?Any consequences with using this ? I have searched about this but not getting the functionality.

Thanks in Advance..

+1  A: 

I don't see any problems with your approach.

XSLT mandates a fully qualified name for a correct matching, so using a prefixed namespace in your XSLT is the right solution; this is why you solved your problem.

Laurent Etiemble
ok i have understand the approach of prefixed name space .Thanks for your help.
Nisarg Mehta