开发者

Ignore name space with t: prefix

开发者 https://www.devze.com 2022-12-16 06:39 出处:网络
We have XML file like below... <?xml version=\'1.0\'?> <T0020 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"

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">

    <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">

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 fu开发者_运维知识库nctionality.

Thanks in Advance..


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消