XSLT Issue - Donot XML Namespace at Element Level. Please He

Here should go questions about transforming XML with XSLT and FOP.
seeyoo
Posts: 1
Joined: Thu Apr 10, 2014 9:10 pm

XSLT Issue - Donot XML Namespace at Element Level. Please He

Post by seeyoo »

Input XML:
<MT_Superior_invoice xmlns='urn:abc.com:10'
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<Invoice_recs>
<Invoice_header>
<comp_code>8000</comp_code>
<AP_text>8VXHR820120624</AP_text>
<header_text>003000993020120624</header_text>
<document_dt>20131115</document_dt>
<posting_dt>20131115</posting_dt>
<fiscal_year>2013</fiscal_year>
<document_type>DB</document_type>
<Reference_no>8VXHR8</Reference_no>
<vendor_no>318992</vendor_no>
<amount>6042.48</amount>
<invoice_details>
<Line_num>10</Line_num>
<gl_account>633001</gl_account>
<item_text>DWAIN Cochran</item_text>
<cr_dr_ind>DB</cr_dr_ind>
<tax_code>I1</tax_code>
<tax_jurisdiction>WA1030000</tax_jurisdiction>
<cost_center>801404</cost_center>
<amount>680.0</amount>
</invoice_details>
</Invoice_header>
</Invoice_recs>
</MT_Superior_invoice>

Output needed:
<ns0:MT_Superior_invoice xmlns:ns0='urn:abc.com:10'>
<Invoice_recs>
<Invoice_header>
<comp_code>8000</comp_code>
<AP_text>8VXHR820120624</AP_text>
<header_text>003000993020120624</header_text>
<document_dt>20131115</document_dt>
<posting_dt>20131115</posting_dt>
<fiscal_year>2013</fiscal_year>
<document_type>DB</document_type>
<Reference_no>8VXHR8</Reference_no>
<vendor_no>318992</vendor_no>
<amount>6042.48</amount>
<invoice_details>
<Line_num>10</Line_num>
<gl_account>633001</gl_account>
<item_text>DWAIN Cochran</item_text>
<cr_dr_ind>DB</cr_dr_ind>
<tax_code>I1</tax_code>
<tax_jurisdiction>WA1030000</tax_jurisdiction>
<cost_center>801404</cost_center>
<amount>680.0</amount>
</invoice_details>
</Invoice_header>
</Invoice_recs>
</ns0:MT_Superior_invoice>


XSLT Used:
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="urn:abc.com:10">
<xsl:template match="/">
<ns0:MT_Superior_invoice>

<xsl:copy-of select="ns0:MT_Superior_invoice/ns0:Invoice_recs"/>

</ns0:MT_Superior_invoice>
</xsl:template>
</xsl:stylesheet>

Issue with Above XSLT is its copying xmlns for every element. But I want only at root as shown in Output. Removing ns0 on Copy-of Select not picking any element at all. What change I should do to get the Output shown above?. Any help in the code would be much appreciated as I'm stuck. Thank you.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: XSLT Issue - Donot XML Namespace at Element Level. Pleas

Post by sorin_ristache »

Hello,

I recommend first going through the examples of one or two XSLT tutorials to learn about namespace processing in XSLT. Two XSLT tutorials with clear and helpful examples of XSLT code are this one and this one.

If you continue to be stuck after that I suggest posting the question to this XSL mailing list where many knowledgeable XSLT experts are available to help you.


Regards,
Sorin
Post Reply