XSLT Issue - Donot XML Namespace at Element Level. Please He
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 1
- Joined: Thu Apr 10, 2014 9:10 pm
XSLT Issue - Donot XML Namespace at Element Level. Please He
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.
<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.
-
- 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
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
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service