on 10-23-2008 12:06 PM
Hello all
I am trying to get rid of namespaces in the XML document. The document XI is producing looks liek this
<com:ID xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/" schemeID="N/A">0018000562</com:ID>
<com:IssueDate xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/">2008-10-02</com:IssueDate>
<com:TypeCode xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/">PIE</com:TypeCode>
<main:InvoiceCurrencyCode xmlns:main="http://rep.oio.dk/ubl/xml/schemas/0p71/maindoc/">USD</main:InvoiceCurrencyCode>
<com:BuyersReferenceID xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/" schemeID="EAN">5790001330217</com:BuyersReferenceID> <com:ReferencedOrder xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/">
<com:BuyerParty xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/">
<com:DestinationParty xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/">
<com:SellerParty xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/">
<com:TaxTotal xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/">
<com:LegalTotals xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/">
<com:InvoiceLine xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/">
And I would like the document to look like this
<com:ID schemeID="N/A">0018000562</com:ID>
<com:IssueDate>2008-10-02</com:IssueDate>
<com:TypeCode>PIE</com:TypeCode>
<main:InvoiceCurrencyCode>USD</main:InvoiceCurrencyCode>
<com:BuyersReferenceID schemeID="EAN">5790001330217</com:BuyersReferenceID>
<com:ReferencedOrder>
<com:BuyerParty>
<com:DestinationParty>
<com:SellerParty>
<com:TaxTotal>
<com:LegalTotals>
<com:InvoiceLine>
Simply put , XI is including a namespcae for every node <com:ID xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/" schemeID="N/A">0018000562</com:ID>
But i would liek just the node <com:ID schemeID="N/A">0018000562</com:ID>
How can we achieve this , XSLT code plz , or could we do this with mapping , adaopter modules etc ..
Thanks a lot
Sudheer
go to
and search....
otherwise if u r using any adapter and specifying documentnamespce...just leave that as blank....
Regards
Rams
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your responses , I am using this code to remove namespaces
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="*">
<!-- remove element prefix (if any) -->
<xsl:element name="{local-name()}">
<!-- process attributes -->
<xsl:for-each select="@*">
<!-- remove attribute prefix (if any) -->
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
This code is completely removing all the namespaces from the document. but i want only namespaces for certain nodes to be removed. how can tweak this code to remove namespaces for certain nodes .
thanks a lot
Sudheer
Hi Sudhir
<xsl:element name="{local-name()}">
This removes the local name i.e value for xmlns for all tags
<xsl:element name="local-name()" namespace="mynamespace.uri">
This you can use to change the local name with the value you need for name space. Use these to resolve as per your structure.
Thanks
Gaurav
Hi Use
For
<com:ID xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/" schemeID="N/A">0018000562</com:ID>
into
<com:ID schemeID="N/A">0018000562</com:ID>
XSL can do like
<com:ID schemeID="N/A"><xsl:value-of select="//com:ID"/></com:ID>
This will not bring the name space.
in case of hierarchy use
<com:ID schemeID="N/A"><xsl:value-of select="//level1/level2/com:ID"/></com:ID>
where level1 , level 2 are nesting of source XML
Thanks
Gaurav
Edited by: Gaurav Bhargava on Oct 25, 2008 6:49 AM
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Guys , I have another strange problem here ,
If I am manually constructing the file with XSLT , then how can I handle dynamic elements in the file , Fr example say there were 3 InvoiceLine nodes instead of 2 , how can i handle this situation.
Cheers
Sudheer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Igor
Looks liek this could be an answer for my problem , I am doing all this to get rid of ns0: prefix which XI adds to its messages . I need to replace this 'ns0' with 'com'
My message after mapping is
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Invoice xmlns:main="http://rep.oio.dk/ubl/xml/schemas/0p71/maindoc/" xmlns:com="http://rep.oio.dk/ubl/xml/schemas/0p71/common/" xmlns:ns0="http://rep.oio.dk/ubl/xml/schemas/0p71/pie/" xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance">
+ <ns0:ID schemeID="N/A">0018000562</ns0:ID>+
+ <ns0:IssueDate>2008-10-02</ns0:IssueDate>+
+ <ns0:TypeCode>PIE</ns0:TypeCode>+
+ <ns0:InvoiceCurrencyCode>USD</ns0:InvoiceCurrencyCode>+
+ <ns0:BuyersReferenceID schemeID="EAN">5790001330217</ns0:BuyersReferenceID>+
+ <ns0:ReferencedOrder>+
+ <ns0:BuyersOrderID>sdfsdfsd</ns0:BuyersOrderID>+
+ <ns0:IssueDate>2008-09-30</ns0:IssueDate>+
+ </ns0:ReferencedOrder>+
+ <ns0:BuyerParty>+
+ <ns0:ID schemeID="EAN">5790001330217</ns0:ID>+
+ <ns0:PartyName>+
+ <ns0:Name>Fred the sold to party</ns0:Name>+
+ </ns0:PartyName>+
+ <ns0:BuyerContact>+
+ <ns0:ID>contact person from ARLA</ns0:ID>+
+ <ns0:Name>contact person from ARLA</ns0:Name>+
+ </ns0:BuyerContact>+
+ </ns0:BuyerParty>+
+ <ns0:DestinationParty>+
+ <ns0:ID schemeID="EAN">5790001330217</ns0:ID>+
+ <ns0:PartyName>+
+ <ns0:Name>Fred the sold to party</ns0:Name>+
+ </ns0:PartyName>+
+ <ns0:Contact>+
+ <ns0:ID>ARLA contact person</ns0:ID>+
+ <ns0:Name>ARLA contact person</ns0:Name>+
+ </ns0:Contact>+
+ <ns0:Address>+
+ <ns0:ID>Levering</ns0:ID>+
+ <ns0:Street>14 Easy street</ns0:Street>+
+ <ns0:CityName>north Andover</ns0:CityName>+
+ <ns0:PostalZone>0184500</ns0:PostalZone>+
+ <ns0:Country>+
+ <ns0:Code>NL</ns0:Code>+
+ </ns0:Country>+
+ </ns0:Address>+
+ </ns0:DestinationParty>+
+ <ns0:SellerParty>+
+ <ns0:ID schemeID="EAN">Vendor's EAN number not implemented</ns0:ID>+
+ <ns0:PartyName>+
+ <ns0:Name>APV SYSTEMS US COMMERCIAL</ns0:Name>+
+ </ns0:PartyName>+
+ <ns0:PartyTaxScheme>+
+ <ns0:CompanyTaxID schemeID="CVR">24730018</ns0:CompanyTaxID>+
+ </ns0:PartyTaxScheme>+
+ </ns0:SellerParty>+
+ <ns0:TaxTotal>+
+ <ns0:TaxTypeCode>VAT</ns0:TaxTypeCode>+
+ <ns0:TaxAmounts>+
+ <ns0:TaxableAmount currencyID="USD">101.53</ns0:TaxableAmount>+
+ <ns0:TaxAmount currencyID="DKK">60.00</ns0:TaxAmount>+
+ </ns0:TaxAmounts>+
+ <ns0:CategoryTotal>+
+ <ns0:RateCategoryCodeID>VAT</ns0:RateCategoryCodeID>+
+ <ns0:RatePercentNumeric>25</ns0:RatePercentNumeric>+
+ <ns0:TaxAmounts>+
+ <ns0:TaxableAmount currencyID="USD">101.53</ns0:TaxableAmount>+
+ <ns0:TaxAmount currencyID="DKK">60.00</ns0:TaxAmount>+
+ </ns0:TaxAmounts>+
+ </ns0:CategoryTotal>+
+ </ns0:TaxTotal>+
+ <ns0:LegalTotals>+
+ <ns0:LineExtensionTotalAmount currencyID="USD">101.53</ns0:LineExtensionTotalAmount>+
+ <ns0:ToBePaidTotalAmount currencyID="USD">101.53</ns0:ToBePaidTotalAmount>+
+ </ns0:LegalTotals>+
+ <ns0:InvoiceLine>+
+ <ns0:ID>000010</ns0:ID>+
+ <ns0:InvoicedQuantity unitCode="ST" unitCodeListAgencyID="n/a">1.000</ns0:InvoicedQuantity>+
+ <ns0:LineExtensionAmount currencyID="DKK">1000.00</ns0:LineExtensionAmount>+
+ <ns0:Item>+
+ <ns0:ID schemeID="n/a">DS1234</ns0:ID>+
+ <ns0:Description>Test material for STO</ns0:Description>+
+ <ns0:BasePrice>+
+ <ns0:PriceAmount currencyID="DKK">1000.00</ns0:PriceAmount>+
+ </ns0:BasePrice>+
+ </ns0:Item>+
+ <ns0:BasePrice>+
+ <ns0:PriceAmount currencyID="DKK">1000.00</ns0:PriceAmount>+
+ <ns0:BaseQuantity unitCode="ST" unitCodeListAgencyID="n/a">1.000</ns0:BaseQuantity>+
+ </ns0:BasePrice>+
+ </ns0:InvoiceLine>+
</ns0:Invoice>
I want to replace ns0: with com:
Is there a simpler way to achieve this other than cosntructing the whole file with XSLT .
Thanks a lot
Sudheer
another option wud be this approach - http://www.tei-c.org/wiki/index.php/Remove-Namespaces.xsl
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Open the message type of ur source structure. There make the option "XML Namespace" as blank and try again.
Regards,
Prateek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.