Inclusion of unused namespace declarations in marshalled XML

Hello.
I have noticed that by default any XML marshaled from an object contains namespace declarations related to every package specified when instantiating the JAXBContext even though they are not used in the instance being marshalled.
Is there any way to avoid this during the marshalling as opposed to via some sort of post processing (e.g. XSLT transform).
Example source below:
package test;
import javax.xml.bind.*;
import java.io.*;
import test.sample1.*;
import test.sample2.*;
public class Converter {
     public static void main(String[] args) {
          try {
               String sample1 = "<Message1 xmlns=\"http://www.example.org/sample1\">" +
                                         "<tns:Field xmlns:tns=\"http://www.someother.org\">value</tns:Field>" +
                                    "</Message1>";
               String sample2 = "<Message2 xmlns=\"http://www.example.org/sample2\">" +
                                        "<Field1>value1</Field1>" +
                                        "<Field2>value2</Field2>" +
                                    "</Message2>";
               JAXBContext ctx = JAXBContext.newInstance("test.sample1:test.sample2");
               Unmarshaller um = ctx.createUnmarshaller();
               Marshaller m = ctx.createMarshaller();
               StringWriter sw1 = new StringWriter();                
               Message1 msg = (Message1)um.unmarshal(new StringReader(sample1));
               m.marshal(msg, sw1);               
               System.out.println("Marshalled sample1: \n"+sw1.toString());
               StringWriter sw2 = new StringWriter();                
               Message2 msg2 = (Message2)um.unmarshal(new StringReader(sample2));
               m.marshal(msg2, sw2);               
               System.out.println("Marshalled sample2: \n"+sw2.toString());
          } catch (JAXBException e) {
               e.printStackTrace();
}Produces output:-
Marshalled sample1:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Message1 xmlns:ns2="http://www.example.org/sample2" xmlns="http://www.example.org/sample1"><tns:Field xmlns:tns="http://www.someother.org">value</tns:Field></Message1>
Marshalled sample2:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns2:Message2 xmlns:ns2="http://www.example.org/sample2" xmlns="http://www.example.org/sample1"><ns2:Field1>value1</ns2:Field1><ns2:Field2>value2</ns2:Field2></ns2:Message2>

Thanks for the quick response. I really appreciate it.
Yes, as you say, there is no real problem as such but part of my app lets the user see the RAW message XMLs and this could confuse them and would be tidier to remove but I can also see why it is easier from the Marshaller perspective not to have to back track to remove unused declarations.
Also, I'm a little concerned about the increased size of the XML produced. One of my webservices does handle quite a few different types and our Oracle namespace URLs are all pretty long!
Like I say, I can see a way to get rid of them after the fact but wondered if there was a more elegant/performant way.

Similar Messages

  • Namespace declaration using DOM

    Hi,
    I am using DOM to create an XML document. How do I declare namespace?
    I want to know which API is used to create namespace declaration in an XML document.
    I want my final XML document to be
    <RootElement xmlns:c="http://pradeep.somesite.com">
    <name>pradeep</name>
    <RootElement>
    My problem is how to put the xml ns declaraton in RootElement.
    Some one plz help;
    thanks in adv.

    xmlns is like any other attribute.
    Try something like:
    NamedNodeMap attributes = rootElement.getAttributes();
    Attr namespace = myDoc.createAttribute("xmlns");
    namespace.setValue("........");
    attributes.setNamedItem(namespace);

  • Avoid repeating namespace declaration in xml output

    Hi all,
    I'm trying an IDoc -> XML File (specifically UBL-format) scenario, and it is working fine. But the resulting XML contains repeating namespace declarations for each element, instead of a "common" declaration at the root element.
    How can I avoid this, so the message contains the namespace declarations in root node, and only uses the namespace prefix for each element?
    The target format, external definition, is an XSD with several import statements, and all external references have been set up, meaning all referenced XSD's are imported too, and have the "Source"-field set according to the import statement.
    Sample result file (top of file only):
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Invoice xmlns:ns0="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
    <ns2:UBLVersionID xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">2.0</ns2:UBLVersionID>
    <ns2:CustomizationID xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">urn:www.cenbii.eu:transaction:BiiCoreTrdm001:ver1.0:extentionId</ns2:CustomizationID>
    <ns2:ProfileID xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">urn:www.cenbii.eu:profile:bii05:ver1.0</ns2:ProfileID>
    <ns2:ID xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">9010045446</ns2:ID>
    <ns2:IssueDate xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">2011-04-19</ns2:IssueDate>
    <ns2:InvoiceTypeCode...
    PI version 7.11.
    Thanks for all help.
    Br,
    Kenneth

    Hi Mon,
    You can use below xslt 1.0 mappings.
    The first one will copy all namespaces (declared) to a newly created root element.
    The seconde one will delete the 'old' root element.
    => The result will look like an xml where the namespacesare moved to the root element.
    First xslt:
    <?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" encoding="UTF-8"/>
    <xsl:template match="/">
    <Invoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ns1="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:ns3="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ns4="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
    <xsl:copy-of select="." />
    </Invoice>
    </xsl:template>
    </xsl:stylesheet>
    Second xslt:
    <?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" encoding="UTF-8"/>
    <xsl:template match="@* | node()">
      <xsl:copy>
        <xsl:apply-templates select="@* | node()"/>
      </xsl:copy>
    </xsl:template>
    <xsl:template match="Invoice" >
      <xsl:apply-templates/>
    </xsl:template>
    </xsl:stylesheet>
    Kind regards,
    Lode

  • Add dynamic namespace declaration into xml root element

    Hello all,
    i've have two scenarios (mail to mail and file to file) with the same issue : no namespace in my XML file and i have to create one 'dynamically' from XML values.
    Example :
    <root>
    <name>test</name>
    <email>test</email>
    <schema>schemaID</schema>
    </root>
    Now I want to add infos into the root element for namespace declaration and so on, without expansion of the xsd. I've must use the value from the field schemaID.
    Example:
    <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns: namespace="http://test.de/schemaID">
    <name>test</name>
    <email>test</email>
    </root>
    I've already done it before through XSLT but it wasn't dynamic !! I don't know how to do it in XSL and i am not a java expert.
    Someone got an idea ?
    Thanks,
    Jean-Philippe.

    Hi,
      If you want to add name space at mapping level two options
    1)Using XSLT Mapping ,its very easy,google it to get sample XSLT code ,it will solve your problem.
    2)Using java mapping,in java mapping use regular expression code ,using regex(Regulkar expresion)we can add any content in message at any level.
    Regards,
    Raj

  • Add namespace declaration into xml root element

    Hello experts,
    I have the following problem:
    I generate a xml message with the following structure (example):
    How can I realise this requirement?
    Thanks and best regards!
    Christopher Kühn

    Hi Christopher,
    Call the below code as a javamappinf in the operation mapping... So now your operation mapping will have two mappings one to convert source to target XML and second this java mapping which will add namespace to your target xml
    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.Reader;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import  com.sap.aii.mapping.api.DynamicConfiguration;
    import com.sap.aii.mapping.api.DynamicConfigurationKey;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    import com.sap.aii.mapping.api.InputHeader;
    public class JavaMapping extends AbstractTransformation {
         public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException {
         getTrace().addInfo("JAVA Mapping Called");
         //Input payload is obtained by using arg0.getInputPayload().getInputStream()
         String inData = convertStreamToString(arg0.getInputPayload().getInputStream());
         String outData = inData.replaceFirst("<root>", "<root xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespace=\"http://test.de/test.xsd\">");
         try
         //8. The JAVA mapping output payload is returned using the TransformationOutput class
         // arg1.getOutputPayload().getOutputStream()
              arg1.getOutputPayload().getOutputStream().write(outData.getBytes("UTF-8"));
         catch(Exception exception1) { }
         public String convertStreamToString(InputStream in){
         StringBuffer sb = new StringBuffer();
         try
         InputStreamReader isr = new InputStreamReader(in);
         Reader reader =
         new BufferedReader(isr);
         int ch;
         while((ch = in.read()) > -1) {
              sb.append((char)ch);}
              reader.close();
         catch(Exception exception) { }
         return sb.toString();
    check stefans blog on the jar files that you need to make this mapping /people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio
    Regards
    Suraj
    Regards
    Suraj

  • Namespace declarations

    I have an XML file that declares some namespaces in its root
    element, like this:
    <config-ui xmlns='ocfgui.dtd'
    xmlns:cfg='ocfg.dtd'>
    |
    (innards deleted)
    |
    </config-ui>
    When I run this though the Oracle XMLParser v2.0.0 with
    validation on, I get "Illegal attribute name" errors on the
    namespace declarations. It's true that they're not in my DTD,
    but I didn't think the DTD had to specify xmlns attributes on
    every element that could use them. I thought that as reserved
    attribute names, they were implicitly valid on any element. Can
    someone set me straight on this?
    null

    David, see http://www.jclark.com/xml/xmlns.htm which states that
    the XML Namespaces Recommendation doesn't define additional
    validity distinct from XML 1.0 validity, so the behavior of our
    parsers is correct. There are two ways you can minimize size of
    your document. Either namespace scoping/defaulting, or attribute
    defaulting. See also section 5 of the following:
    http://www.w3.org/TR/1999/REC-xml-names-19990114/
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    David Kulik (guest) wrote:
    : I have an XML file that declares some namespaces in its root
    : element, like this:
    : <config-ui xmlns='ocfgui.dtd'
    : xmlns:cfg='ocfg.dtd'>
    : |
    : (innards deleted)
    : |
    : </config-ui>
    : When I run this though the Oracle XMLParser v2.0.0 with
    : validation on, I get "Illegal attribute name" errors on the
    : namespace declarations. It's true that they're not in my DTD,
    : but I didn't think the DTD had to specify xmlns attributes on
    : every element that could use them. I thought that as reserved
    : attribute names, they were implicitly valid on any element.
    Can
    : someone set me straight on this?
    null

  • RFC Call: Missing namespace declaration

    Dear experts,
    I have a file to RFC scenario. I imported the RFC and create files exactly according to the RFC structure, so I don't use a mapping. When I create a file, it provides the following error in the adapter log:
    <i>Exception caught by adapter framework: error while processing message to remote system:com.sap.aii.af.rfc.core.client.RfcClientException: could not get functionname from XML requst: com.sap.aii.af.rfc.RfcAdapterException: failed to read funtionname from XML document: missing namespace declaration(2)</i>
    What do I need to do to fix this.
    Thanks in advance!

    This is the whole message:
    I created my own interface and mapped it to the RFC:
    This is the message. Now it successfully pass XI and the adapter sais it is delivered.
    BUT nothing is seen in the target system... how is that possible???
    <?xml version="1.0" ?>
    <ns:MT_TO_CREATE xmlns:ns="urn://cchbc/w2/xi/mes/warehousetransfer">
    <LGNUM></LGNUM>
    <TIMEST>20071207094550.0000000</TIMEST>
    <WERKS>4510</WERKS>
    <ZLAST>0</ZLAST>
    <ZSCID>SCANPRD4</ZSCID>
    <I_LTAP>
    <item>
    <EAN11>5449000003096</EAN11>
    <LETYP>E2</LETYP>
    <VSOLM>48.000</VSOLM>
    <LENUM>00345101239500010930</LENUM>
    <VFDAT>2008-12-11T00:00:00</VFDAT>
    <WDATU>2007-12-07</WDATU>
    <ZLINE>830</ZLINE>
    <ZTIME>09:43:32</ZTIME>
    <BRGEW/>
    </item><item>
    <EAN11>2229000058744</EAN11>
    <LETYP>E2</LETYP>
    <VSOLM>48</VSOLM>
    <LENUM>00000000003000002961</LENUM>
    <VFDAT>2008-12-11T00:00:00</VFDAT>
    <WDATU>2007-12-07</WDATU>
    <ZLINE>830</ZLINE>
    <ZTIME>09:44:01</ZTIME>
    <BRGEW/></item><item>
    <EAN11>2229000058744</EAN11>
    <LETYP>E2</LETYP>
    <VSOLM>48.000</VSOLM>
    <LENUM>00000000003000002978</LENUM>
    <VFDAT>2008-12-11T00:00:00</VFDAT>
    <WDATU>2007-12-07</WDATU>
    <ZLINE>830</ZLINE>
    <ZTIME>09:44:32</ZTIME>
    <BRGEW/></item></I_LTAP></ns:MT_TO_CREATE>
    And the output is:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns1:ZWM_TO_CREATE xmlns:ns1="urn:sap-com:document:sap:rfc:functions">
      <LGNUM />
      <TIMEST>20071207094550.0000000</TIMEST>
      <WERKS>4510</WERKS>
      <ZLAST>0</ZLAST>
      <ZSCID>SCANPRD4</ZSCID>
    - <I_LTAP>
    - <item>
      <EAN11>5449000003096</EAN11>
      <LETYP>E2</LETYP>
      <VSOLM>48.000</VSOLM>
      <LENUM>00345101239500010930</LENUM>
      <VFDAT>2008-12-11T00:00:00</VFDAT>
      <WDATU>2007-12-07</WDATU>
      <ZLINE>830</ZLINE>
      <ZTIME>09:43:32</ZTIME>
      <BRGEW />
      </item>
    - <item>
      <EAN11>2229000058744</EAN11>
      <LETYP>E2</LETYP>
      <VSOLM>48</VSOLM>
      <LENUM>00000000003000002961</LENUM>
      <VFDAT>2008-12-11T00:00:00</VFDAT>
      <WDATU>2007-12-07</WDATU>
      <ZLINE>830</ZLINE>
      <ZTIME>09:44:01</ZTIME>
      <BRGEW />
      </item>
    - <item>
      <EAN11>2229000058744</EAN11>
      <LETYP>E2</LETYP>
      <VSOLM>48.000</VSOLM>
      <LENUM>00000000003000002978</LENUM>
      <VFDAT>2008-12-11T00:00:00</VFDAT>
      <WDATU>2007-12-07</WDATU>
      <ZLINE>830</ZLINE>
      <ZTIME>09:44:32</ZTIME>
      <BRGEW />
      </item>
      </I_LTAP>
      </ns1:ZWM_TO_CREATE>

  • How to remove SOAP namespaces declarations in body content?

    Hi!
    I'm calling a WS with WS-Security without problems but when I extract the content the SOAP message's Body(the "business" part), the namespace declarations of the SOAP part (envelope, security, etc.) are present in the root element. However, any of this namespaces is referenced in the message that I extract.
    I'm extracting the message inside the body like this
    XmlObject[] aXml = xml.selectPath(##THE QUERY##);
    return XmlObject.Factory.parse(aXml[0].xmlText(_opts));
    Is there a way of getting rid of these declarations?
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    I've tried changing the XmlOptions (setSaveAggresiveNamespaces, setLoadSubstituteNamespaces, etc.) without success.
    Thanks in advance!

    just use $body/* and you will have what u wanted.

  • Namespace declaration inconsistencies

    It has occurred to me that there is an inconsistency in the BPEL input message depending on where it is called from... If I test the BPEL process from the BPEL console using the test-form, the namespace of the input message is included. However, when the same BPEL process is called through another BPEL process (partner link), the namespace declaration is omitted.
    This makes testing harder, since my XPath expressions will then either fail when I test from the BPEL Console, or when the process is invoked from another bpel.
    The best way to fix it (I think) is to force the calling bpel process to include the namespace declaration when invoking the partner link. Is there a way to accomplish this?
    Cheers,
    Bastiaan

    Bastian
    I have come across the same problem.
    The BPEL Console is producing an XML message that is not consistent with the defined schema.
    Has anyone else seen any other comments relating to this area - has it been raised as a bug?
    I have included my message structures below.
    BPEL Console Messsage - the namespaces in bold are the ones that are incorrect
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body xmlns:ns1="http://itv.com/parispublish">
    <ns1:ParisPublishProcessRequest xmlns:ns2="http://itv.com/schemas/message/paris">
    <ns2:ProgrammeAdviseRq>
    <ns2:HeaderRq xmlns:ns3="http://itv.com/schemas/header/paris">
    <ns3:RqUID>ABC</ns3:RqUID>
    <ns3:Action>Add</ns3:Action>
    </ns2:HeaderRq>
    <ns2:Programme xmlns:ns4="http://itv.com/schemas/productcatalogue/paris">
    <ns4:ProgrammeId>1234</ns4:ProgrammeId>
    </ns2:Programme>
    </ns2:ProgrammeAdviseRq>
    </ns1:ParisPublishProcessRequest>
    </soap:Body>
    </soap:Envelope>
    Partnerlink message - which is correct.
    <inputVariable>
         <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
              <soap:Envelope xmlns="http://itv.com/parispublish" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                   <soap:Header/>
                   <soap:Body>
                        <ProgrammeAdviseRq xsi:schemaLocation="http://itv.com/schemas/message/paris ../Message.xsd" xmlns="http://itv.com/schemas/message/paris" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                             <HeaderRq xmlns="http://itv.com/schemas/header/paris">
                                  <RqUID>564</RqUID>
                                  <Action>Add</Action>
                             </HeaderRq>
                             <Programme xsi:schemaLocation="http://itv.com/schemas/productcatalogue/paris ../productcatalogue.xsd" xmlns="http://itv.com/schemas/productcatalogue/paris">
                                  <ProgrammeId>G/0002</ProgrammeId>
                                                      </Programme>
                        </ProgrammeAdviseRq>
                   </soap:Body>
              </soap:Envelope>
         </part>
    </inputVariable>

  • Retrieve namespace  declarations from unmarshalled object

    Hi,
         I hope this is a beginner's question:
    Still working on a web service, that uses an EJB for implementation. I'm using types/classes that were derived automatically from a WSDL (top-down/outside-in/what have you), or rather the corresponding schemata. I'm trying to retrieve namespace declarations from the unmarshalled object/element, but  they are not contained in the "otherAttributes" [Map<QName, String>] member field of the respective object. However, I can retrieve any other attribute, qualified and non qualified, as long as the namespace isn't that of xmlns (http://www.w3.org/2000/xmlns/). For example:
    Client:
                MyElement my_element = new MyElement();
                Map<QName, String> atts = my_element.getOtherAttributes();
                QName ns_att = new QName("http://www.w3.org/2000/xmlns/", "a");
                atts.put(ns_att, "http://www.example.com/");
                QName test_att = new QName("test-att");
                atts.put(test_att, "http://www.example2.com");
    Service:
                MyElement my_element = parent.getMyElement(); // ...
                Map<QName, String> atts = my_element.getOtherAttributes();
                for (QName qn :  atts.keySet()) {
                    System.out.println("qn: ["+qn+"] value["+atts.get(qn)+"]");
    This would print:
    qn: [test-att] value[http://www.example2.com]
    What am I missing? How do I get the namespace declaration? Thanks for your help in advance.
    Cheers,
    Felix

    I'll try to explain in a better way ...
    I have a server with 2 different client and each client communicate to the server with a different interface.
    My needs are to recognize from the server, the type of the client that are operating, and to do this I was thinking to recognize the interface used from the client to interact with the server
    An other option is that, from the client, after retrieving the server and it's cast, a can call a method to pass to the server object, the type of the interface actually used.
    But I think this makes a bit of nonsense because When I receive the marshalled object in my opinion doesn't make sense that i have to say the object it's type (the interface used).
    the object is already alive and I think it has to know the interface used to refer it even if is on another VM
    The cast operation doesn't store nothing into the current object instance?
    local code example (I don't know if with JRMI the situation is different because the different JVM)
    Map foo = new HashTable();
    I need a method like
    foo.curretUsedInterface() ... that return "Map"
    instead of
    foo.getClass().getName() that return "HashMap"
    It's possible to obtain this information or I have to try another idea to make the server distinguish the client type?
    thank you very much for your comprehension

  • Unnecessary  Namespace declarations

    Hi,
    When mapping (graphic) to an externally defined XML schema where some elements belong to different namespaces I get namespace declarations on each element in the resulting XML instance even though they refer to the same ns name. The problem is that the XML document, even though valid, is very verbose. Is there a way to get all ns declarations in the root element instead without using XSLT?
    Example output
    <?xml version="1.0" encoding="utf-8" ?>
    <ns1:RootElement xmlns:ns1="http://foo.com">
    <ns2:Element1 xmlns:ns2="http://junk.com" />
    <ns2:Element2 xmlns:ns2="http://junk.com" />
    <ns2:Element3 xmlns:ns2="http://junk.com" />
    </ns1:RootElement>
    I would like to get something like this instead:
    <?xml version="1.0" encoding="utf-8" ?>
    <ns1:RootElement xmlns:ns1="http://foo.com" xmlns:ns2="http://junk.com">
    <ns2:Element1 />
    <ns2:Element2 />
    <ns2:Element3 />
    </ns1:RootElement>
    Kind regards Johan

    Hi,
    I was probably not clear enough in my question.
    My Scenario is CRM -> Xi -> External system.
    The inbound interface to the external system is a predefined XML Schema where not all components/elements belong to the same namespace.
    When executing a mapping, created with the graphical mapping tool in Xi, the resulting XML document/Instance is valid but very verbose since XI put namespace declarations in every element over and over again instead of just putting them once in the root element.
    I don't think this has anything to do with the XSD, but rather with the mapping program.
    The result is that the receiving system takes a performance hit. I would like to find a way to force XI to just declare the same ns once in the root element instead of over and over again?
    kind regards Johan

  • Duplicate namespace declarations when writing a file with JCA file adapter

    I am using JCA File adapter to write a an XML file. The composite contains a mediator which received and transforms an XML to desired format and then calls a JCA file adapter to write the file.
    The problem that I am having is that the written file has declaration of namespaces repeated with repeating elements instead of a single declaration at root. For ex.
    instead of
    <ns0:Root xmlns:ns0="namespace0"  xmlns:ns1="namespace1" xmlns:ns2="namespace2">
    <ns0:RepeatingChild>
    <ns1:Element1>value1</ns1:Element1>
    <ns2:Element2>value2</ns2:Element2>
    </ns0:RepeatingChild>
    <ns0:RepeatingChild>
    <ns1:Element1>value3</ns1:Element1>
    <ns2:Element2>value4</ns2:Element2>
    </ns0:RepeatingChild>
    </ns0:Root>What I see in the file is:
    <ns0:Root xmlns:ns0="namespace0"  xmlns:ns1="namespace1" xmlns:ns2="namespace2">
    <ns0:RepeatingChild>
    <ns1:Element1 xmlns:ns1="namespace1" xmlns:"namespace1">value1</ns1:Element1>
    <ns2:Element2 xmlns:ns2="namespace2" xmlns:"namespace2">>value2</ns2:Element2>
    </ns0:RepeatingChild>
    <ns0:RepeatingChild>
    <ns1:Element1 xmlns:ns1="namespace1" xmlns:"namespace1">>value3</ns1:Element1>
    <ns2:Element2 xmlns:ns2="namespace2" xmlns:"namespace2">>value4</ns2:Element2>
    </ns0:RepeatingChild>
    </ns0:Root>So basically all the elements which are in different namespace than root element have a namespace declaration repeated even though the namespace identifier is declared at the root elment level.
    Although, the XML is still valid, but this is unnecessarily increasing the filesizes 3-4 times. Is there a way I can write the XML file without duplicate declarations of namespaces?
    I am using SOA Suite 11.1.1.4
    The file adapter has the schema set as above XML.
    I tried the transformation in mediator using XSL and also tried using assign [source(input to mediator) and target(output of mediator, input of file adapter) XMLs are exactly same].
    but no success.

    I used automapper of JDeveloper to generate the schema. The source and target schema are exactly same.
    I was trying to figure it out and I observed that if the namespaces in question are listed in exclude-result-prefixes list in xsl, then while testing the XSL in jDeveloper duplicate namespaces occur in the target and if I remove the namespace identifiers from the exclude-result-prefixes list then in jDeveloper testing the target correctly has only a single namespace declaration at the root node.
    But, when I deployed the same to server and tested there, again the same problem.

  • Namespaces missing in destination xml

    Hello,
    I have BPEL composite that will take a input xml. This xml has couple of namespaces.
    I used Assign activity to copy the input TO output (input and output are of SAME type. Meaning using same XSD)
    As I run the process and view the generated output XML, it gives me error stating that namespace is used in xml but not declared. following is the sample output xml.
    <CreateService>
    <Service:Data>
    <Service:CreateService>
    <Service:Service>
    </Service:ServiceOrder>
    </Service:CreateService>
    </Service:Data>
    </CreateService>
    u see Service is namespace used but not declared.
    how to add those declaration at the top of XML ? Transform will add those declarations ? How ?

    <CreateService xmlns:Service="and your namespace over here">
    <Service:Data>
    <Service:CreateService>
    <Service:Service>
    </Service:ServiceOrder>
    </Service:CreateService>
    </Service:Data>
    </CreateService>
    or when you're using the xslt mapper try adding at the top in your 'xsl:stylesheet' element something like
    xmlns:Service="and your namespace over here"

  • CFFEED & Namespace Declaration

    I would appreciate some help with generating rss feed for Google Merchant.  I am trying to use cffeed to generate the xml file which I am good with.  The issue is formatting it to google's specifications and their namespace declaration (<g:price></g:rpice>)  how to set a xml structure to include g:  in front of the names?
    Here is a sample of googe xml structure:
    <?xml version="1.0"?>
    <rss version="2.0"
    xmlns:g="http://base.google.com/ns/1.0">
    <channel>
    <title>The name of your data feed</title>
    <link>http://www.example.com</link>
    <description>A description of your content</description>
    <item>
    <title>Red wool sweater</title>
    <link> http://www.example.com/item1-info-page.html</link>
    <description>Comfortable and soft, this sweater will keep you warm on those cold winter nights.</description>
    <g:image_link>http://www.example.com/image1.jpg</g:image_link>
    <g:price>25</g:price>
    <g:condition>new</g:condition>
    <g:id>1a</g:id></item>
    </channel>
    </rss>

    I had a google around, and as far as I can tell it cannot be done with <cffeed> (*).  Just use <cfxml> instead, I reckon.
    And maybe raise an issue with Adobe: http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html.  If you do so, and post the bug ref back here, I'll vote for it too :-)
    Adam
    (*) http://www.coldfusionjedi.com/index.cfm/2008/4/23/Ask-a-Jedi-Handling-RSS-feeds-with-custo m-data.  Ray's pretty clued up about these things, so I'd take his word for it.

  • Add a root node and namespace declaration

    According to the requirement,I have a large appended .txt file.
    This .txt file is created by appending various xml files (without the namespace and root node).
    I need to add a root node and namespace declaration to the large appended .txt file so that it can be read as .xml.
    Please provide the pointers for the same.
    Thanks & Regards,
    Rashi

    My appended file looks like following.
    <input>
       <Store>
          <StoreHeader>
             <StoreNbr>56</StoreNbr>
             <StoreType>Retail</StoreType>
             <StoreSite>2004</StoreSite>
          </StoreHeader>
          <Transactions>
             <Transaction>
                <Item>A</Item>
                <ItemPrice>4</ItemPrice>
             </Transaction>
             <Transaction>
                <Item>C</Item>
                <ItemPrice>56</ItemPrice>
             </Transaction>
          </Transactions>
       </Store>
    </input>
    <input>
       <Store>
          <StoreHeader>
             <StoreNbr>123</StoreNbr>
             <StoreType>Retail</StoreType>
             <StoreSite>2004</StoreSite>
          </StoreHeader>
          <Transactions>
             <Transaction>
                <Item>A</Item>
                <ItemPrice>4</ItemPrice>
             </Transaction>
             <Transaction>
                <Item>B</Item>
                <ItemPrice>8</ItemPrice>
             </Transaction>
             <Transaction>
                <Item>C</Item>
                <ItemPrice>56</ItemPrice>
             </Transaction>
          </Transactions>
       </Store>
    </input>
    Now according to the requirement, I need to add namespace and root node and make it like follows:
    <ns0:output xmlns:ns0="http://xxx">
       <input>
       <Store>
          <StoreHeader>
             <StoreNbr>56</StoreNbr>
             <StoreType>Retail</StoreType>
             <StoreSite>2004</StoreSite>
          </StoreHeader>
          <Transactions>
             <Transaction>
                <Item>A</Item>
                <ItemPrice>4</ItemPrice>
             </Transaction>
             <Transaction>
                <Item>C</Item>
                <ItemPrice>56</ItemPrice>
             </Transaction>
          </Transactions>
       </Store>
    </input>
    <input>
       <Store>
          <StoreHeader>
             <StoreNbr>123</StoreNbr>
             <StoreType>Retail</StoreType>
             <StoreSite>2004</StoreSite>
          </StoreHeader>
          <Transactions>
             <Transaction>
                <Item>A</Item>
                <ItemPrice>4</ItemPrice>
             </Transaction>
             <Transaction>
                <Item>B</Item>
                <ItemPrice>8</ItemPrice>
             </Transaction>
             <Transaction>
                <Item>C</Item>
                <ItemPrice>56</ItemPrice>
             </Transaction>
          </Transactions>
       </Store>
    </input>
    </ns0:output>

Maybe you are looking for

  • Can't start or uninstall Adobe Reader 9.3

    When I try to start Adobe reader I get an error message that jusy says "an internal error occured" Also I get errors when I try to uninstall it or update it. Total frustration. Can anyone help?

  • IPhoto synching to iphone no longer works

    I upgraded to IOS5 and the new iPhoto update but now my phone does not synch to iPhoto. Does it have something to do with iCloud?  1.  My iCloud is not activated because the Apple ID in iCloud is wrong.  Instead they have an email alias in there but

  • Cost center and Org unit relationship.

    Hi Guys, I need quick help from any one of you. Actually our org stucture is like Root-> company->plants-> costcenters( deparments)- users. so we create org unit in the structure with some 100001 and assign users for that cost center  org unit , so b

  • Version 7 fix anytime soon?

    So what is Apple actually doing to rectify the distortion and Ipod problems with Version 7? I can't find any info on if they're working on a Version 7.0.1 or whatever. I don't dare plug my Ipod into it after hearing what has happened with other folks

  • Selection tools question

    I'm fairly new to Photoshop Elements, so hope fully this is a simple question. I've used the selction tools, magic wand, lassos, etc, to trace out areas of a photo that I want to eliminate and fill with another layer.  I only have my background layer